ASPiK SDK
cgradient.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 __cgradient__
6 #define __cgradient__
7 
8 #include "vstguifwd.h"
9 #include "ccolor.h"
10 #include <map>
11 #include <algorithm>
12 
13 namespace VSTGUI {
14 
15 //-----------------------------------------------------------------------------
18 //-----------------------------------------------------------------------------
20 {
21 public:
22  using ColorStopMap = std::multimap<double, CColor>;
23 
24  static CGradient* create (const ColorStopMap& colorStopMap);
25  static CGradient* create (double color1Start, double color2Start, const CColor& color1, const CColor& color2)
26  {
27  ColorStopMap map;
28  map.emplace (color1Start, color1);
29  map.emplace (color2Start, color2);
30  return create (map);
31  }
32 
33  //-----------------------------------------------------------------------------
35  //-----------------------------------------------------------------------------
37 
38  void addColorStop (double start, const CColor& color)
39  {
40  addColorStop (std::make_pair (start, color));
41  }
42 
43  virtual void addColorStop (const std::pair<double, CColor>& colorStop)
44  {
45  colorStops.emplace (colorStop);
46  }
47 
48  virtual void addColorStop (std::pair<double, CColor>&& colorStop)
49  {
50  colorStops.emplace (std::move (colorStop));
51  }
52 
53  const ColorStopMap& getColorStops () const { return colorStops; }
55 protected:
56  CGradient (double color1Start, double color2Start, const CColor& color1, const CColor& color2)
57  {
58  addColorStop (color1Start, color1);
59  addColorStop (color2Start, color2);
60  }
61  explicit CGradient (const ColorStopMap& colorStopMap) : colorStops (colorStopMap) {}
62 
63  ColorStopMap colorStops;
64 };
65 
66 }
67 
68 #endif // __cgradient__
RGBA Color structure.
Definition: ccolor.h:15
Gradient Object [new in 4.0].
Definition: cgradient.h:19
Definition: customcontrols.cpp:8
Definition: vstguibase.h:247