TDME2  1.9.200
GUIGradientNode.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <string>
4 
5 #include <tdme/tdme.h>
7 #include <tdme/gui/fwd-tdme.h>
10 #include <tdme/gui/nodes/GUINode.h>
14 #include <tdme/math/Matrix3x3.h>
15 
16 using std::string;
17 
33 
34 /**
35  * GUI gradient node
36  * @author Andreas Drewke
37  */
39  : public GUINode
40 {
41  friend class tdme::gui::GUIParser;
42 
43 public:
44  struct Gradient {
45  int count { 0 };
46  array<GUIColor, 10> colors;
47  array<float, 10> colorStarts;
48  float rotationAngle { 0.0f };
49  };
50 
51  /**
52  * Create gradient from string values
53  * @param colors colors
54  * @param rotation rotation
55  */
56  static Gradient createGradient(const string& colors, const string& rotation);
57 
58 private:
62  Texture* maskTexture { nullptr };
63  float maskMaxValue;
64  int32_t maskTextureId { 0 };
65 
67  string mask;
68 
70 
71 protected:
72  // forbid class copy
74 
75  /**
76  * Constructor
77  * @param screenNode screen node
78  * @param parentNode parent node
79  * @param id id
80  * @param flow flow
81  * @param alignments alignments
82  * @param requestedConstraints requested constraints
83  * @param backgroundColor background color
84  * @param backgroundImage background image
85  * @param backgroundImageScale9Grid background image scale 9 grid
86  * @param backgroundImageEffectColorMul background image effect color mul
87  * @param backgroundImageEffectColorAdd background image effect color add
88  * @param border border
89  * @param padding padding
90  * @param showOn show on
91  * @param hideOn hide on
92  * @param tooltip tooltip
93  * @param effectColorMul effect color mul
94  * @param effectColorAdd effect color add
95  * @param clipping clipping
96  * @param mask mask image
97  * @param maskMaxValue maximum value of mask to display image
98  * @param gradient gradient
99  * @throws tdme::gui::GUIParserException
100  */
104  const string& id,
108  const GUIColor& backgroundColor,
109  const string& backgroundImage,
113  const GUINode_Border& border,
114  const GUINode_Padding& padding,
115  const GUINodeConditions& showOn,
116  const GUINodeConditions& hideOn,
117  const string& tooltip,
118  const GUIColor& effectColorMul,
119  const GUIColor& effectColorAdd,
120  const GUINode_Clipping& clipping,
121  const string& mask,
122  float maskMaxValue,
123  const Gradient& gradient
124  );
125 
126  // overridden methods
127  const string getNodeType() override;
128  bool isContentNode() override;
129 
130 public:
131  // overridden methods
132  int getContentWidth() override;
133  int getContentHeight() override;
134  void dispose() override;
135  void render(GUIRenderer* guiRenderer) override;
136 
137  /**
138  * Set texture matrix
139  * @param textureMatrix texture matrix
140  */
142 
143  /**
144  * @return effect color mul
145  */
146  const GUIColor& getEffectColorMul();
147 
148  /**
149  * Set effect color mul
150  * @param effectColorMul effect color mul
151  */
153 
154  /**
155  * @return effect color add
156  */
157  const GUIColor& getEffectColorAdd();
158 
159  /**
160  * Set effect color add
161  * @param effectColorAdd effect color add
162  */
164 
165  /**
166  * @return clipping
167  */
169 
170  /**
171  * Create clipping
172  * @param allClipping all sides
173  * @param left left
174  * @param top top
175  * @param right right
176  * @param bottom bottom
177  */
178  static GUINode_Clipping createClipping(const string& allClipping, const string& left, const string& top, const string& right, const string& bottom);
179 
180  /**
181  * @return mask source
182  */
183  const string& getMask();
184 
185  /**
186  * Set mask source
187  * @param mask mask source
188  */
189  void setMask(const string& mask);
190 
191  /**
192  * @return maximum value of mask to display image
193  */
194  float getMaskMaxValue() {
195  return maskMaxValue;
196  }
197 
198  /**
199  * Set maximum value of mask to display image
200  * @param maskMinValue value of mask to display image
201  */
203  this->maskMaxValue = maskMaxValue;
204  }
205 
206 };
Texture entity.
Definition: Texture.h:24
GUI parser.
Definition: GUIParser.h:40
static GUINode_Clipping createClipping(const string &allClipping, const string &left, const string &top, const string &right, const string &bottom)
Create clipping.
const string getNodeType() override
GUIGradientNode(GUIScreenNode *screenNode, GUIParentNode *parentNode, const string &id, GUINode_Flow *flow, const GUINode_Alignments &alignments, const GUINode_RequestedConstraints &requestedConstraints, const GUIColor &backgroundColor, const string &backgroundImage, const GUINode_Scale9Grid &backgroundImageScale9Grid, const GUIColor &backgroundImageEffectColorMul, const GUIColor &backgroundImageEffectColorAdd, const GUINode_Border &border, const GUINode_Padding &padding, const GUINodeConditions &showOn, const GUINodeConditions &hideOn, const string &tooltip, const GUIColor &effectColorMul, const GUIColor &effectColorAdd, const GUINode_Clipping &clipping, const string &mask, float maskMaxValue, const Gradient &gradient)
Constructor.
void setEffectColorMul(const GUIColor &effectColorMul)
Set effect color mul.
void dispose() override
Dispose node.
void setMaskMaxValue(float maskMaxValue)
Set maximum value of mask to display image.
void setMask(const string &mask)
Set mask source.
static Gradient createGradient(const string &colors, const string &rotation)
Create gradient from string values.
void render(GUIRenderer *guiRenderer) override
Render.
void setEffectColorAdd(const GUIColor &effectColorAdd)
Set effect color add.
void setTextureMatrix(const Matrix3x3 &textureMatrix)
Set texture matrix.
GUI element node conditions.
GUI node base class.
Definition: GUINode.h:64
GUINodeConditions hideOn
Definition: GUINode.h:162
GUIColor backgroundImageEffectColorMul
Definition: GUINode.h:157
GUINode_Border border
Definition: GUINode.h:160
GUINode_Scale9Grid backgroundImageScale9Grid
Definition: GUINode.h:156
GUIColor backgroundImageEffectColorAdd
Definition: GUINode.h:158
GUIParentNode * parentNode
Definition: GUINode.h:148
GUINode_Padding padding
Definition: GUINode.h:159
GUIScreenNode * screenNode
Definition: GUINode.h:147
GUINode_RequestedConstraints requestedConstraints
Definition: GUINode.h:151
GUINode_Alignments alignments
Definition: GUINode.h:150
GUINodeConditions showOn
Definition: GUINode.h:161
GUINode_Flow * flow
Definition: GUINode.h:86
GUI parent node base class thats supporting child nodes.
Definition: GUIParentNode.h:42
GUI screen node that represents a screen that can be rendered via GUI system.
Definition: GUIScreenNode.h:72
Matrix3x3 class representing matrix3x3 mathematical structure and operations for 2d space.
Definition: Matrix3x3.h:20
GUI node border entity.
GUI node clipping entity.
GUI node padding entity.
GUI node scale 9 grid entity.
#define FORBID_CLASS_COPY(CLASS)
Definition: tdme.h:6