ASPiK SDK
cgradientview.h
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 #ifndef __cgradientview__
6 #define __cgradientview__
7 
8 #include "vstguifwd.h"
9 #include "cview.h"
10 #include "ccolor.h"
11 #include "cgradient.h"
12 
13 namespace VSTGUI {
14 
15 //-----------------------------------------------------------------------------
18 //-----------------------------------------------------------------------------
19 class CGradientView : public CView
20 {
21 public:
22  explicit CGradientView (const CRect& size);
23  ~CGradientView () noexcept override = default;
24 
25  //-----------------------------------------------------------------------------
27  //-----------------------------------------------------------------------------
29  enum GradientStyle {
30  kLinearGradient,
31  kRadialGradient
32  };
33 
34  void setGradientStyle (GradientStyle style);
35  void setGradient (CGradient* gradient);
36  void setFrameColor (const CColor& newColor);
37  void setGradientAngle (double angle);
38  void setRoundRectRadius (CCoord radius);
39  void setFrameWidth (CCoord width);
40  void setDrawAntialiased (bool state);
41  void setRadialCenter (const CPoint& center);
42  void setRadialRadius (CCoord radius);
43 
44  GradientStyle getGradientStyle () const { return gradientStyle; }
45  CGradient* getGradient () const { return gradient; }
46  const CColor& getFrameColor () const { return frameColor; }
47  double getGradientAngle () const { return gradientAngle; }
48  CCoord getRoundRectRadius () const { return roundRectRadius; }
49  CCoord getFrameWidth () const { return frameWidth; }
50  bool getDrawAntialised () const { return drawAntialiased; }
51  const CPoint& getRadialCenter () const { return radialCenter; }
52  CCoord getRadialRadius () const { return radialRadius; }
54 
55  // override
56  void setViewSize (const CRect& rect, bool invalid = true) override;
57  void draw (CDrawContext* context) override;
58 protected:
59  virtual void attributeChanged ();
60 
61  GradientStyle gradientStyle {kLinearGradient};
62  CColor frameColor {kBlackCColor};
63  double gradientAngle {0.};
64  CCoord roundRectRadius {5.};
65  CCoord frameWidth {1.};
66  CCoord radialRadius {1.};
67  CPoint radialCenter {0.5, 0.5};
68  bool drawAntialiased {true};
69 
71  SharedPointer<CGradient> gradient;
72 };
73 
74 } // namespace
75 
76 #endif // __cgradientview__
Rect structure.
Definition: crect.h:17
void draw(CDrawContext *context) override
called if the view should draw itself
Definition: cgradientview.cpp:126
Definition: vstguibase.h:299
View which draws a gradient.
Definition: cgradientview.h:19
A drawing context encapsulates the drawing context of the underlying OS.
Definition: cdrawcontext.h:29
RGBA Color structure.
Definition: ccolor.h:15
Gradient Object [new in 4.0].
Definition: cgradient.h:19
Definition: customcontrols.cpp:8
void setViewSize(const CRect &rect, bool invalid=true) override
set views size
Definition: cgradientview.cpp:116
Base Class of all view objects.
Definition: cview.h:44
virtual void invalid()
mark whole view as invalid
Definition: cview.h:63
Point structure.
Definition: cpoint.h:17