TDME2
1.9.121
src
tdme
gui
nodes
GUIInputInternalController.h
Go to the documentation of this file.
1
#pragma once
2
3
#include <array>
4
5
#include <
tdme/tdme.h
>
6
#include <
tdme/gui/events/fwd-tdme.h
>
7
#include <
tdme/gui/nodes/fwd-tdme.h
>
8
#include <
tdme/gui/nodes/GUINodeController.h
>
9
#include <
tdme/utilities/MutableString.h
>
10
11
using
std::array;
12
13
using
tdme::gui::events::GUIKeyboardEvent
;
14
using
tdme::gui::events::GUIMouseEvent
;
15
using
tdme::gui::nodes::GUIElementNode
;
16
using
tdme::gui::nodes::GUIInputInternalController_CursorMode;
17
using
tdme::gui::nodes::GUINode
;
18
using
tdme::gui::nodes::GUINodeController
;
19
using
tdme::utilities::MutableString
;
20
21
/**
22
* GUI input internal controller
23
* @author Andreas Drewke
24
* @version $Id$
25
*/
26
class
tdme::gui::nodes::GUIInputInternalController
final
27
:
public
GUINodeController
28
{
29
friend
class
GUIInputInternalNode
;
30
friend
class
GUIInputInternalController_CursorMode
;
31
public
:
32
enum
CursorMode
{
CURSORMODE_HIDE
,
CURSORMODE_SHOW
};
33
private
:
34
static
constexpr
int64_t
CURSOR_MODE_DURATION
{ 500LL };
35
static
constexpr
int64_t
DRAGGING_CALMDOWN
{ 50LL };
36
GUIElementNode
*
inputNode
{
nullptr
};
37
int64_t
cursorModeStarted
{ -1LL };
38
CursorMode
cursorMode
{
CURSORMODE_SHOW
};
39
int
index
{ 0 };
40
int
selectionIndex
{ -1 };
41
int
offset
{ 0 };
42
bool
mouseDraggingInit
{
false
};
43
bool
mouseDraggingSlideValueActive
{
false
};
44
bool
mouseDraggingSelectionActive
{
false
};
45
array<int, 2>
mouseDragPosition
;
46
array<int, 2>
mouseOriginalPosition
;
47
MutableString
value
;
48
49
enum
Type
{
TYPE_STRING
,
TYPE_FLOAT
,
TYPE_INT
};
50
Type
type
{
TYPE_STRING
};
51
bool
haveMin
{
false
};
52
bool
haveMax
{
false
};
53
bool
haveStep
{
false
};
54
float
min
{ 0.0f };
55
float
max
{ 0.0f };
56
float
step
{ 0.0f };
57
int
decimals
{ 3 };
58
59
bool
editMode
{
false
};
60
61
/**
62
* Private constructor
63
* @param node node
64
*/
65
GUIInputInternalController
(
GUINode
*
node
);
66
67
/**
68
* @return index
69
*/
70
inline
int
getIndex
() {
71
return
index
;
72
}
73
74
/**
75
* @return selection index
76
*/
77
inline
int
getSelectionIndex
() {
78
return
selectionIndex
;
79
}
80
81
/**
82
* @return offset
83
*/
84
inline
int
getOffset
() {
85
return
offset
;
86
}
87
88
/**
89
* Reset cursor mode
90
*/
91
void
resetCursorMode
();
92
93
/**
94
* @return cursor mode
95
*/
96
CursorMode
getCursorMode
();
97
98
/**
99
* Check and correct offset
100
*/
101
void
checkOffset
();
102
103
public
:
104
/**
105
* Reset cursor index and offset
106
*/
107
void
onTextUpdate
();
108
109
/**
110
* Format text according to options
111
*/
112
void
formatText
();
113
114
/**
115
* @return show cursor
116
*/
117
bool
isShowCursor
();
118
119
// overridden methods
120
bool
isDisabled
()
override
;
121
void
setDisabled
(
bool
disabled)
override
;
122
void
initialize
()
override
;
123
void
dispose
()
override
;
124
void
postLayout
()
override
;
125
void
handleMouseEvent
(
GUINode
*
node
,
GUIMouseEvent
* event)
override
;
126
void
handleKeyboardEvent
(
GUIKeyboardEvent
* event)
override
;
127
void
tick
()
override
;
128
void
onFocusGained
()
override
;
129
void
onFocusLost
()
override
;
130
bool
hasValue
()
override
;
131
const
MutableString
&
getValue
()
override
;
132
void
setValue
(
const
MutableString
&
value
)
override
;
133
void
onSubTreeChange
()
override
;
134
135
};
GUINodeController.h
MutableString.h
tdme::gui::events::GUIKeyboardEvent
GUI keyboard event.
Definition:
GUIKeyboardEvent.h:13
tdme::gui::events::GUIMouseEvent
GUI mouse event.
Definition:
GUIMouseEvent.h:13
tdme::gui::nodes::GUIElementNode
GUI element node.
Definition:
GUIElementNode.h:38
tdme::gui::nodes::GUIInputInternalController
GUI input internal controller.
Definition:
GUIInputInternalController.h:28
tdme::gui::nodes::GUIInputInternalController::CURSOR_MODE_DURATION
static constexpr int64_t CURSOR_MODE_DURATION
Definition:
GUIInputInternalController.h:34
tdme::gui::nodes::GUIInputInternalController::getSelectionIndex
int getSelectionIndex()
Definition:
GUIInputInternalController.h:77
tdme::gui::nodes::GUIInputInternalController::onFocusGained
void onFocusGained() override
On focus gained.
Definition:
GUIInputInternalController.cpp:531
tdme::gui::nodes::GUIInputInternalController::dispose
void dispose() override
Dispose controller.
Definition:
GUIInputInternalController.cpp:107
tdme::gui::nodes::GUIInputInternalController::GUIInputInternalController_CursorMode
friend class GUIInputInternalController_CursorMode
Definition:
GUIInputInternalController.h:30
tdme::gui::nodes::GUIInputInternalController::formatText
void formatText()
Format text according to options.
Definition:
GUIInputInternalController.cpp:575
tdme::gui::nodes::GUIInputInternalController::Type
Type
Definition:
GUIInputInternalController.h:49
tdme::gui::nodes::GUIInputInternalController::TYPE_FLOAT
@ TYPE_FLOAT
Definition:
GUIInputInternalController.h:49
tdme::gui::nodes::GUIInputInternalController::TYPE_INT
@ TYPE_INT
Definition:
GUIInputInternalController.h:49
tdme::gui::nodes::GUIInputInternalController::TYPE_STRING
@ TYPE_STRING
Definition:
GUIInputInternalController.h:49
tdme::gui::nodes::GUIInputInternalController::GUIInputInternalController
GUIInputInternalController(GUINode *node)
Private constructor.
Definition:
GUIInputInternalController.cpp:57
tdme::gui::nodes::GUIInputInternalController::postLayout
void postLayout() override
Post layout event.
Definition:
GUIInputInternalController.cpp:111
tdme::gui::nodes::GUIInputInternalController::selectionIndex
int selectionIndex
Definition:
GUIInputInternalController.h:40
tdme::gui::nodes::GUIInputInternalController::max
float max
Definition:
GUIInputInternalController.h:55
tdme::gui::nodes::GUIInputInternalController::mouseOriginalPosition
array< int, 2 > mouseOriginalPosition
Definition:
GUIInputInternalController.h:46
tdme::gui::nodes::GUIInputInternalController::resetCursorMode
void resetCursorMode()
Reset cursor mode.
Definition:
GUIInputInternalController.cpp:115
tdme::gui::nodes::GUIInputInternalController::initialize
void initialize() override
Initialize controller after element has been created.
Definition:
GUIInputInternalController.cpp:79
tdme::gui::nodes::GUIInputInternalController::mouseDraggingSlideValueActive
bool mouseDraggingSlideValueActive
Definition:
GUIInputInternalController.h:43
tdme::gui::nodes::GUIInputInternalController::editMode
bool editMode
Definition:
GUIInputInternalController.h:59
tdme::gui::nodes::GUIInputInternalController::CursorMode
CursorMode
Definition:
GUIInputInternalController.h:32
tdme::gui::nodes::GUIInputInternalController::CURSORMODE_SHOW
@ CURSORMODE_SHOW
Definition:
GUIInputInternalController.h:32
tdme::gui::nodes::GUIInputInternalController::CURSORMODE_HIDE
@ CURSORMODE_HIDE
Definition:
GUIInputInternalController.h:32
tdme::gui::nodes::GUIInputInternalController::haveStep
bool haveStep
Definition:
GUIInputInternalController.h:53
tdme::gui::nodes::GUIInputInternalController::haveMin
bool haveMin
Definition:
GUIInputInternalController.h:51
tdme::gui::nodes::GUIInputInternalController::handleKeyboardEvent
void handleKeyboardEvent(GUIKeyboardEvent *event) override
Handle keyboard event.
Definition:
GUIInputInternalController.cpp:304
tdme::gui::nodes::GUIInputInternalController::mouseDragPosition
array< int, 2 > mouseDragPosition
Definition:
GUIInputInternalController.h:45
tdme::gui::nodes::GUIInputInternalController::haveMax
bool haveMax
Definition:
GUIInputInternalController.h:52
tdme::gui::nodes::GUIInputInternalController::getOffset
int getOffset()
Definition:
GUIInputInternalController.h:84
tdme::gui::nodes::GUIInputInternalController::getIndex
int getIndex()
Definition:
GUIInputInternalController.h:70
tdme::gui::nodes::GUIInputInternalController::onFocusLost
void onFocusLost() override
On focus lost.
Definition:
GUIInputInternalController.cpp:535
tdme::gui::nodes::GUIInputInternalController::setValue
void setValue(const MutableString &value) override
Set value.
Definition:
GUIInputInternalController.cpp:553
tdme::gui::nodes::GUIInputInternalController::handleMouseEvent
void handleMouseEvent(GUINode *node, GUIMouseEvent *event) override
Handle mouse event.
Definition:
GUIInputInternalController.cpp:137
tdme::gui::nodes::GUIInputInternalController::onTextUpdate
void onTextUpdate()
Reset cursor index and offset.
Definition:
GUIInputInternalController.cpp:557
tdme::gui::nodes::GUIInputInternalController::index
int index
Definition:
GUIInputInternalController.h:39
tdme::gui::nodes::GUIInputInternalController::cursorMode
CursorMode cursorMode
Definition:
GUIInputInternalController.h:38
tdme::gui::nodes::GUIInputInternalController::isShowCursor
bool isShowCursor()
Definition:
GUIInputInternalController.cpp:570
tdme::gui::nodes::GUIInputInternalController::tick
void tick() override
Tick method will be executed once per frame.
Definition:
GUIInputInternalController.cpp:527
tdme::gui::nodes::GUIInputInternalController::step
float step
Definition:
GUIInputInternalController.h:56
tdme::gui::nodes::GUIInputInternalController::DRAGGING_CALMDOWN
static constexpr int64_t DRAGGING_CALMDOWN
Definition:
GUIInputInternalController.h:35
tdme::gui::nodes::GUIInputInternalController::setDisabled
void setDisabled(bool disabled) override
Set disabled.
Definition:
GUIInputInternalController.cpp:75
tdme::gui::nodes::GUIInputInternalController::value
MutableString value
Definition:
GUIInputInternalController.h:47
tdme::gui::nodes::GUIInputInternalController::inputNode
GUIElementNode * inputNode
Definition:
GUIInputInternalController.h:36
tdme::gui::nodes::GUIInputInternalController::getValue
const MutableString & getValue() override
Definition:
GUIInputInternalController.cpp:548
tdme::gui::nodes::GUIInputInternalController::type
Type type
Definition:
GUIInputInternalController.h:50
tdme::gui::nodes::GUIInputInternalController::cursorModeStarted
int64_t cursorModeStarted
Definition:
GUIInputInternalController.h:37
tdme::gui::nodes::GUIInputInternalController::isDisabled
bool isDisabled() override
Definition:
GUIInputInternalController.cpp:70
tdme::gui::nodes::GUIInputInternalController::onSubTreeChange
void onSubTreeChange() override
On sub tree change.
Definition:
GUIInputInternalController.cpp:624
tdme::gui::nodes::GUIInputInternalController::getCursorMode
CursorMode getCursorMode()
Definition:
GUIInputInternalController.cpp:121
tdme::gui::nodes::GUIInputInternalController::hasValue
bool hasValue() override
Definition:
GUIInputInternalController.cpp:543
tdme::gui::nodes::GUIInputInternalController::checkOffset
void checkOffset()
Check and correct offset.
Definition:
GUIInputInternalController.cpp:287
tdme::gui::nodes::GUIInputInternalController::mouseDraggingInit
bool mouseDraggingInit
Definition:
GUIInputInternalController.h:42
tdme::gui::nodes::GUIInputInternalController::min
float min
Definition:
GUIInputInternalController.h:54
tdme::gui::nodes::GUIInputInternalController::decimals
int decimals
Definition:
GUIInputInternalController.h:57
tdme::gui::nodes::GUIInputInternalController::mouseDraggingSelectionActive
bool mouseDraggingSelectionActive
Definition:
GUIInputInternalController.h:44
tdme::gui::nodes::GUIInputInternalController::offset
int offset
Definition:
GUIInputInternalController.h:41
tdme::gui::nodes::GUIInputInternalNode
GUI input internal node.
Definition:
GUIInputInternalNode.h:40
tdme::gui::nodes::GUINodeController
GUI node controller base class.
Definition:
GUINodeController.h:19
tdme::gui::nodes::GUINodeController::node
GUINode * node
Definition:
GUINodeController.h:21
tdme::gui::nodes::GUINode
GUI node base class.
Definition:
GUINode.h:63
tdme::utilities::MutableString
Mutable string class.
Definition:
MutableString.h:16
fwd-tdme.h
fwd-tdme.h
tdme.h
Generated by
1.9.3