TDME2 1.9.121
GUITabsHeaderController.cpp
Go to the documentation of this file.
1
3
4#include <tdme/tdme.h>
14#include <tdme/gui/GUI.h>
15
26using tdme::gui::GUI;
27
28GUITabsHeaderController::GUITabsHeaderController(GUINode* node)
30{
31 this->focus = false;
32}
33
35{
36 return false;
37}
38
40{
41}
42
44{
45 tabsNode = required_dynamic_cast<GUIParentNode*>(node)->getParentControllerNode();
46
47 //
48 GUIElementController::initialize();
49
50 //
53}
54
56{
57 GUIElementController::dispose();
58}
59
61{
62}
63
65{
66 return focus;
67}
68
70{
71 if (tabControllerIdx == -1) return;
72 tabControllers[tabControllerIdx]->setSelected(false);
73}
74
76{
77 if (tabControllerIdx == -1) return;
78 tabControllers[tabControllerIdx]->setSelected(true);
79}
80
82 unselect();
83 tabControllerIdx = idx;
85 select();
86}
87
89 auto tabElementNodeController = tabElementNode->getController();
90 auto i = 0;
91 for (auto tabController: tabControllers) {
92 if (tabElementNodeController == tabController) {
93 select(i);
94 break;
95 }
96 i++;
97 }
98}
99
101{
102 vector<GUINode*> childControllerNodes;
103 tabControllers.clear();
104 required_dynamic_cast<GUIParentNode*>(node)->getChildControllerNodes(childControllerNodes);
105 for (auto i = 0; i < childControllerNodes.size(); i++) {
106 auto childControllerNode = childControllerNodes[i];
107 auto childController = childControllerNode->getController();
108 if (dynamic_cast<GUITabController*>(childController) != nullptr) {
109 auto guiTabController = required_dynamic_cast<GUITabController*>(childController);
110 if (static_cast<GUINode*>(guiTabController->getNode()->getParentControllerNode()) != node)
111 continue;
112 tabControllers.push_back(guiTabController);
113 }
114 }
115}
116
118{
119 if (tabControllers.empty() == true) return;
120 if (tabControllerIdx == -1) tabControllerIdx = 0;
121 unselect();
123 if (tabControllerIdx < 0)
125
126 select();
127 auto guiTabsController = required_dynamic_cast<GUITabsController*>(tabsNode->getController());
128 guiTabsController->setTabContentSelected(tabControllers[tabControllerIdx]->getNode()->getId());
129}
130
132{
133 if (tabControllers.empty() == true) return;
134 if (tabControllerIdx == -1) tabControllerIdx = 0;
135 unselect();
137 if (tabControllerIdx < 0)
139
140 select();
141 auto guiTabsController = required_dynamic_cast<GUITabsController*>(tabsNode->getController());
142 guiTabsController->setTabContentSelected(tabControllers[tabControllerIdx]->getNode()->getId());
143}
144
146{
147 if (tabControllers.empty() == true) return;
148 unselect();
149 if (tabControllerIdx == -1) tabControllerIdx = 0;
151 select();
152 auto guiTabsController = required_dynamic_cast<GUITabsController*>(tabsNode->getController());
153 if (guiTabsController->getValue().equals(tabControllers[tabControllerIdx]->getNode()->getId()) == false) {
154 guiTabsController->setTabContentSelected(tabControllers[tabControllerIdx]->getNode()->getId());
155 }
156}
157
159{
160 GUIElementController::handleMouseEvent(node, event);
161 if (node == this->node && node->isEventBelongingToNode(event) && event->getButton() == MOUSE_BUTTON_LEFT) {
162 event->setProcessed(true);
163 if (event->getType() == GUIMouseEvent::MOUSEEVENT_RELEASED) {
164 node->getScreenNode()->getGUI()->setFoccussedNode(required_dynamic_cast<GUIElementNode*>(node));
165 }
166 }
167}
168
170{
171 GUIElementController::handleKeyboardEvent(event);
172 switch (event->getKeyCode()) {
173 case GUIKeyboardEvent::KEYCODE_LEFT: {
174 event->setProcessed(true);
175 if (event->getType() == GUIKeyboardEvent::KEYBOARDEVENT_KEY_PRESSED) {
177 }
178 }
179 break;
180 case GUIKeyboardEvent::KEYCODE_RIGHT: {
181 event->setProcessed(true);
182 if (event->getType() == GUIKeyboardEvent::KEYBOARDEVENT_KEY_PRESSED) {
183 selectNext();
184 }
185 }
186 break;
187 }
188}
189
191{
192 GUIElementController::tick();
193}
194
196{
197 focus = true;
199}
200
202{
203 focus = false;
205}
206
208{
209 return false;
210}
211
213{
214 return value;
215}
216
218{
219}
220
223 if (tabControllerIdx == -1) tabControllerIdx = 0;
226}
227
228
#define MOUSE_BUTTON_LEFT
GUI module class.
Definition: GUI.h:66
void setFoccussedNode(GUIElementNode *newFoccussedNode)
Set focussed node.
Definition: GUI.cpp:359
void initialize() override
Initialize controller after element has been created.
void handleKeyboardEvent(GUIKeyboardEvent *event) override
Handle keyboard event.
void setValue(const MutableString &value) override
Set value.
void handleMouseEvent(GUINode *node, GUIMouseEvent *event) override
Handle mouse event.
void tick() override
Tick method will be executed once per frame.
void setDisabled(bool disabled) override
Set disabled.
void determineTabControllers()
Determine select box option controllers.
void onSubTreeChange() override
On sub tree change.
GUI node base class.
Definition: GUINode.h:63
GUIParentNode * getParentControllerNode()
Definition: GUINode.cpp:1053
bool isEventBelongingToNode(GUIMouseEvent *event, Vector2 &position)
Is event belonging to node.
Definition: GUINode.cpp:973
GUIScreenNode * getScreenNode()
Definition: GUINode.h:315
GUINodeController * getController()
Definition: GUINode.h:586
GUI parent node base class thats supporting child nodes.
Definition: GUIParentNode.h:43
GUI screen node that represents a screen that can be rendered via GUI system.
Definition: GUIScreenNode.h:57
Mutable string class.
Definition: MutableString.h:16