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