TDME2  1.9.200
ContextMenuScreenController.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <string>
4 #include <unordered_map>
5 
6 #include <tdme/tdme.h>
18 
19 using std::string;
20 using std::unordered_map;
21 
35 
36 /**
37  * Context menu screen controller
38  * @author Andreas Drewke
39  */
41  : public ScreenController
42  , public virtual GUIActionListener
43  , public virtual GUIChangeListener
44  , public virtual GUIFocusListener
45  , public virtual GUITooltipRequestListener
46  , public virtual GUIInputEventHandler
47 {
48 public:
51  virtual void onMethodSelection(const string& methodName) = 0;
52  };
53 
54 private:
55  PopUps* popUps { nullptr };
56  GUIScreenNode* screenNode { nullptr };
58  unordered_map<string, Action*> actions;
59 
61 
63 
64 public:
65  // forbid class copy
67 
68  /**
69  * Public constructor
70  * @param popUps pop ups
71  */
73 
74  /**
75  * Destructor
76  */
78 
79  /**
80  * Set MiniScript method selection listener
81  * @param miniScriptMethodSelectionListener MiniScript method selection listener
82  */
84  this->miniScriptMethodSelectionListener = miniScriptMethodSelectionListener;
85  }
86 
87  /**
88  * Clear
89  */
90  void clear();
91 
92  /**
93  * Clear and setup visual code add node context menu
94  */
96 
97  /**
98  * Add menu item
99  * @param text text
100  * @param id id
101  * @param action action
102  */
103  void addMenuItem(const string& text, const string& id, Action* action = nullptr);
104 
105  /**
106  * Add menu separator
107  */
109 
110  // overridden methods
112  void initialize() override;
113  void dispose() override;
114  void onAction(GUIActionListenerType type, GUIElementNode* node) override;
115  void onChange(GUIElementNode* node) override;
116  void onFocus(GUIElementNode* node) override;
117  void onUnfocus(GUIElementNode* node) override;
118  void onTooltipShowRequest(GUINode* node, int mouseX, int mouseY) override;
119  void onTooltipCloseRequest() override;
120  void handleInputEvents() override;
121 
122  /**
123  * Shows the pop up
124  * @param mouseX mouse X
125  * @param mouseY mouse Y
126  */
127  void show(int mouseX, int mouseY);
128 
129  /**
130  * Closes the pop up
131  */
132  void close();
133 
134 };
GUI node base class.
Definition: GUINode.h:64
GUI screen node that represents a screen that can be rendered via GUI system.
Definition: GUIScreenNode.h:72
void setMiniScriptMethodSelectionListener(MiniScriptMethodSelectionListener *miniScriptMethodSelectionListener)
Set MiniScript method selection listener.
void show(int mouseX, int mouseY)
Shows the pop up.
void setupVisualCodeAddNodeContextMenu()
Clear and setup visual code add node context menu.
void onChange(GUIElementNode *node) override
On change.
void handleInputEvents() override
Handle input events that have not yet been processed.
void onUnfocus(GUIElementNode *node) override
On unfocus.
void onTooltipCloseRequest() override
On tooltip close request.
void onFocus(GUIElementNode *node) override
On focus.
void onAction(GUIActionListenerType type, GUIElementNode *node) override
void addMenuItem(const string &text, const string &id, Action *action=nullptr)
Add menu item.
void onTooltipShowRequest(GUINode *node, int mouseX, int mouseY) override
On tooltip show request.
Pop ups controller accessor class.
Definition: PopUps.h:29
Properties class, which helps out with storeing or loading key value pairs from/to property files.
Definition: Properties.h:23
GUI action listener interface.
GUI change listener interface.
GUI focus listener interface.
GUI input event handler interface.
Screen controller, which connects GUI screen definition with code.
Action Interface.
Definition: Action.h:11
#define FORBID_CLASS_COPY(CLASS)
Definition: tdme.h:6