TDME2 1.9.121
GUITabController.cpp
Go to the documentation of this file.
2
3#include <tdme/tdme.h>
16#include <tdme/gui/GUI.h>
17
31using tdme::gui::GUI;
32
33string GUITabController::CONDITION_DISABLED = "disabled";
34string GUITabController::CONDITION_ENABLED = "enabled";
35string GUITabController::CONDITION_SELECTED = "selected";
36string GUITabController::CONDITION_UNSELECTED = "unselected";
37
38GUITabController::GUITabController(GUINode* node)
40{
41 this->tabsNode = nullptr;
42 this->tabsHeaderNode = nullptr;
43 this->selected = false;
44 this->disabled = required_dynamic_cast<GUIElementNode*>(node)->isDisabled();
45}
46
48{
49 return disabled;
50}
51
53{
54 auto& nodeConditions = required_dynamic_cast<GUIElementNode*>(node)->getActiveConditions();
55 nodeConditions.remove(this->disabled == true?CONDITION_DISABLED:CONDITION_ENABLED);
56 this->disabled = disabled;
57 nodeConditions.add(this->disabled == true?CONDITION_DISABLED:CONDITION_ENABLED);
58}
59
61{
62 return selected;
63}
64
66{
67 auto& nodeConditions = required_dynamic_cast<GUIElementNode*>(this->node)->getActiveConditions();
68 nodeConditions.remove(this->selected == true?CONDITION_SELECTED:CONDITION_UNSELECTED);
69 this->selected = selected;
70 nodeConditions.add(this->selected == true?CONDITION_SELECTED:CONDITION_UNSELECTED);
71 if (required_dynamic_cast<GUITabsHeaderController*>(tabsHeaderNode->getController())->hasFocus() == true) {
72 if (selected == true) {
73 auto focussedBorderColor = node->getScreenNode()->getGUI()->getFoccussedBorderColor();
74 auto border = node->getBorder();
75 border.topColor = focussedBorderColor;
76 border.leftColor = focussedBorderColor;
77 border.bottomColor = focussedBorderColor;
78 border.rightColor = focussedBorderColor;
79 } else {
80 auto border = node->getBorder();
82 border.leftColor = unfocussedNodeBorderLeftColor;
83 border.bottomColor = unfocussedNodeBorderBottomColor;
84 border.rightColor = unfocussedNodeBorderRightColor;
85 }
86 } else {
87 auto border = node->getBorder();
89 border.leftColor = unfocussedNodeBorderLeftColor;
90 border.bottomColor = unfocussedNodeBorderBottomColor;
91 border.rightColor = unfocussedNodeBorderRightColor;
92 }
93}
94
96{
97 tabsNode = required_dynamic_cast<GUIParentNode*>(node)->getParentControllerNode()->getParentControllerNode();
98 tabsHeaderNode = required_dynamic_cast<GUIParentNode*>(node)->getParentControllerNode();
99 auto border = node->getBorder();
100 unfocussedNodeBorderTopColor = border.topColor;
101 unfocussedNodeBorderLeftColor = border.leftColor;
102 unfocussedNodeBorderBottomColor = border.bottomColor;
103 unfocussedNodeBorderRightColor = border.rightColor;
105
106 //
107 GUIElementController::initialize();
108}
109
111{
112 GUIElementController::dispose();
113}
114
116{
117}
118
120{
121 GUIElementController::handleMouseEvent(node, event);
122 if (disabled == false && node == this->node && node->isEventBelongingToNode(event) && event->getButton() == MOUSE_BUTTON_LEFT) {
123 event->setProcessed(true);
124 if (event->getType() == GUIMouseEvent::MOUSEEVENT_RELEASED) {
125 auto guiTabsController = required_dynamic_cast<GUITabsController*>(tabsNode->getController());
126 guiTabsController->unselect();
127 guiTabsController->select(required_dynamic_cast<GUIElementNode*>(this->node));
128 guiTabsController->setTabContentSelected(node->getId());
129 }
130 }
131}
132
134{
135 GUIElementController::handleKeyboardEvent(event);
136}
137
139{
140 GUIElementController::tick();
141}
142
144{
145}
146
148{
149}
150
152{
153 return false;
154}
155
157{
158 return value;
159}
160
162{
163}
#define MOUSE_BUTTON_LEFT
GUI module class.
Definition: GUI.h:66
GUIColor & getFoccussedBorderColor()
Definition: GUI.h:303
void onFocusGained() override
On focus gained.
void dispose() override
Dispose controller.
void postLayout() override
Post layout event.
void initialize() override
Initialize controller after element has been created.
void handleKeyboardEvent(GUIKeyboardEvent *event) override
Handle keyboard event.
void onFocusLost() override
On focus lost.
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.
static STATIC_DLL_IMPEXT string CONDITION_DISABLED
static STATIC_DLL_IMPEXT string CONDITION_ENABLED
static STATIC_DLL_IMPEXT string CONDITION_UNSELECTED
void setDisabled(bool disabled) override
Set disabled.
const MutableString & getValue() override
void setSelected(bool selected)
Set checked.
static STATIC_DLL_IMPEXT string CONDITION_SELECTED
GUI element node conditions.
GUI node controller base class.
GUI node base class.
Definition: GUINode.h:63
GUIParentNode * getParentControllerNode()
Definition: GUINode.cpp:1053
const string & getId()
Definition: GUINode.h:329
bool isEventBelongingToNode(GUIMouseEvent *event, Vector2 &position)
Is event belonging to node.
Definition: GUINode.cpp:973
GUINode_Border & getBorder()
Definition: GUINode.h:366
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
GUI node border entity.