ASPiK SDK
cairogradient.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 #pragma once
6 
7 #include "../../cgradient.h"
8 #include "../../cpoint.h"
9 #include "cairoutils.h"
10 #include <cairo/cairo.h>
11 
12 //------------------------------------------------------------------------
13 namespace VSTGUI {
14 namespace Cairo {
15 
16 //------------------------------------------------------------------------
17 class Gradient : public CGradient
18 {
19 public:
20  Gradient (const ColorStopMap& colorStopMap);
21  ~Gradient ();
22 
23  void addColorStop (const std::pair<double, CColor>& colorStop) override
24  {
25  destroy ();
26  CGradient::addColorStop (colorStop);
27  }
28 
29 #if VSTGUI_RVALUE_REF_SUPPORT
30  void addColorStop (std::pair<double, CColor>&& colorStop) override
31  {
32  destroy ();
33  CGradient::addColorStop (std::move (colorStop));
34  }
35 #endif
36 
37  const PatternHandle& getLinearGradient (CPoint start, CPoint end) const;
38  const PatternHandle& getRadialGradient () const;
39 
40 private:
41  void destroy () const;
42 
43  /* we want to calculate a normalized linear and radial gradiant */
44  mutable PatternHandle linearGradient;
45  mutable PatternHandle radialGradient;
46 
47  mutable CPoint linearGradientStart;
48  mutable CPoint linearGradientEnd;
49 };
50 
51 //------------------------------------------------------------------------
52 } // Cairo
53 } // VSTGUI
Definition: cairogradient.h:17
Gradient Object [new in 4.0].
Definition: cgradient.h:19
Definition: customcontrols.cpp:8
Point structure.
Definition: cpoint.h:17