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 
5 #pragma once
6 
7 #include "vstguifwd.h"
8 #include <vector>
9 
10 namespace VSTGUI {
11 
12 //-----------
13 // @brief Line Style
14 //-----------
15 class CLineStyle
16 {
17 public:
18 	using CoordVector = std::vector<CCoord>;
19 
20 	enum LineCap
21 	{
22 		kLineCapButt = 0,
23 		kLineCapRound,
24 		kLineCapSquare
25 	};
26 
27 	enum LineJoin
28 	{
29 		kLineJoinMiter = 0,
30 		kLineJoinRound,
31 		kLineJoinBevel
32 	};
33 
34 	CLineStyle () = default;
35 	explicit CLineStyle (LineCap cap, LineJoin join = kLineJoinMiter, CCoord dashPhase = 0., uint32_t dashCount = 0, const CCoord* dashLengths = nullptr);
36 	CLineStyle (LineCap cap, LineJoin join, CCoord dashPhase, const CoordVector& dashLengths);
37 	CLineStyle (const CLineStyle& lineStyle);
38 	~CLineStyle () noexcept = default;
39 
40 	CLineStyle (LineCap cap, LineJoin join, CCoord dashPhase, CoordVector&& dashLengths) noexcept;
41 	CLineStyle (CLineStyle&& cls) noexcept;
42 	CLineStyle& operator= (CLineStyle&& cls) noexcept;
43 
getLineCap()44 	LineCap getLineCap () const { return cap; }
getLineJoin()45 	LineJoin getLineJoin () const { return join; }
getDashPhase()46 	CCoord getDashPhase () const { return dashPhase; }
getDashCount()47 	uint32_t getDashCount () const { return static_cast<uint32_t> (dashLengths.size ()); }
getDashLengths()48 	CoordVector& getDashLengths () { return dashLengths; }
getDashLengths()49 	const CoordVector& getDashLengths() const { return dashLengths; }
50 
setLineCap(LineCap newCap)51 	void setLineCap (LineCap newCap) { cap = newCap; }
setLineJoin(LineJoin newJoin)52 	void setLineJoin (LineJoin newJoin) { join = newJoin; }
setDashPhase(CCoord phase)53 	void setDashPhase (CCoord phase) { dashPhase = phase; }
54 
55 	bool operator== (const CLineStyle& cls) const;
56 	bool operator!= (const CLineStyle& cls) const { return !(*this == cls); }
57 	CLineStyle& operator= (const CLineStyle& cls);
58 
59 protected:
60 	LineCap cap {kLineCapButt};
61 	LineJoin join {kLineJoinMiter};
62 	CCoord dashPhase {0.};
63 	CoordVector dashLengths;
64 };
65 
66 extern const CLineStyle kLineSolid;
67 extern const CLineStyle kLineOnOffDash;
68 
69 } // VSTGUI
70