TDME2 1.9.121
GUIContextMenuItemController.cpp
Go to the documentation of this file.
2
3#include <string>
4
5#include <tdme/tdme.h>
16#include <tdme/gui/GUI.h>
19
20using std::string;
21
32using tdme::gui::GUI;
35
36string GUIContextMenuItemController::CONDITION_SELECTED = "selected";
37string GUIContextMenuItemController::CONDITION_UNSELECTED = "unselected";
38
39GUIContextMenuItemController::GUIContextMenuItemController(GUINode* node)
41{
42 this->selected = required_dynamic_cast<GUIElementNode*>(node)->isSelected();
43}
44
46{
47 return selected;
48}
49
51{
52 auto& nodeConditions = required_dynamic_cast<GUIElementNode*>(node)->getActiveConditions();
53 nodeConditions.remove(this->selected == true?CONDITION_SELECTED:CONDITION_UNSELECTED);
54 this->selected = true;
55 nodeConditions.add(this->selected == true?CONDITION_SELECTED:CONDITION_UNSELECTED);
56}
57
59{
60 auto& nodeConditions = required_dynamic_cast<GUIElementNode*>(node)->getActiveConditions();
61 nodeConditions.remove(this->selected == true?CONDITION_SELECTED:CONDITION_UNSELECTED);
62 this->selected = false;
63 nodeConditions.add(this->selected == true?CONDITION_SELECTED:CONDITION_UNSELECTED);
64}
65
67{
69 while (true == true) {
70 if (dynamic_cast<GUIContextMenuController*>(contextMenuNode->getController()) != nullptr) {
71 break;
72 }
74 }
75 if (selected == true) {
76 select();
77 } else {
78 unselect();
79 }
81
82 //
83 GUIElementController::initialize();
84}
85
87{
88}
89
91{
92 GUIElementController::dispose();
93}
94
96{
97 GUIElementController::handleMouseEvent(node, event);
98 if (isDisabled() == false && node == this->node && node->isEventBelongingToNode(event)) {
99 event->setProcessed(true);
100 if (event->getType() == GUIMouseEvent::MOUSEEVENT_PRESSED) {
101 node->getScreenNode()->getGUI()->setFoccussedNode(required_dynamic_cast<GUIElementNode*>(contextMenuNode));
102 }
103 }
104}
105
107{
108 GUIElementController::handleKeyboardEvent(event);
109}
110
112{
113 GUIElementController::tick();
114}
115
117{
118}
119
121{
122}
123
125{
126 return false;
127}
128
130{
131 return value;
132}
133
135{
136}
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.
GUI element node conditions.
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
String tools class.
Definition: StringTools.h:20