DISTRHO Plugin Framework
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

92 lines
2.8KB

  1. // This file is part of VSTGUI. It is subject to the license terms
  2. // in the LICENSE file found in the top-level directory of this
  3. // distribution and at http://github.com/steinbergmedia/vstgui/LICENSE
  4. #include "clinestyle.h"
  5. namespace VSTGUI {
  6. //-----------------------------------------------------------------------------
  7. //-----------------------------------------------------------------------------
  8. //-----------------------------------------------------------------------------
  9. CLineStyle::CLineStyle (LineCap _cap, LineJoin _join, CCoord _dashPhase, uint32_t _dashCount, const CCoord* _dashLengths)
  10. : cap (_cap)
  11. , join (_join)
  12. , dashPhase (_dashPhase)
  13. {
  14. if (_dashCount && _dashLengths)
  15. {
  16. for (uint32_t i = 0; i < _dashCount; i++)
  17. dashLengths.emplace_back (_dashLengths[i]);
  18. }
  19. }
  20. //-----------------------------------------------------------------------------
  21. CLineStyle::CLineStyle (LineCap _cap, LineJoin _join, CCoord _dashPhase, const CoordVector& _dashLengths)
  22. : cap (_cap)
  23. , join (_join)
  24. , dashPhase (_dashPhase)
  25. , dashLengths (_dashLengths)
  26. {
  27. }
  28. //-----------------------------------------------------------------------------
  29. CLineStyle::CLineStyle (const CLineStyle& lineStyle)
  30. {
  31. *this = lineStyle;
  32. }
  33. //-----------------------------------------------------------------------------
  34. CLineStyle::CLineStyle (LineCap _cap, LineJoin _join, CCoord _dashPhase, CoordVector&& _dashLengths) noexcept
  35. : cap (_cap)
  36. , join (_join)
  37. , dashPhase (_dashPhase)
  38. , dashLengths (std::move (_dashLengths))
  39. {
  40. }
  41. //-----------------------------------------------------------------------------
  42. CLineStyle::CLineStyle (CLineStyle&& cls) noexcept
  43. {
  44. *this = std::move (cls);
  45. }
  46. //-----------------------------------------------------------------------------
  47. CLineStyle& CLineStyle::operator= (CLineStyle&& cls) noexcept
  48. {
  49. dashLengths.clear ();
  50. cap = cls.cap;
  51. join = cls.join;
  52. dashPhase = cls.dashPhase;
  53. dashLengths = std::move (cls.dashLengths);
  54. return *this;
  55. }
  56. //-----------------------------------------------------------------------------
  57. bool CLineStyle::operator== (const CLineStyle& cls) const
  58. {
  59. if (cap == cls.cap && join == cls.join && dashPhase == cls.dashPhase && dashLengths == cls.dashLengths)
  60. {
  61. return true;
  62. }
  63. return false;
  64. }
  65. //-----------------------------------------------------------------------------
  66. CLineStyle& CLineStyle::operator= (const CLineStyle& cls)
  67. {
  68. dashLengths.clear ();
  69. cap = cls.cap;
  70. join = cls.join;
  71. dashPhase = cls.dashPhase;
  72. dashLengths = cls.dashLengths;
  73. return *this;
  74. }
  75. //-----------------------------------------------------------------------------
  76. static const CCoord kDefaultOnOffDashLength[] = {1, 1};
  77. const CLineStyle kLineSolid {};
  78. const CLineStyle kLineOnOffDash (CLineStyle::kLineCapButt, CLineStyle::kLineJoinMiter, 0, 2, kDefaultOnOffDashLength);
  79. }