reflexion 0.1.19 → 0.1.23
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.doc/ext/reflex/contact_event.cpp +6 -6
- data/.doc/ext/reflex/event.cpp +9 -1
- data/.doc/ext/reflex/focus_event.cpp +6 -6
- data/.doc/ext/reflex/key_event.cpp +211 -13
- data/.doc/ext/reflex/native.cpp +2 -0
- data/.doc/ext/reflex/pointer.cpp +158 -0
- data/.doc/ext/reflex/pointer_event.cpp +31 -90
- data/.doc/ext/reflex/selector.cpp +8 -0
- data/.doc/ext/reflex/view.cpp +57 -0
- data/.doc/ext/reflex/window.cpp +41 -0
- data/VERSION +1 -1
- data/ext/reflex/contact_event.cpp +6 -6
- data/ext/reflex/event.cpp +11 -2
- data/ext/reflex/focus_event.cpp +6 -6
- data/ext/reflex/key_event.cpp +212 -13
- data/ext/reflex/native.cpp +2 -0
- data/ext/reflex/pointer.cpp +170 -0
- data/ext/reflex/pointer_event.cpp +30 -95
- data/ext/reflex/selector.cpp +9 -0
- data/ext/reflex/view.cpp +67 -3
- data/ext/reflex/window.cpp +49 -3
- data/include/reflex/defs.h +140 -106
- data/include/reflex/event.h +26 -27
- data/include/reflex/pointer.h +107 -0
- data/include/reflex/ruby/pointer.h +41 -0
- data/include/reflex/ruby/view.h +9 -0
- data/include/reflex/ruby/window.h +9 -0
- data/include/reflex/selector.h +1 -1
- data/include/reflex/view.h +6 -4
- data/include/reflex/window.h +14 -8
- data/lib/reflex/application.rb +3 -3
- data/lib/reflex/autoinit.rb +1 -1
- data/lib/reflex/button.rb +7 -7
- data/lib/reflex/capture_event.rb +7 -7
- data/lib/reflex/contact_event.rb +4 -4
- data/lib/reflex/draw_event.rb +2 -2
- data/lib/reflex/ellipse_shape.rb +2 -2
- data/lib/reflex/focus_event.rb +4 -4
- data/lib/reflex/frame_event.rb +5 -5
- data/lib/reflex/helper.rb +20 -20
- data/lib/reflex/image_view.rb +2 -2
- data/lib/reflex/key_event.rb +6 -6
- data/lib/reflex/model.rb +22 -22
- data/lib/reflex/model_owner.rb +7 -7
- data/lib/reflex/model_view.rb +1 -1
- data/lib/reflex/module.rb +5 -5
- data/lib/reflex/pointer.rb +107 -0
- data/lib/reflex/pointer_event.rb +16 -54
- data/lib/reflex/polygon_shape.rb +2 -2
- data/lib/reflex/reflex.rb +3 -3
- data/lib/reflex/scroll_event.rb +1 -1
- data/lib/reflex/selector.rb +4 -4
- data/lib/reflex/shape.rb +13 -13
- data/lib/reflex/style.rb +11 -11
- data/lib/reflex/style_length.rb +1 -1
- data/lib/reflex/text_view.rb +2 -2
- data/lib/reflex/timer.rb +2 -2
- data/lib/reflex/timer_event.rb +1 -1
- data/lib/reflex/update_event.rb +1 -1
- data/lib/reflex/view.rb +32 -32
- data/lib/reflex/wheel_event.rb +3 -3
- data/lib/reflex/window.rb +7 -6
- data/lib/reflex.rb +1 -0
- data/lib/reflexion.rb +17 -17
- data/reflex.gemspec +5 -5
- data/samples/reflexion/noise.rb +1 -1
- data/samples/tree.rb +1 -1
- data/src/event.cpp +189 -37
- data/src/event.h +32 -0
- data/src/ios/event.h +15 -3
- data/src/ios/event.mm +126 -11
- data/src/ios/view_controller.mm +50 -22
- data/src/ios/window.mm +18 -0
- data/src/osx/event.h +14 -3
- data/src/osx/event.mm +213 -23
- data/src/osx/native_window.mm +84 -17
- data/src/osx/window.mm +22 -0
- data/src/pointer.cpp +203 -0
- data/src/pointer.h +26 -0
- data/src/selector.cpp +1 -1
- data/src/view.cpp +103 -64
- data/src/view.h +0 -4
- data/src/window.cpp +334 -98
- data/src/window.h +28 -3
- data/test/helper.rb +3 -3
- data/test/test_application.rb +1 -1
- data/test/test_capture_event.rb +6 -6
- data/test/test_event.rb +18 -4
- data/test/test_has_frame.rb +11 -11
- data/test/test_pointer.rb +149 -0
- data/test/test_pointer_event.rb +70 -104
- data/test/test_reflex.rb +1 -1
- data/test/test_selector.rb +15 -8
- data/test/test_shape.rb +8 -8
- data/test/test_style.rb +13 -13
- data/test/test_style_length.rb +5 -5
- data/test/test_view.rb +57 -30
- data/test/test_window.rb +45 -26
- metadata +46 -35
data/ext/reflex/key_event.cpp
CHANGED
@@ -43,7 +43,7 @@ RUCY_DEF1(initialize_copy, obj)
|
|
43
43
|
RUCY_END
|
44
44
|
|
45
45
|
static
|
46
|
-
RUCY_DEF0(
|
46
|
+
RUCY_DEF0(get_type)
|
47
47
|
{
|
48
48
|
CHECK;
|
49
49
|
return value(THIS->type);
|
@@ -51,7 +51,205 @@ RUCY_DEF0(type)
|
|
51
51
|
RUCY_END
|
52
52
|
|
53
53
|
static
|
54
|
-
RUCY_DEF0(
|
54
|
+
RUCY_DEF0(get_key)
|
55
|
+
{
|
56
|
+
CHECK;
|
57
|
+
switch (THIS->code)
|
58
|
+
{
|
59
|
+
#define CASE(key) case Reflex::KEY_##key
|
60
|
+
#define SYMBOL1(name) SYMBOL2(_##name, #name)
|
61
|
+
#define SYMBOL2(var, sym) {RUCY_SYMBOL(var, sym); return var.value();}
|
62
|
+
|
63
|
+
CASE(A): SYMBOL1(a);
|
64
|
+
CASE(B): SYMBOL1(b);
|
65
|
+
CASE(C): SYMBOL1(c);
|
66
|
+
CASE(D): SYMBOL1(d);
|
67
|
+
CASE(E): SYMBOL1(e);
|
68
|
+
CASE(F): SYMBOL1(f);
|
69
|
+
CASE(G): SYMBOL1(g);
|
70
|
+
CASE(H): SYMBOL1(h);
|
71
|
+
CASE(I): SYMBOL1(i);
|
72
|
+
CASE(J): SYMBOL1(j);
|
73
|
+
CASE(K): SYMBOL1(k);
|
74
|
+
CASE(L): SYMBOL1(l);
|
75
|
+
CASE(M): SYMBOL1(m);
|
76
|
+
CASE(N): SYMBOL1(n);
|
77
|
+
CASE(O): SYMBOL1(o);
|
78
|
+
CASE(P): SYMBOL1(p);
|
79
|
+
CASE(Q): SYMBOL1(q);
|
80
|
+
CASE(R): SYMBOL1(r);
|
81
|
+
CASE(S): SYMBOL1(s);
|
82
|
+
CASE(T): SYMBOL1(t);
|
83
|
+
CASE(U): SYMBOL1(u);
|
84
|
+
CASE(V): SYMBOL1(v);
|
85
|
+
CASE(W): SYMBOL1(w);
|
86
|
+
CASE(X): SYMBOL1(x);
|
87
|
+
CASE(Y): SYMBOL1(y);
|
88
|
+
CASE(Z): SYMBOL1(z);
|
89
|
+
|
90
|
+
CASE(0):
|
91
|
+
CASE(NUM_0): SYMBOL1(0);
|
92
|
+
CASE(1):
|
93
|
+
CASE(NUM_1): SYMBOL1(1);
|
94
|
+
CASE(2):
|
95
|
+
CASE(NUM_2): SYMBOL1(2);
|
96
|
+
CASE(3):
|
97
|
+
CASE(NUM_3): SYMBOL1(3);
|
98
|
+
CASE(4):
|
99
|
+
CASE(NUM_4): SYMBOL1(4);
|
100
|
+
CASE(5):
|
101
|
+
CASE(NUM_5): SYMBOL1(5);
|
102
|
+
CASE(6):
|
103
|
+
CASE(NUM_6): SYMBOL1(6);
|
104
|
+
CASE(7):
|
105
|
+
CASE(NUM_7): SYMBOL1(7);
|
106
|
+
CASE(8):
|
107
|
+
CASE(NUM_8): SYMBOL1(8);
|
108
|
+
CASE(9):
|
109
|
+
CASE(NUM_9): SYMBOL1(9);
|
110
|
+
|
111
|
+
CASE(MINUS): SYMBOL1(minus);
|
112
|
+
CASE(EQUAL): SYMBOL1(equal);
|
113
|
+
CASE(COMMA): SYMBOL1(comma);
|
114
|
+
CASE(PERIOD): SYMBOL1(period);
|
115
|
+
CASE(SEMICOLON): SYMBOL1(semicolon);
|
116
|
+
CASE(QUOTE): SYMBOL1(quote);
|
117
|
+
CASE(SLASH): SYMBOL1(slash);
|
118
|
+
CASE(BACKSLASH): SYMBOL1(backslash);
|
119
|
+
CASE(UNDERSCORE): SYMBOL1(underscore);
|
120
|
+
CASE(GRAVE): SYMBOL1(grave);
|
121
|
+
CASE(YEN): SYMBOL1(yen);
|
122
|
+
CASE(LBRACKET): SYMBOL1(lbracket);
|
123
|
+
CASE(RBRACKET): SYMBOL1(rbracket);
|
124
|
+
|
125
|
+
CASE(ENTER):
|
126
|
+
CASE(RETURN): SYMBOL1(enter);
|
127
|
+
CASE(SPACE): SYMBOL1(space);
|
128
|
+
CASE(TAB): SYMBOL1(tab);
|
129
|
+
CASE(DELETE): SYMBOL2(_delete, "delete");
|
130
|
+
CASE(BACKSPACE): SYMBOL1(backspace);
|
131
|
+
//CASE(INSERT): SYMBOL1(insert);
|
132
|
+
CASE(ESCAPE): SYMBOL1(escape);
|
133
|
+
|
134
|
+
CASE(LEFT): SYMBOL1(left);
|
135
|
+
CASE(RIGHT): SYMBOL1(right);
|
136
|
+
CASE(UP): SYMBOL1(up);
|
137
|
+
CASE(DOWN): SYMBOL1(down);
|
138
|
+
CASE(HOME): SYMBOL1(home);
|
139
|
+
CASE(END): SYMBOL1(end);
|
140
|
+
CASE(PAGEUP): SYMBOL1(pageup);
|
141
|
+
CASE(PAGEDOWN): SYMBOL1(pagedown);
|
142
|
+
|
143
|
+
CASE(LSHIFT):
|
144
|
+
CASE(RSHIFT): SYMBOL1(shift);
|
145
|
+
CASE(LCONTROL):
|
146
|
+
CASE(RCONTROL): SYMBOL1(control);
|
147
|
+
//CASE(LALT):
|
148
|
+
//CASE(RALT): SYMBOL1(alt);
|
149
|
+
//CASE(LWIN):
|
150
|
+
//CASE(RWIN): SYMBOL1(win);
|
151
|
+
CASE(LCOMMAND):
|
152
|
+
CASE(RCOMMAND): SYMBOL1(command);
|
153
|
+
CASE(LOPTION):
|
154
|
+
CASE(ROPTION): SYMBOL1(option);
|
155
|
+
CASE(FUNCTION): SYMBOL1(function);
|
156
|
+
|
157
|
+
CASE(F1): SYMBOL1(f1);
|
158
|
+
CASE(F2): SYMBOL1(f2);
|
159
|
+
CASE(F3): SYMBOL1(f3);
|
160
|
+
CASE(F4): SYMBOL1(f4);
|
161
|
+
CASE(F5): SYMBOL1(f5);
|
162
|
+
CASE(F6): SYMBOL1(f6);
|
163
|
+
CASE(F7): SYMBOL1(f7);
|
164
|
+
CASE(F8): SYMBOL1(f8);
|
165
|
+
CASE(F9): SYMBOL1(f9);
|
166
|
+
CASE(F10): SYMBOL1(f10);
|
167
|
+
CASE(F11): SYMBOL1(f11);
|
168
|
+
CASE(F12): SYMBOL1(f12);
|
169
|
+
CASE(F13): SYMBOL1(f13);
|
170
|
+
CASE(F14): SYMBOL1(f14);
|
171
|
+
CASE(F15): SYMBOL1(f15);
|
172
|
+
CASE(F16): SYMBOL1(f16);
|
173
|
+
CASE(F17): SYMBOL1(f17);
|
174
|
+
CASE(F18): SYMBOL1(f18);
|
175
|
+
CASE(F19): SYMBOL1(f19);
|
176
|
+
CASE(F20): SYMBOL1(f20);
|
177
|
+
//CASE(F21): SYMBOL1(f21);
|
178
|
+
//CASE(F22): SYMBOL1(f22);
|
179
|
+
//CASE(F23): SYMBOL1(f23);
|
180
|
+
//CASE(F24): SYMBOL1(f24);
|
181
|
+
|
182
|
+
CASE(NUM_PLUS): SYMBOL1(plus);
|
183
|
+
CASE(NUM_MINUS): SYMBOL1(minus);
|
184
|
+
CASE(NUM_MULTIPLY): SYMBOL1(multiply);
|
185
|
+
CASE(NUM_DIVIDE): SYMBOL1(divide);
|
186
|
+
CASE(NUM_EQUAL): SYMBOL1(equal);
|
187
|
+
CASE(NUM_COMMA): SYMBOL1(comma);
|
188
|
+
CASE(NUM_DECIMAL): SYMBOL1(decimal);
|
189
|
+
CASE(NUM_CLEAR): SYMBOL1(clear);
|
190
|
+
|
191
|
+
CASE(CAPSLOCK): SYMBOL1(capslock);
|
192
|
+
//CASE(NUMLOCK): SYMBOL1(numlock);
|
193
|
+
//CASE(SCROLLLOCK): SYMBOL1(scrolllock);
|
194
|
+
|
195
|
+
//CASE(PRINTSCREEN): SYMBOL1(printscreen);
|
196
|
+
//CASE(PAUSE): SYMBOL1(pause);
|
197
|
+
//CASE(BREAK): SYMBOL2(_break, "break");
|
198
|
+
CASE(SECTION): SYMBOL1(section);
|
199
|
+
CASE(HELP): SYMBOL1(help);
|
200
|
+
|
201
|
+
CASE(IME_EISU): SYMBOL1(eisu);
|
202
|
+
CASE(IME_KANA): SYMBOL1(kana);
|
203
|
+
//CASE(IME_KANJI): SYMBOL1(kanji);
|
204
|
+
//CASE(IME_JUNJA): SYMBOL1(junja);
|
205
|
+
//CASE(IME_PROCESS): SYMBOL1(process);
|
206
|
+
//CASE(IME_ACCEPT): SYMBOL1(accept);
|
207
|
+
//CASE(IME_FINAL): SYMBOL2(_final, "final");
|
208
|
+
//CASE(IME_CONVERT): SYMBOL1(convert);
|
209
|
+
//CASE(IME_NONCONVERT): SYMBOL1(nonconvert);
|
210
|
+
//CASE(IME_MODECHANGE): SYMBOL1(mode_change);
|
211
|
+
|
212
|
+
CASE(VOLUME_UP): SYMBOL1(volume_up);
|
213
|
+
CASE(VOLUME_DOWN): SYMBOL1(volume_down);
|
214
|
+
CASE(MUTE): SYMBOL1(mute);
|
215
|
+
|
216
|
+
//CASE(SLEEP): SYMBOL1(sleep);
|
217
|
+
//CASE(EXEC): SYMBOL1(exec);
|
218
|
+
//CASE(PRINT): SYMBOL1(print);
|
219
|
+
//CASE(APPS): SYMBOL1(apps);
|
220
|
+
//CASE(SELECT): SYMBOL1(select);
|
221
|
+
//CASE(CLEAR): SYMBOL1(clear);
|
222
|
+
//CASE(PLAY): SYMBOL1(play);
|
223
|
+
//CASE(ZOOM): SYMBOL1(zoom);
|
224
|
+
|
225
|
+
//CASE(BROWSER_BACK): SYMBOL1(browser_back);
|
226
|
+
//CASE(BROWSER_FORWARD): SYMBOL1(browser_forward);
|
227
|
+
//CASE(BROWSER_REFRESH): SYMBOL1(browser_refresh);
|
228
|
+
//CASE(BROWSER_STOP): SYMBOL1(browser_stop);
|
229
|
+
//CASE(BROWSER_SEARCH): SYMBOL1(browser_search);
|
230
|
+
//CASE(BROWSER_FAVORITES): SYMBOL1(browser_favorites);
|
231
|
+
//CASE(BROWSER_HOME): SYMBOL1(browser_home);
|
232
|
+
|
233
|
+
//CASE(MEDIA_NEXT_TRACK): SYMBOL1(media_next);
|
234
|
+
//CASE(MEDIA_PREV_TRACK): SYMBOL1(media_prev);
|
235
|
+
//CASE(MEDIA_STOP): SYMBOL1(media_stop);
|
236
|
+
//CASE(MEDIA_PLAY_PAUSE): SYMBOL1(media_play_stop);
|
237
|
+
|
238
|
+
//CASE(LAUNCH_MAIL): SYMBOL1(launch_mail);
|
239
|
+
//CASE(LAUNCH_MEDIA_SELECT): SYMBOL1(launch_media_select);
|
240
|
+
//CASE(LAUNCH_APP1): SYMBOL1(launch_app1);
|
241
|
+
//CASE(LAUNCH_APP2): SYMBOL1(launch_app2);
|
242
|
+
|
243
|
+
#undef CASE
|
244
|
+
#undef SYMBOL1
|
245
|
+
#undef SYMBOL2
|
246
|
+
}
|
247
|
+
return nil();
|
248
|
+
}
|
249
|
+
RUCY_END
|
250
|
+
|
251
|
+
static
|
252
|
+
RUCY_DEF0(get_chars)
|
55
253
|
{
|
56
254
|
CHECK;
|
57
255
|
return value(THIS->chars.c_str());
|
@@ -59,7 +257,7 @@ RUCY_DEF0(chars)
|
|
59
257
|
RUCY_END
|
60
258
|
|
61
259
|
static
|
62
|
-
RUCY_DEF0(
|
260
|
+
RUCY_DEF0(get_code)
|
63
261
|
{
|
64
262
|
CHECK;
|
65
263
|
return value(THIS->code);
|
@@ -67,7 +265,7 @@ RUCY_DEF0(code)
|
|
67
265
|
RUCY_END
|
68
266
|
|
69
267
|
static
|
70
|
-
RUCY_DEF0(
|
268
|
+
RUCY_DEF0(get_modifiers)
|
71
269
|
{
|
72
270
|
CHECK;
|
73
271
|
return value(THIS->modifiers);
|
@@ -75,7 +273,7 @@ RUCY_DEF0(modifiers)
|
|
75
273
|
RUCY_END
|
76
274
|
|
77
275
|
static
|
78
|
-
RUCY_DEF0(
|
276
|
+
RUCY_DEF0(get_repeat)
|
79
277
|
{
|
80
278
|
CHECK;
|
81
279
|
return value(THIS->repeat);
|
@@ -83,10 +281,10 @@ RUCY_DEF0(repeat)
|
|
83
281
|
RUCY_END
|
84
282
|
|
85
283
|
static
|
86
|
-
RUCY_DEF0(
|
284
|
+
RUCY_DEF0(is_captured)
|
87
285
|
{
|
88
286
|
CHECK;
|
89
|
-
return value(THIS->
|
287
|
+
return value(THIS->captured);
|
90
288
|
}
|
91
289
|
RUCY_END
|
92
290
|
|
@@ -102,12 +300,13 @@ Init_key_event ()
|
|
102
300
|
cKeyEvent.define_alloc_func(alloc);
|
103
301
|
cKeyEvent.define_private_method("initialize", initialize);
|
104
302
|
cKeyEvent.define_private_method("initialize_copy", initialize_copy);
|
105
|
-
cKeyEvent.define_method("type",
|
106
|
-
cKeyEvent.define_method("
|
107
|
-
cKeyEvent.define_method("
|
108
|
-
cKeyEvent.define_method("
|
109
|
-
cKeyEvent.define_method("
|
110
|
-
cKeyEvent.define_method("
|
303
|
+
cKeyEvent.define_method("type", get_type);
|
304
|
+
cKeyEvent.define_method("key", get_key);
|
305
|
+
cKeyEvent.define_method("chars", get_chars);
|
306
|
+
cKeyEvent.define_method("code", get_code);
|
307
|
+
cKeyEvent.define_method("modifiers", get_modifiers);
|
308
|
+
cKeyEvent.define_method("repeat", get_repeat);
|
309
|
+
cKeyEvent.define_method("captured?", is_captured);
|
111
310
|
cKeyEvent.define_const("TYPE_NONE", Reflex::KeyEvent::NONE);
|
112
311
|
cKeyEvent.define_const("TYPE_DOWN", Reflex::KeyEvent::DOWN);
|
113
312
|
cKeyEvent.define_const("TYPE_UP", Reflex::KeyEvent::UP);
|
data/ext/reflex/native.cpp
CHANGED
@@ -17,6 +17,7 @@ void Init_frame_event ();
|
|
17
17
|
void Init_scroll_event ();
|
18
18
|
void Init_focus_event ();
|
19
19
|
void Init_key_event ();
|
20
|
+
void Init_pointer ();
|
20
21
|
void Init_pointer_event ();
|
21
22
|
void Init_wheel_event ();
|
22
23
|
void Init_capture_event ();
|
@@ -63,6 +64,7 @@ extern "C" void
|
|
63
64
|
Init_scroll_event();
|
64
65
|
Init_focus_event();
|
65
66
|
Init_key_event();
|
67
|
+
Init_pointer();
|
66
68
|
Init_pointer_event();
|
67
69
|
Init_wheel_event();
|
68
70
|
Init_capture_event();
|
@@ -0,0 +1,170 @@
|
|
1
|
+
#include "reflex/ruby/pointer.h"
|
2
|
+
|
3
|
+
|
4
|
+
#include <rays/ruby/point.h>
|
5
|
+
#include "defs.h"
|
6
|
+
|
7
|
+
|
8
|
+
RUCY_DEFINE_VALUE_FROM_TO(Reflex::Pointer)
|
9
|
+
|
10
|
+
#define THIS to<Reflex::Pointer*>(self)
|
11
|
+
|
12
|
+
#define CHECK RUCY_CHECK_OBJ(Reflex::Pointer, self)
|
13
|
+
|
14
|
+
|
15
|
+
static
|
16
|
+
RUCY_DEF_ALLOC(alloc, klass)
|
17
|
+
{
|
18
|
+
return new_type<Reflex::Pointer>(klass);
|
19
|
+
}
|
20
|
+
RUCY_END
|
21
|
+
|
22
|
+
static
|
23
|
+
RUCY_DEF8(initialize,
|
24
|
+
id, type, action, position, modifiers, click_count, drag, time)
|
25
|
+
{
|
26
|
+
CHECK;
|
27
|
+
|
28
|
+
*THIS = Reflex::Pointer(
|
29
|
+
to<Reflex::Pointer::ID>(id),
|
30
|
+
to<uint>(type),
|
31
|
+
(Reflex::Pointer::Action) to<int>(action),
|
32
|
+
to<Rays::Point>(position),
|
33
|
+
to<uint>(modifiers),
|
34
|
+
to<uint>(click_count),
|
35
|
+
to<bool>(drag),
|
36
|
+
to<double>(time));
|
37
|
+
return self;
|
38
|
+
}
|
39
|
+
RUCY_END
|
40
|
+
|
41
|
+
static
|
42
|
+
RUCY_DEF1(initialize_copy, obj)
|
43
|
+
{
|
44
|
+
CHECK;
|
45
|
+
*THIS = to<Reflex::Pointer&>(obj);
|
46
|
+
return self;
|
47
|
+
}
|
48
|
+
RUCY_END
|
49
|
+
|
50
|
+
static
|
51
|
+
RUCY_DEF0(get_id)
|
52
|
+
{
|
53
|
+
CHECK;
|
54
|
+
return value(THIS->id());
|
55
|
+
}
|
56
|
+
RUCY_END
|
57
|
+
|
58
|
+
static
|
59
|
+
RUCY_DEF0(get_type)
|
60
|
+
{
|
61
|
+
CHECK;
|
62
|
+
return value(THIS->type());
|
63
|
+
}
|
64
|
+
RUCY_END
|
65
|
+
|
66
|
+
static
|
67
|
+
RUCY_DEF0(get_action)
|
68
|
+
{
|
69
|
+
CHECK;
|
70
|
+
return value(THIS->action());
|
71
|
+
}
|
72
|
+
RUCY_END
|
73
|
+
|
74
|
+
static
|
75
|
+
RUCY_DEF0(get_position)
|
76
|
+
{
|
77
|
+
CHECK;
|
78
|
+
return value(THIS->position());
|
79
|
+
}
|
80
|
+
RUCY_END
|
81
|
+
|
82
|
+
static
|
83
|
+
RUCY_DEF0(get_modifiers)
|
84
|
+
{
|
85
|
+
CHECK;
|
86
|
+
return value(THIS->modifiers());
|
87
|
+
}
|
88
|
+
RUCY_END
|
89
|
+
|
90
|
+
static
|
91
|
+
RUCY_DEF0(get_click_count)
|
92
|
+
{
|
93
|
+
CHECK;
|
94
|
+
return value(THIS->click_count());
|
95
|
+
}
|
96
|
+
RUCY_END
|
97
|
+
|
98
|
+
static
|
99
|
+
RUCY_DEF0(is_drag)
|
100
|
+
{
|
101
|
+
CHECK;
|
102
|
+
return value(THIS->is_drag());
|
103
|
+
}
|
104
|
+
RUCY_END
|
105
|
+
|
106
|
+
static
|
107
|
+
RUCY_DEF0(get_time)
|
108
|
+
{
|
109
|
+
CHECK;
|
110
|
+
return value(THIS->time());
|
111
|
+
}
|
112
|
+
RUCY_END
|
113
|
+
|
114
|
+
static
|
115
|
+
RUCY_DEF0(get_prev)
|
116
|
+
{
|
117
|
+
CHECK;
|
118
|
+
return value(THIS->prev());
|
119
|
+
}
|
120
|
+
RUCY_END
|
121
|
+
|
122
|
+
|
123
|
+
static Class cPointer;
|
124
|
+
|
125
|
+
void
|
126
|
+
Init_pointer ()
|
127
|
+
{
|
128
|
+
Module mReflex = define_module("Reflex");
|
129
|
+
|
130
|
+
cPointer = mReflex.define_class("Pointer");
|
131
|
+
cPointer.define_alloc_func(alloc);
|
132
|
+
cPointer.define_private_method("initialize", initialize);
|
133
|
+
cPointer.define_private_method("initialize_copy", initialize_copy);
|
134
|
+
cPointer.define_method("id", get_id);
|
135
|
+
cPointer.define_private_method("get_type", get_type);
|
136
|
+
cPointer.define_private_method("get_action", get_action);
|
137
|
+
cPointer.define_method("position", get_position);
|
138
|
+
cPointer.define_method("modifiers", get_modifiers);
|
139
|
+
cPointer.define_method("click_count", get_click_count);
|
140
|
+
cPointer.define_method("drag?", is_drag);
|
141
|
+
cPointer.define_method("time", get_time);
|
142
|
+
cPointer.define_method("prev", get_prev);
|
143
|
+
cPointer.define_const("TYPE_NONE", Reflex::Pointer::TYPE_NONE);
|
144
|
+
cPointer.define_const("MOUSE", Reflex::Pointer::MOUSE);
|
145
|
+
cPointer.define_const("MOUSE_LEFT", Reflex::Pointer::MOUSE_LEFT);
|
146
|
+
cPointer.define_const("MOUSE_RIGHT", Reflex::Pointer::MOUSE_RIGHT);
|
147
|
+
cPointer.define_const("MOUSE_MIDDLE", Reflex::Pointer::MOUSE_MIDDLE);
|
148
|
+
cPointer.define_const("TOUCH", Reflex::Pointer::TOUCH);
|
149
|
+
cPointer.define_const("PEN", Reflex::Pointer::PEN);
|
150
|
+
cPointer.define_const("ACTION_NONE", Reflex::Pointer::ACTION_NONE);
|
151
|
+
cPointer.define_const("DOWN", Reflex::Pointer::DOWN);
|
152
|
+
cPointer.define_const("UP", Reflex::Pointer::UP);
|
153
|
+
cPointer.define_const("MOVE", Reflex::Pointer::MOVE);
|
154
|
+
cPointer.define_const("CANCEL", Reflex::Pointer::CANCEL);
|
155
|
+
cPointer.define_const("STAY", Reflex::Pointer::STAY);
|
156
|
+
}
|
157
|
+
|
158
|
+
|
159
|
+
namespace Reflex
|
160
|
+
{
|
161
|
+
|
162
|
+
|
163
|
+
Class
|
164
|
+
pointer_class ()
|
165
|
+
{
|
166
|
+
return cPointer;
|
167
|
+
}
|
168
|
+
|
169
|
+
|
170
|
+
}// Reflex
|
@@ -1,7 +1,9 @@
|
|
1
1
|
#include "reflex/ruby/event.h"
|
2
2
|
|
3
3
|
|
4
|
+
#include <vector>
|
4
5
|
#include <rays/ruby/point.h>
|
6
|
+
#include "reflex/ruby/pointer.h"
|
5
7
|
#include "defs.h"
|
6
8
|
|
7
9
|
|
@@ -20,23 +22,18 @@ RUCY_DEF_ALLOC(alloc, klass)
|
|
20
22
|
RUCY_END
|
21
23
|
|
22
24
|
static
|
23
|
-
|
25
|
+
RUCY_DEFN(initialize)
|
24
26
|
{
|
25
27
|
CHECK;
|
26
28
|
|
27
|
-
|
28
|
-
if (size <= 0 || Reflex::PointerEvent::MAX < size)
|
29
|
+
if (argc == 0)
|
29
30
|
argument_error(__FILE__, __LINE__);
|
30
31
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
THIS->count = to<uint>(count);
|
35
|
-
THIS->drag = to<bool>(drag);
|
36
|
-
THIS->size = (size_t) size;
|
32
|
+
std::vector<Reflex::Pointer> pointers;
|
33
|
+
for (size_t i = 0; i < argc; ++i)
|
34
|
+
pointers.emplace_back(to<Reflex::Pointer&>(argv[i]));
|
37
35
|
|
38
|
-
|
39
|
-
THIS->positions[i] = to<Rays::Point>(positions[i]);
|
36
|
+
*THIS = Reflex::PointerEvent(&pointers[0], pointers.size());
|
40
37
|
|
41
38
|
return rb_call_super(0, NULL);
|
42
39
|
}
|
@@ -52,98 +49,52 @@ RUCY_DEF1(initialize_copy, obj)
|
|
52
49
|
RUCY_END
|
53
50
|
|
54
51
|
static
|
55
|
-
RUCY_DEF0(
|
52
|
+
RUCY_DEF0(get_size)
|
56
53
|
{
|
57
54
|
CHECK;
|
58
|
-
return value(THIS->
|
55
|
+
return value(THIS->size());
|
59
56
|
}
|
60
57
|
RUCY_END
|
61
58
|
|
62
59
|
static
|
63
|
-
RUCY_DEF0(
|
60
|
+
RUCY_DEF0(is_empty)
|
64
61
|
{
|
65
62
|
CHECK;
|
66
|
-
return value(THIS->
|
63
|
+
return value(THIS->empty());
|
67
64
|
}
|
68
65
|
RUCY_END
|
69
66
|
|
70
67
|
static
|
71
|
-
RUCY_DEF0(
|
68
|
+
RUCY_DEF0(is_captured)
|
72
69
|
{
|
73
70
|
CHECK;
|
74
|
-
return value(THIS->
|
71
|
+
return value(THIS->is_captured());
|
75
72
|
}
|
76
73
|
RUCY_END
|
77
74
|
|
78
75
|
static
|
79
|
-
|
80
|
-
{
|
81
|
-
CHECK;
|
82
|
-
return value(THIS->modifiers);
|
83
|
-
}
|
84
|
-
RUCY_END
|
85
|
-
|
86
|
-
static
|
87
|
-
RUCY_DEF0(count)
|
88
|
-
{
|
89
|
-
CHECK;
|
90
|
-
return value(THIS->count);
|
91
|
-
}
|
92
|
-
RUCY_END
|
93
|
-
|
94
|
-
static
|
95
|
-
RUCY_DEF0(drag)
|
96
|
-
{
|
97
|
-
CHECK;
|
98
|
-
return value(THIS->drag);
|
99
|
-
}
|
100
|
-
RUCY_END
|
101
|
-
|
102
|
-
static
|
103
|
-
RUCY_DEF0(capture)
|
104
|
-
{
|
105
|
-
CHECK;
|
106
|
-
return value(THIS->capture);
|
107
|
-
}
|
108
|
-
RUCY_END
|
109
|
-
|
110
|
-
static
|
111
|
-
RUCY_DEF0(x)
|
112
|
-
{
|
113
|
-
CHECK;
|
114
|
-
return value(THIS->x);
|
115
|
-
}
|
116
|
-
RUCY_END
|
117
|
-
|
118
|
-
static
|
119
|
-
RUCY_DEF0(y)
|
76
|
+
RUCY_DEF1(get_at, index)
|
120
77
|
{
|
121
78
|
CHECK;
|
122
|
-
return value(THIS->y);
|
123
|
-
}
|
124
|
-
RUCY_END
|
125
79
|
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
check_arg_count(__FILE__, __LINE__, "PointerEvent#position", argc, 0, 1);
|
80
|
+
int size = (int) THIS->size();
|
81
|
+
int i = to<int>(index);
|
82
|
+
if (i < -size || size <= i)
|
83
|
+
return Qnil;
|
131
84
|
|
132
|
-
|
133
|
-
return value(THIS->position(index));
|
85
|
+
return value((*THIS)[i >= 0 ? i : i + size]);
|
134
86
|
}
|
135
87
|
RUCY_END
|
136
88
|
|
137
89
|
static
|
138
|
-
|
90
|
+
RUCY_DEF0(each)
|
139
91
|
{
|
140
92
|
CHECK;
|
141
93
|
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
return value((*THIS)[i]);
|
94
|
+
Value ret;
|
95
|
+
for (size_t i = 0, size = THIS->size(); i < size; ++i)
|
96
|
+
ret = rb_yield(value((*THIS)[i]));
|
97
|
+
return ret;
|
147
98
|
}
|
148
99
|
RUCY_END
|
149
100
|
|
@@ -159,27 +110,11 @@ Init_pointer_event ()
|
|
159
110
|
cPointerEvent.define_alloc_func(alloc);
|
160
111
|
cPointerEvent.define_private_method("initialize", initialize);
|
161
112
|
cPointerEvent.define_private_method("initialize_copy", initialize_copy);
|
162
|
-
cPointerEvent.define_method("
|
163
|
-
cPointerEvent.define_method("
|
164
|
-
cPointerEvent.define_method("
|
165
|
-
cPointerEvent.define_method("
|
166
|
-
cPointerEvent.define_method("
|
167
|
-
cPointerEvent.define_method("drag?", drag);
|
168
|
-
cPointerEvent.define_method("capture?", capture);
|
169
|
-
cPointerEvent.define_method("x", x);
|
170
|
-
cPointerEvent.define_method("y", y);
|
171
|
-
cPointerEvent.define_method("position", position);
|
172
|
-
cPointerEvent.define_method("[]", get_at);
|
173
|
-
cPointerEvent.define_const("TYPE_NONE", Reflex::PointerEvent::NONE);
|
174
|
-
cPointerEvent.define_const("TYPE_DOWN", Reflex::PointerEvent::DOWN);
|
175
|
-
cPointerEvent.define_const("TYPE_UP", Reflex::PointerEvent::UP);
|
176
|
-
cPointerEvent.define_const("TYPE_MOVE", Reflex::PointerEvent::MOVE);
|
177
|
-
cPointerEvent.define_const("POINTER_NONE", Reflex::POINTER_NONE);
|
178
|
-
cPointerEvent.define_const("POINTER_MOUSE_LEFT", Reflex::POINTER_MOUSE_LEFT);
|
179
|
-
cPointerEvent.define_const("POINTER_MOUSE_RIGHT", Reflex::POINTER_MOUSE_RIGHT);
|
180
|
-
cPointerEvent.define_const("POINTER_MOUSE_MIDDLE", Reflex::POINTER_MOUSE_MIDDLE);
|
181
|
-
cPointerEvent.define_const("POINTER_TOUCH", Reflex::POINTER_TOUCH);
|
182
|
-
cPointerEvent.define_const("POINTER_PEN", Reflex::POINTER_PEN);
|
113
|
+
cPointerEvent.define_method("size", get_size);
|
114
|
+
cPointerEvent.define_method("empty?", is_empty);
|
115
|
+
cPointerEvent.define_method("captured?", is_captured);
|
116
|
+
cPointerEvent.define_method("[]", get_at);
|
117
|
+
cPointerEvent.define_method("each", each);
|
183
118
|
}
|
184
119
|
|
185
120
|
|
data/ext/reflex/selector.cpp
CHANGED
@@ -90,6 +90,14 @@ RUCY_DEF0(each_tag)
|
|
90
90
|
}
|
91
91
|
RUCY_END
|
92
92
|
|
93
|
+
static
|
94
|
+
RUCY_DEF0(is_empty)
|
95
|
+
{
|
96
|
+
CHECK;
|
97
|
+
return value(C_THIS->empty());
|
98
|
+
}
|
99
|
+
RUCY_END
|
100
|
+
|
93
101
|
static
|
94
102
|
RUCY_DEF1(contains, selector)
|
95
103
|
{
|
@@ -124,6 +132,7 @@ Init_selector ()
|
|
124
132
|
cSelector.define_method("clear_tags", clear_tags);
|
125
133
|
cSelector.define_method("tag?", has_tag);
|
126
134
|
cSelector.define_method("each_tag", each_tag);
|
135
|
+
cSelector.define_method("empty?", is_empty);
|
127
136
|
cSelector.define_method("contains", contains);
|
128
137
|
cSelector.define_method("==", equal);
|
129
138
|
}
|