TDME2  1.9.200
GUISelectBoxParentOptionController.cpp
Go to the documentation of this file.
2 
3 #include <memory>
4 
5 #include <tdme/tdme.h>
10 #include <tdme/gui/nodes/GUINode.h>
14 #include <tdme/gui/GUI.h>
15 
16 using std::make_unique;
17 using std::unique_ptr;
18 
28 using tdme::gui::GUI;
29 
30 string GUISelectBoxParentOptionController::CONDITION_EXPANDED = "expanded";
31 string GUISelectBoxParentOptionController::CONDITION_COLLAPSED = "collapsed";
32 
33 GUISelectBoxParentOptionController::GUISelectBoxParentOptionController(GUINode* node)
34  : GUISelectBoxOptionController(node), expanded(false)
35 {
36 }
37 
39 {
40  class ArrowNodeActionListener: public virtual GUIActionListener
41  {
42 
43  public:
44  // overridden method
45  void onAction(GUIActionListenerType type, GUIElementNode* node) override {
46  if (node == selectBoxParentOptionController->arrowNode && type == GUIActionListenerType::PERFORMED) {
47  required_dynamic_cast<GUISelectBoxController*>(selectBoxParentOptionController->selectBoxNode->getController())->toggleOpenState(required_dynamic_cast<GUIElementNode*>(selectBoxParentOptionController->node));
48  }
49  }
50 
51  /**
52  * Public constructor
53  * @param selectBoxParentOptionController select box parent option controller
54  */
55  ArrowNodeActionListener(GUISelectBoxParentOptionController* selectBoxParentOptionController): selectBoxParentOptionController(selectBoxParentOptionController) {
56  }
57 
58  private:
59  GUISelectBoxParentOptionController* selectBoxParentOptionController { nullptr };
60  };
61  arrowNode = required_dynamic_cast<GUIElementNode*>(node->getScreenNode()->getNodeById(node->getId() + "_arrow"));
63  arrowNode->getScreenNode()->addActionListener((arrowNodeActionListener = make_unique<ArrowNodeActionListener>(this)).get());
64  //
66 }
67 
69  if (arrowNodeActionListener != nullptr) {
71  arrowNodeActionListener = nullptr;
72  }
73 }
74 
76  return expanded;
77 }
78 
80 {
82  expanded = expanded == true?false:true;
84 }
GUI module class.
Definition: GUI.h:64
void initialize() override
Initialize controller after element has been created.
void initialize() override
Initialize controller after element has been created.
GUINodeConditions & getActiveConditions()
GUI element node conditions.
bool add(const string &condition)
Add a condition.
bool remove(const string &condition)
Remove a condition.
GUI node base class.
Definition: GUINode.h:64
GUIScreenNode * getScreenNode()
Definition: GUINode.h:325
const string & getId()
Definition: GUINode.h:339
GUI parent node base class thats supporting child nodes.
Definition: GUIParentNode.h:42
GUI screen node that represents a screen that can be rendered via GUI system.
Definition: GUIScreenNode.h:72
void removeActionListener(GUIActionListener *listener)
Remove action listener.
void addActionListener(GUIActionListener *listener)
Add action listener.
GUINode * getNodeById(const string &nodeId)
Get GUI node by id.
GUI action listener interface.