TDME2  1.9.200
GUISelectBoxController.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <string>
4 #include <vector>
5 
6 #include <tdme/tdme.h>
12 
13 using std::string;
14 using std::vector;
15 
23 
24 /**
25  * GUI select box controller
26  * @author Andreas Drewke
27  */
29  : public GUIElementController
30 {
31  friend class GUISelectBox;
33 
34 private:
37  STATIC_DLL_IMPEXT static constexpr char VALUE_DELIMITER { '|' };
38  vector<GUISelectBoxOptionController*> selectBoxOptionControllers;
39  bool disabled;
44 
45  bool keyControl;
46 
47  // forbid class copy
49 
50  /**
51  * Private constructor
52  * @param node node
53  */
55 
56  /**
57  * @return if multiple selection is enabled
58  */
59  bool isMultipleSelection();
60 
61  /**
62  * @return is control down
63  */
64  bool isKeyControlDown();
65 
66  /**
67  * Get focussed option idx
68  */
70 
71  /**
72  * Get focussed option idx
73  * @param optionElementNode option element node
74  */
75  int getOptionIdx(GUIElementNode* optionElementNode);
76 
77  /**
78  * Unselect all nodes
79  */
80  void unselect();
81 
82  /**
83  * Select
84  * @param optionIdx option index
85  */
86  void select(int optionIdx);
87 
88  /**
89  * Select
90  * @param optionElementNode option element node
91  */
92  void select(GUIElementNode* optionElementNode);
93 
94  /**
95  * Unfocus all nodes
96  */
97  void unfocus();
98 
99  /**
100  * Focus
101  * @param optionIdx option index
102  */
103  void focus(int optionIdx);
104 
105  /**
106  * Focus
107  * @param optionElementNode option element node
108  */
109  void focus(GUIElementNode* optionElementNode);
110 
111  /**
112  * Select current options
113  */
114  void selectCurrent();
115 
116  /**
117  * Focus next option
118  */
119  void focusNext();
120 
121  /**
122  * Focus previous option
123  */
124  void focusPrevious();
125 
126  /**
127  * Toggle
128  * @param optionIdx option index
129  */
130  void toggle(int optionIdx);
131 
132  /**
133  * Toggle
134  * @param optionElementNode option element node
135  */
136  void toggle(GUIElementNode* optionElementNode);
137 
138  /**
139  * Select focussed node
140  */
141  void select();
142 
143  /**
144  * Determine all options
145  */
146  void determineAllOptions();
147 
148  /**
149  * Determine expanded options
150  */
152 
153  /**
154  * Determine parent options
155  */
156  void determineParentOptions();
157 
158  /**
159  * Toggle open state of current parent option
160  * @param optionIdx option index
161  */
162  void toggleOpenState(int optionIdx);
163 
164  /**
165  * Expand
166  * @param optionIdx option index
167  */
168  void expand(int optionIdx);
169 
170  /**
171  * Collapse
172  * @param optionIdx option index
173  */
174  void collapse(int optionIdx);
175 
176 public:
177  /**
178  * Toggle open state of current parent option
179  * @param optionElementNode option element node
180  */
181  void toggleOpenState(GUIElementNode* optionElementNode);
182 
183  // overridden methods
184  void initialize() override;
185  void dispose() override;
186  void postLayout() override;
187  void handleMouseEvent(GUINode* node, GUIMouseEvent* event) override;
188  void handleKeyboardEvent(GUIKeyboardEvent* event) override;
189  void tick() override;
190  void onFocusGained() override;
191  void onFocusLost() override;
192  bool hasValue() override;
193  const MutableString& getValue() override;
194  void setValue(const MutableString& value) override;
195  void onSubTreeChange() override;
196 
197  /**
198  * Determine expanded parent option values
199  * @param expandedParentOptionValues expanded parent option values
200  */
201  void determineExpandedParentOptionValues(vector<string>& expandedParentOptionValues);
202 
203  /**
204  * Expand parent options by values
205  * @param expandedParentOptionValues expanded parent option values
206  */
207  void expandParentOptionsByValues(const vector<string>& expandedParentOptionValues);
208 
209 };
void dispose() override
Dispose controller.
void postLayout() override
Post layout event.
void determineExpandedParentOptionValues(vector< string > &expandedParentOptionValues)
Determine expanded parent option values.
void initialize() override
Initialize controller after element has been created.
GUISelectBoxController(GUINode *node)
Private constructor.
void handleKeyboardEvent(GUIKeyboardEvent *event) override
Handle keyboard event.
void determineExpandedOptions()
Determine expanded options.
void setValue(const MutableString &value) override
Set value.
void handleMouseEvent(GUINode *node, GUIMouseEvent *event) override
Handle mouse event.
void determineParentOptions()
Determine parent options.
void tick() override
Tick method will be executed once per frame.
static constexpr STATIC_DLL_IMPEXT char VALUE_DELIMITER
static STATIC_DLL_IMPEXT string CONDITION_DISABLED
static STATIC_DLL_IMPEXT string CONDITION_ENABLED
void toggleOpenState(int optionIdx)
Toggle open state of current parent option.
vector< GUISelectBoxOptionController * > selectBoxOptionControllers
void expandParentOptionsByValues(const vector< string > &expandedParentOptionValues)
Expand parent options by values.
void onSubTreeChange() override
On sub tree change.
int getOptionIdx(GUIElementNode *optionElementNode)
Get focussed option idx.
GUI select box element.
Definition: GUISelectBox.h:28
GUI node controller base class.
GUI node base class.
Definition: GUINode.h:64
Mutable utf8 aware string class.
Definition: MutableString.h:23
#define STATIC_DLL_IMPEXT
Definition: tdme.h:15
#define FORBID_CLASS_COPY(CLASS)
Definition: tdme.h:6