TDME2  1.9.200
GUIParentNode.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <string>
4 #include <unordered_set>
5 #include <vector>
6 
7 #include <tdme/tdme.h>
9 #include <tdme/gui/fwd-tdme.h>
11 #include <tdme/gui/nodes/GUINode.h>
15 
16 using std::string;
17 using std::unordered_set;
18 using std::vector;
19 
35 
36 /**
37  * GUI parent node base class thats supporting child nodes
38  * @author Andreas Drewke
39  */
41  : public GUINode
42 {
43  friend class tdme::gui::GUI;
44  friend class tdme::gui::GUIParser;
45  friend class GUIElementNode;
46  friend class GUILayerNode;
47  friend class GUILayoutNode;
48  friend class GUINode;
49  friend class GUINodeConditions;
50  friend class GUIScreenNode;
51  friend class GUITableNode;
52  friend class GUITableCellNode;
53  friend class GUITableRowNode;
56  friend class GUIParentNode_Overflow;
57 private:
60 
61 protected:
62  vector<GUINode*> subNodes;
64  vector<GUINode*> vieportSubNodesCache;
65  vector<GUINode*> floatingNodesCache;
68 
69  // forbid class copy
71 
72  /**
73  * Constructor
74  * @param screenNode screen node
75  * @param parentNode parent node
76  * @param id id
77  * @param flow flow
78  * @param overflowX overflow x
79  * @param overflowY overflow y
80  * @param alignments alignments
81  * @param requestedConstraints requested constraints
82  * @param backgroundColor background color
83  * @param backgroundImage background image
84  * @param backgroundImageScale9Grid background image scale 9 grid
85  * @param backgroundImageEffectColorMul background image effect color mul
86  * @param backgroundImageEffectColorAdd background image effect color add
87  * @param border border
88  * @param padding padding
89  * @param showOn show on
90  * @param hideOn hide on
91  * @param tooltip tooltip
92  * @throws tdme::gui::GUIParserException
93  */
97  const string& id,
103  const GUIColor& backgroundColor,
104  const string& backgroundImage,
108  const GUINode_Border& border,
109  const GUINode_Padding& padding,
110  const GUINodeConditions& showOn,
111  const GUINodeConditions& hideOn,
112  const string& tooltip
113  );
114 
115  /**
116  * Layout
117  */
118  void layout() override;
119 
120  /**
121  * Layout sub nodes
122  */
123  virtual void layoutSubNodes();
124 
125  /**
126  * Compute horizontal children alignment
127  */
128  virtual void computeHorizontalChildrenAlignment();
129 
130  /**
131  * Compute vertical children alignment
132  */
133  virtual void computeVerticalChildrenAlignment();
134 
135  /**
136  * Detach sub node at given index
137  * @param index sub node index
138  * @returns sub node at given index
139  */
140  GUINode* detachSubNode(int index);
141 
142  /**
143  * Detach sub nodes
144  * @returns sub nodes
145  */
146  vector<GUINode*> detachSubNodes();
147 
148 public:
149 
150  /**
151  * @return sub nodes count
152  */
153  inline int getSubNodesCount() {
154  return subNodes.size();
155  }
156 
157  /**
158  * Clear sub nodes
159  */
160  void clearSubNodes();
161 
162  /**
163  * Replace sub nodes with given XML
164  * @param xml xml
165  * @param resetScrollOffsets reset scroll offsets
166  * @throws tdme::gui::GUIParserException
167  */
168  void replaceSubNodes(const string& xml, bool resetScrollOffsets);
169 
170  /**
171  * Add sub nodes with given XML
172  * @param xml xml
173  * @param resetScrollOffsets reset scroll offsets
174  * @throws tdme::gui::GUIParserException
175  */
176  void addSubNodes(const string& xml, bool resetScrollOffsets);
177 
178  /**
179  * Add sub node
180  * @param node node
181  * @throws tdme::gui::GUIParserException
182  */
183  void addSubNode(GUINode* node);
184 
185  /**
186  * Move children node from other parent node into this parent node
187  * @param otherParentNode other parent node
188  * @param index other parent node sub node index
189  */
190  void moveSubNode(GUIParentNode* otherParentNode, int index);
191 
192  /**
193  * Move children nodes from other parent node into this parent node
194  * @param otherParentNode other parent node
195  */
196  void moveSubNodes(GUIParentNode* otherParentNode);
197 
198  /**
199  * @return overflow x
200  */
202 
203  /**
204  * @return overflow y
205  */
207 
208  /**
209  * Create over flow
210  * @param overflow over flow
211  * @return over flow
212  * @throws tdme::gui::GUIParserException
213  */
214  static GUIParentNode_Overflow* createOverflow(const string& overflow);
215 
216  /**
217  * @return children render offset x
218  */
219  inline float getChildrenRenderOffsetX() {
220  return childrenRenderOffsetX;
221  }
222 
223  /**
224  * Set children render offset x
225  * @param childrenRenderOffSetX children render offset x
226  */
227  void setChildrenRenderOffsetX(float childrenRenderOffSetX);
228 
229  /**
230  * @return children render offset y
231  */
232  inline float getChildrenRenderOffsetY() {
233  return childrenRenderOffsetY;
234  }
235 
236  /**
237  * Set children render offset y
238  * @param childrenRenderOffSetY children render offset y
239  */
240  void setChildrenRenderOffsetY(float childrenRenderOffSetY);
241 
242  /**
243  * Create requested constraints
244  * @param left left
245  * @param top top
246  * @param width width
247  * @param height height
248  * @param factor factor
249  * @return requested constraints
250  */
251  static GUINode_RequestedConstraints createRequestedConstraints(const string& left, const string& top, const string& width, const string& height, int factor);
252 
253  /**
254  * Get child controller nodes
255  * @param childControllerNodes child controller nodes
256  * @param requireConditionsMet require conditions met
257  */
258  void getChildControllerNodes(vector<GUINode*>& childControllerNodes, bool requireConditionsMet = false);
259 
260  // overridden methods
261  void dispose() override;
262  void setConditionsMet() override;
263  void render(GUIRenderer* guiRenderer) override;
264  void determineNodesByCoordinate(const Vector2& coordinate, unordered_set<string>& nodeIds) override;
265  void determineMouseEventNodes(GUIMouseEvent* event, bool floatingNode, unordered_set<string>& eventNodeIds, unordered_set<string>& eventFloatingNodeIds, int flags = DETERMINEMOUSEEVENTNODES_FLAG_NONE) override;
266 
267  /**
268  * Invalidate render caches
269  */
270  void invalidateRenderCaches();
271 
272 private:
273  /**
274  * Get child controller nodes internal
275  * @param childControllerNodes child controller nodes
276  * @param requireConditionsMet require conditions met
277  */
278  void getChildControllerNodesInternal(vector<GUINode*>& childControllerNodes, bool requireConditionsMet = false);
279 
280  /**
281  * Remove sub node
282  * @param node node
283  * @param resetScrollOffsets reset scroll offsets
284  */
285  void removeSubNode(GUINode* node, bool resetScrollOffsets);
286 
287  /**
288  * Unset mouse over and click conditions on element nodes
289  */
290  void unsetMouseStates();
291 
292 };
GUI parser.
Definition: GUIParser.h:40
GUI module class.
Definition: GUI.h:64
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
friend class GUIParentNode
Definition: GUINode.h:70
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
static constexpr int DETERMINEMOUSEEVENTNODES_FLAG_NONE
Definition: GUINode.h:319
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
GUIParentNode_Overflow * overflowX
Definition: GUIParentNode.h:66
void getChildControllerNodes(vector< GUINode * > &childControllerNodes, bool requireConditionsMet=false)
Get child controller nodes.
void dispose() override
Dispose node.
virtual void computeHorizontalChildrenAlignment()
Compute horizontal children alignment.
void setConditionsMet() override
Set conditions met for this node and its subnodes.
void getChildControllerNodesInternal(vector< GUINode * > &childControllerNodes, bool requireConditionsMet=false)
Get child controller nodes internal.
static GUIParentNode_Overflow * createOverflow(const string &overflow)
Create over flow.
void setChildrenRenderOffsetX(float childrenRenderOffSetX)
Set children render offset x.
GUIParentNode_Overflow * getOverflowX()
void removeSubNode(GUINode *node, bool resetScrollOffsets)
Remove sub node.
vector< GUINode * > vieportSubNodesCache
Definition: GUIParentNode.h:64
void replaceSubNodes(const string &xml, bool resetScrollOffsets)
Replace sub nodes with given XML.
void layout() override
Layout.
void clearSubNodes()
Clear sub nodes.
void unsetMouseStates()
Unset mouse over and click conditions on element nodes.
GUIParentNode_Overflow * getOverflowY()
vector< GUINode * > floatingNodesCache
Definition: GUIParentNode.h:65
void determineMouseEventNodes(GUIMouseEvent *event, bool floatingNode, unordered_set< string > &eventNodeIds, unordered_set< string > &eventFloatingNodeIds, int flags=DETERMINEMOUSEEVENTNODES_FLAG_NONE) override
Determine mouse event nodes.
void moveSubNodes(GUIParentNode *otherParentNode)
Move children nodes from other parent node into this parent node.
void render(GUIRenderer *guiRenderer) override
Render.
void moveSubNode(GUIParentNode *otherParentNode, int index)
Move children node from other parent node into this parent node.
GUINode * detachSubNode(int index)
Detach sub node at given index.
GUIParentNode_Overflow * overflowY
Definition: GUIParentNode.h:67
virtual void layoutSubNodes()
Layout sub nodes.
vector< GUINode * > subNodes
Definition: GUIParentNode.h:62
static GUINode_RequestedConstraints createRequestedConstraints(const string &left, const string &top, const string &width, const string &height, int factor)
Create requested constraints.
vector< GUINode * > detachSubNodes()
Detach sub nodes.
void setChildrenRenderOffsetY(float childrenRenderOffSetY)
Set children render offset y.
void addSubNode(GUINode *node)
Add sub node.
void determineNodesByCoordinate(const Vector2 &coordinate, unordered_set< string > &nodeIds) override
Determine nodes by coordinate.
virtual void computeVerticalChildrenAlignment()
Compute vertical children alignment.
void addSubNodes(const string &xml, bool resetScrollOffsets)
Add sub nodes with given XML.
void invalidateRenderCaches()
Invalidate render caches.
GUI screen node that represents a screen that can be rendered via GUI system.
Definition: GUIScreenNode.h:72
Vector2 class representing vector2 mathematical structure and operations with x, y components.
Definition: Vector2.h:20
GUI node border entity.
GUI node padding entity.
GUI node scale 9 grid entity.
#define FORBID_CLASS_COPY(CLASS)
Definition: tdme.h:6