forked from panda3d/panda3d
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuttonEvent.I
More file actions
151 lines (138 loc) · 2.91 KB
/
buttonEvent.I
File metadata and controls
151 lines (138 loc) · 2.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
/**
* PANDA 3D SOFTWARE
* Copyright (c) Carnegie Mellon University. All rights reserved.
*
* All use of this software is subject to the terms of the revised BSD
* license. You should have received a copy of this license along
* with this source code in a file named "LICENSE."
*
* @file buttonEvent.I
* @author drose
* @date 2000-03-01
*/
/**
*
*/
INLINE ButtonEvent::
ButtonEvent() :
_button(ButtonHandle::none()),
_keycode(0),
_type(T_down),
_time(0.0)
{
}
/**
*
*/
INLINE ButtonEvent::
ButtonEvent(ButtonHandle button, ButtonEvent::Type type, double time) :
_button(button),
_keycode(0),
_highlight_start(0),
_highlight_end(0),
_type(type),
_time(time)
{
}
/**
*
*/
INLINE ButtonEvent::
ButtonEvent(int keycode, double time) :
_button(ButtonHandle::none()),
_keycode(keycode),
_highlight_start(0),
_highlight_end(0),
_type(T_keystroke),
_time(time)
{
}
/**
*
*/
INLINE ButtonEvent::
ButtonEvent(const std::wstring &candidate_string, size_t highlight_start,
size_t highlight_end, size_t cursor_pos) :
_button(ButtonHandle::none()),
_keycode(0),
_candidate_string(candidate_string),
_highlight_start(highlight_start),
_highlight_end(highlight_end),
_cursor_pos(cursor_pos),
_type(T_candidate),
_time(ClockObject::get_global_clock()->get_frame_time())
{
}
/**
*
*/
INLINE ButtonEvent::
ButtonEvent(const ButtonEvent ©) :
_button(copy._button),
_keycode(copy._keycode),
_candidate_string(copy._candidate_string),
_highlight_start(copy._highlight_start),
_highlight_end(copy._highlight_end),
_cursor_pos(copy._cursor_pos),
_type(copy._type),
_time(copy._time)
{
}
/**
*
*/
INLINE void ButtonEvent::
operator = (const ButtonEvent ©) {
_button = copy._button;
_keycode = copy._keycode;
_candidate_string = copy._candidate_string;
_highlight_start = copy._highlight_start;
_highlight_end = copy._highlight_end;
_cursor_pos = copy._cursor_pos;
_type = copy._type;
_time = copy._time;
}
/**
* The equality operator does not consider time significant.
*/
INLINE bool ButtonEvent::
operator == (const ButtonEvent &other) const {
return (_button == other._button &&
_keycode == other._keycode &&
_type == other._type);
}
/**
*
*/
INLINE bool ButtonEvent::
operator != (const ButtonEvent &other) const {
return !operator == (other);
}
/**
*
*/
INLINE bool ButtonEvent::
operator < (const ButtonEvent &other) const {
if (_button != other._button) {
return _button < other._button;
}
if (_keycode != other._keycode) {
return _keycode < other._keycode;
}
return _type < other._type;
}
/**
* Calls button_down() or button_up(), as appropriate, according to the
* ButtonEvent.
*/
INLINE bool ButtonEvent::
update_mods(ModifierButtons &mods) const {
switch (_type) {
case T_down:
return mods.button_down(_button);
case T_up:
return mods.button_up(_button);
default:
return false;
}
}