TDME2  1.9.200
GUIInputInternalController.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <array>
4 
5 #include <tdme/tdme.h>
10 
11 using std::array;
12 
16 using tdme::gui::nodes::GUIInputInternalController_CursorMode;
20 
21 /**
22  * GUI input internal controller
23  * @author Andreas Drewke
24  */
26  : public GUINodeController
27 {
28  friend class GUIInputInternalNode;
30 
31 public:
33 
34 private:
35  static constexpr int64_t TIME_DOUBLECLICK { 250LL };
36  static constexpr int64_t CURSOR_MODE_DURATION { 500LL };
37  static constexpr int64_t DRAGGING_CALMDOWN { 50LL };
38  GUIElementNode* inputNode { nullptr };
39  int64_t cursorModeStarted { -1LL };
41  int index { 0 };
42  int selectionIndex { -1 };
43  int offset { 0 };
44  bool mouseDraggingInit { false };
47  array<int, 2> mouseDragPosition {{ -1, -1 }};
48  array<int, 2> mouseOriginalPosition {{ -1, -1 }};
50 
53  bool haveMin { false };
54  bool haveMax { false };
55  bool haveStep { false };
56  float min { 0.0f };
57  float max { 0.0f };
58  float step { 0.0f };
59  int decimals { 3 };
60 
61  bool editMode { false };
62 
63  int64_t timeLastClick { -1LL };
64  bool doubleClick { false };
65 
66  // forbid class copy
68 
69  /**
70  * Private constructor
71  * @param node node
72  */
74 
75  /**
76  * @return index
77  */
78  inline int getIndex() {
79  return index;
80  }
81 
82  /**
83  * @return selection index
84  */
85  inline int getSelectionIndex() {
86  return selectionIndex;
87  }
88 
89  /**
90  * @return offset
91  */
92  inline int getOffset() {
93  return offset;
94  }
95 
96  /**
97  * Reset cursor mode
98  */
99  void resetCursorMode();
100 
101  /**
102  * @return cursor mode
103  */
105 
106  /**
107  * Check and correct offset
108  */
109  void checkOffset();
110 
111 public:
112  /**
113  * Reset cursor index and offset
114  */
115  void onTextUpdate();
116 
117  /**
118  * Format text according to options
119  */
120  void formatText();
121 
122  /**
123  * @return show cursor
124  */
125  bool isShowCursor();
126 
127  // overridden methods
128  bool isDisabled() override;
129  void setDisabled(bool disabled) override;
130  void initialize() override;
131  void dispose() override;
132  void postLayout() override;
133  void handleMouseEvent(GUINode* node, GUIMouseEvent* event) override;
134  void handleKeyboardEvent(GUIKeyboardEvent* event) override;
135  void tick() override;
136  void onFocusGained() override;
137  void onFocusLost() override;
138  bool hasValue() override;
139  const MutableString& getValue() override;
140  void setValue(const MutableString& value) override;
141  void onSubTreeChange() override;
142 
143 };
void formatText()
Format text according to options.
GUIInputInternalController(GUINode *node)
Private constructor.
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 node controller base class.
GUI node base class.
Definition: GUINode.h:64
Mutable utf8 aware string class.
Definition: MutableString.h:23
#define FORBID_CLASS_COPY(CLASS)
Definition: tdme.h:6