reflexion 0.3 → 0.3.2
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/pointer.cpp +6 -15
- data/.doc/ext/reflex/style_length.cpp +3 -1
- data/.doc/ext/reflex/view.cpp +16 -8
- data/.github/workflows/utils.rb +1 -1
- data/ChangeLog.md +18 -0
- data/Gemfile.lock +1 -1
- data/LICENSE +1 -1
- data/Rakefile +0 -1
- data/VERSION +1 -1
- data/ext/reflex/pointer.cpp +6 -16
- data/ext/reflex/style_length.cpp +3 -1
- data/ext/reflex/view.cpp +17 -8
- data/include/reflex/pointer.h +3 -5
- data/include/reflex/ruby/timer.h +1 -1
- data/include/reflex/view.h +3 -1
- data/lib/reflex/pointer.rb +1 -1
- data/lib/reflex/pointer_event.rb +2 -2
- data/reflex.gemspec +4 -4
- data/src/body.cpp +12 -6
- data/src/event.cpp +10 -28
- data/src/event.h +1 -3
- data/src/filter.cpp +3 -1
- data/src/ios/event.mm +1 -2
- data/src/osx/application.mm +6 -5
- data/src/osx/event.mm +1 -2
- data/src/pointer.cpp +12 -32
- data/src/pointer.h +0 -2
- data/src/selector.cpp +3 -1
- data/src/shape.cpp +3 -1
- data/src/style.cpp +14 -8
- data/src/view.cpp +46 -24
- data/src/win32/event.cpp +2 -4
- data/src/window.cpp +27 -30
- data/src/window.h +3 -12
- data/test/test_pointer.rb +8 -10
- data/test/test_pointer_event.rb +8 -9
- metadata +34 -10
data/src/pointer.cpp
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
#include "pointer.h"
|
2
2
|
|
3
3
|
|
4
|
-
#include <limits.h>
|
5
4
|
#include <xot/time.h>
|
6
5
|
#include "reflex/exception.h"
|
7
6
|
|
@@ -48,9 +47,7 @@ namespace Reflex
|
|
48
47
|
|
49
48
|
Point position, prev_position;
|
50
49
|
|
51
|
-
uint modifiers, flags;
|
52
|
-
|
53
|
-
ushort click_count, view_index;
|
50
|
+
uint modifiers, click_count, flags;
|
54
51
|
|
55
52
|
double time;
|
56
53
|
|
@@ -58,16 +55,14 @@ namespace Reflex
|
|
58
55
|
|
59
56
|
Data (
|
60
57
|
ID id = -1, uint types = TYPE_NONE, Action action = ACTION_NONE,
|
61
|
-
const Point& position = 0, uint modifiers = 0,
|
58
|
+
const Point& position = 0, uint modifiers = 0, uint click_count = 0,
|
62
59
|
bool drag = false, bool enter = false, bool exit = false,
|
63
|
-
|
60
|
+
double time = 0)
|
64
61
|
: id(id), types(types), action(action),
|
65
|
-
position(position), modifiers(modifiers),
|
62
|
+
position(position), modifiers(modifiers), click_count(click_count),
|
66
63
|
flags(make_flags(drag, enter, exit)),
|
67
|
-
|
64
|
+
time(time)
|
68
65
|
{
|
69
|
-
if (view_index >= USHRT_MAX)
|
70
|
-
argument_error(__FILE__, __LINE__);
|
71
66
|
}
|
72
67
|
|
73
68
|
uint make_flags (bool drag, bool enter, bool exit)
|
@@ -101,15 +96,6 @@ namespace Reflex
|
|
101
96
|
it->self->id = id;
|
102
97
|
}
|
103
98
|
|
104
|
-
void
|
105
|
-
Pointer_set_view_index (Pointer* it, uint view_index)
|
106
|
-
{
|
107
|
-
if (view_index >= USHRT_MAX)
|
108
|
-
argument_error(__FILE__, __LINE__);
|
109
|
-
|
110
|
-
it->self->view_index = view_index;
|
111
|
-
}
|
112
|
-
|
113
99
|
void
|
114
100
|
Pointer_add_flag (Pointer* it, uint flag)
|
115
101
|
{
|
@@ -177,12 +163,12 @@ namespace Reflex
|
|
177
163
|
|
178
164
|
Pointer::Pointer (
|
179
165
|
ID id, uint types, Action action,
|
180
|
-
const Point& position, uint modifiers, bool drag,
|
181
|
-
|
166
|
+
const Point& position, uint modifiers, uint click_count, bool drag,
|
167
|
+
double time)
|
182
168
|
: self(new Data(
|
183
169
|
id, types, action,
|
184
|
-
position, modifiers, drag, false, false,
|
185
|
-
|
170
|
+
position, modifiers, click_count, drag, false, false,
|
171
|
+
time))
|
186
172
|
{
|
187
173
|
}
|
188
174
|
|
@@ -232,22 +218,16 @@ namespace Reflex
|
|
232
218
|
return self->modifiers;
|
233
219
|
}
|
234
220
|
|
235
|
-
bool
|
236
|
-
Pointer::is_drag () const
|
237
|
-
{
|
238
|
-
return Xot::has_flag(self->flags, Data::DRAG);
|
239
|
-
}
|
240
|
-
|
241
221
|
uint
|
242
222
|
Pointer::click_count () const
|
243
223
|
{
|
244
224
|
return self->click_count;
|
245
225
|
}
|
246
226
|
|
247
|
-
|
248
|
-
Pointer::
|
227
|
+
bool
|
228
|
+
Pointer::is_drag () const
|
249
229
|
{
|
250
|
-
return self->
|
230
|
+
return Xot::has_flag(self->flags, Data::DRAG);
|
251
231
|
}
|
252
232
|
|
253
233
|
double
|
data/src/pointer.h
CHANGED
data/src/selector.cpp
CHANGED
data/src/shape.cpp
CHANGED
@@ -444,7 +444,9 @@ namespace Reflex
|
|
444
444
|
void
|
445
445
|
Shape_call_contact_event (Shape* shape, ContactEvent* event)
|
446
446
|
{
|
447
|
-
if (!shape
|
447
|
+
if (!shape)
|
448
|
+
argument_error(__FILE__, __LINE__);
|
449
|
+
if (!event)
|
448
450
|
argument_error(__FILE__, __LINE__);
|
449
451
|
|
450
452
|
shape->on_contact(event);
|
data/src/style.cpp
CHANGED
@@ -202,7 +202,9 @@ namespace Reflex
|
|
202
202
|
void
|
203
203
|
StyleLength::reset (Type type, Value value)
|
204
204
|
{
|
205
|
-
if (type < NONE
|
205
|
+
if (type < NONE)
|
206
|
+
argument_error(__FILE__, __LINE__);
|
207
|
+
if (type >= TYPE_MAX)
|
206
208
|
argument_error(__FILE__, __LINE__);
|
207
209
|
|
208
210
|
if (type == FIT && value != 1)
|
@@ -615,14 +617,18 @@ namespace Reflex
|
|
615
617
|
void
|
616
618
|
Style::set_flow (Flow main, Flow sub)
|
617
619
|
{
|
618
|
-
if (
|
619
|
-
|
620
|
-
|
621
|
-
(
|
622
|
-
|
623
|
-
|
620
|
+
if (main < FLOW_NONE)
|
621
|
+
argument_error(__FILE__, __LINE__);
|
622
|
+
if (main >= FLOW_MAX)
|
623
|
+
argument_error(__FILE__, __LINE__);
|
624
|
+
if (sub < FLOW_NONE)
|
625
|
+
argument_error(__FILE__, __LINE__);
|
626
|
+
if (sub >= FLOW_MAX)
|
627
|
+
argument_error(__FILE__, __LINE__);
|
628
|
+
if (main != FLOW_NONE && (get_flow_dir(main) == get_flow_dir(sub)))
|
629
|
+
argument_error(__FILE__, __LINE__);
|
630
|
+
if (main == FLOW_NONE && sub != FLOW_NONE)
|
624
631
|
argument_error(__FILE__, __LINE__);
|
625
|
-
}
|
626
632
|
|
627
633
|
self->set_flow(main, sub);
|
628
634
|
|
data/src/view.cpp
CHANGED
@@ -289,15 +289,22 @@ namespace Reflex
|
|
289
289
|
|
290
290
|
World* child_world (View* view, bool create = true)
|
291
291
|
{
|
292
|
-
if (!pchild_world && create)
|
293
|
-
{
|
294
|
-
pchild_world.reset(new World());
|
295
|
-
create_walls(view);
|
296
|
-
}
|
297
|
-
|
292
|
+
if (!pchild_world && create) create_world(view);
|
298
293
|
return pchild_world.get();
|
299
294
|
}
|
300
295
|
|
296
|
+
void create_world (View* view, float pixels_per_meter = 0)
|
297
|
+
{
|
298
|
+
if (pchild_world)
|
299
|
+
invalid_state_error(__FILE__, __LINE__);
|
300
|
+
|
301
|
+
if (pixels_per_meter == 0)
|
302
|
+
pixels_per_meter = World::DEFAULT_PIXELS_PER_METER;
|
303
|
+
|
304
|
+
pchild_world.reset(new World(pixels_per_meter));
|
305
|
+
create_walls(view);
|
306
|
+
}
|
307
|
+
|
301
308
|
void create_walls (View* view)
|
302
309
|
{
|
303
310
|
clear_walls(view);
|
@@ -1327,7 +1334,9 @@ namespace Reflex
|
|
1327
1334
|
void
|
1328
1335
|
View_call_key_event (View* view, KeyEvent* event)
|
1329
1336
|
{
|
1330
|
-
if (!view
|
1337
|
+
if (!view)
|
1338
|
+
argument_error(__FILE__, __LINE__);
|
1339
|
+
if (!event)
|
1331
1340
|
argument_error(__FILE__, __LINE__);
|
1332
1341
|
|
1333
1342
|
if (view->hidden()) return;
|
@@ -1383,9 +1392,6 @@ namespace Reflex
|
|
1383
1392
|
case Pointer::CANCEL: view->on_pointer_cancel(event); break;
|
1384
1393
|
default: break;
|
1385
1394
|
}
|
1386
|
-
|
1387
|
-
if (!event->is_captured())
|
1388
|
-
PointerEvent_increment_view_indices(event);
|
1389
1395
|
}
|
1390
1396
|
|
1391
1397
|
static void
|
@@ -1398,34 +1404,36 @@ namespace Reflex
|
|
1398
1404
|
PointerEvent_each_pointer(&event, [&](const auto& pointer)
|
1399
1405
|
{
|
1400
1406
|
if (pointer.action() == Pointer::DOWN)
|
1401
|
-
Window_register_capture(win, view, pointer.id()
|
1407
|
+
Window_register_capture(win, view, pointer.id());
|
1402
1408
|
});
|
1403
1409
|
}
|
1404
1410
|
|
1405
1411
|
static void
|
1406
|
-
unregister_captures (View* view, const PointerEvent& event)
|
1412
|
+
unregister_captures (Window* window, View* view, const PointerEvent& event)
|
1407
1413
|
{
|
1408
|
-
Window* win = view->window();
|
1409
|
-
if (!win)
|
1410
|
-
invalid_state_error(__FILE__, __LINE__);
|
1411
|
-
|
1412
1414
|
PointerEvent_each_pointer(&event, [&](const auto& pointer)
|
1413
1415
|
{
|
1414
1416
|
auto action = pointer.action();
|
1415
1417
|
if (action == Pointer::UP || action == Pointer::CANCEL)
|
1416
|
-
Window_unregister_capture(
|
1418
|
+
Window_unregister_capture(window, view, pointer.id());
|
1417
1419
|
});
|
1418
1420
|
}
|
1419
1421
|
|
1420
1422
|
void
|
1421
1423
|
View_call_pointer_event (View* view, PointerEvent* event)
|
1422
1424
|
{
|
1423
|
-
if (!view
|
1425
|
+
if (!view)
|
1426
|
+
argument_error(__FILE__, __LINE__);
|
1427
|
+
if (!event)
|
1424
1428
|
argument_error(__FILE__, __LINE__);
|
1425
1429
|
|
1426
1430
|
if (view->hidden() || event->empty())
|
1427
1431
|
return;
|
1428
1432
|
|
1433
|
+
Window* win = view->window();
|
1434
|
+
if (!win)
|
1435
|
+
invalid_state_error(__FILE__, __LINE__);
|
1436
|
+
|
1429
1437
|
PointerEvent e = event->dup();
|
1430
1438
|
|
1431
1439
|
if (!e.is_captured())
|
@@ -1437,13 +1445,15 @@ namespace Reflex
|
|
1437
1445
|
call_pointer_events(view, &e);
|
1438
1446
|
}
|
1439
1447
|
|
1440
|
-
unregister_captures(view, e);
|
1448
|
+
unregister_captures(win, view, e);
|
1441
1449
|
}
|
1442
1450
|
|
1443
1451
|
void
|
1444
1452
|
View_call_wheel_event (View* view, WheelEvent* event)
|
1445
1453
|
{
|
1446
|
-
if (!view
|
1454
|
+
if (!view)
|
1455
|
+
argument_error(__FILE__, __LINE__);
|
1456
|
+
if (!event)
|
1447
1457
|
argument_error(__FILE__, __LINE__);
|
1448
1458
|
|
1449
1459
|
if (view->hidden()) return;
|
@@ -1469,7 +1479,9 @@ namespace Reflex
|
|
1469
1479
|
void
|
1470
1480
|
View_call_contact_event (View* view, ContactEvent* event)
|
1471
1481
|
{
|
1472
|
-
if (!view
|
1482
|
+
if (!view)
|
1483
|
+
argument_error(__FILE__, __LINE__);
|
1484
|
+
if (!event)
|
1473
1485
|
argument_error(__FILE__, __LINE__);
|
1474
1486
|
|
1475
1487
|
ContactEvent e = event->dup();
|
@@ -1738,7 +1750,9 @@ namespace Reflex
|
|
1738
1750
|
void
|
1739
1751
|
View::add_child (View* child)
|
1740
1752
|
{
|
1741
|
-
if (!child
|
1753
|
+
if (!child)
|
1754
|
+
argument_error(__FILE__, __LINE__);
|
1755
|
+
if (child == this)
|
1742
1756
|
argument_error(__FILE__, __LINE__);
|
1743
1757
|
|
1744
1758
|
bool found = std::find(child_begin(), child_end(), child) != child_end();
|
@@ -1764,7 +1778,9 @@ namespace Reflex
|
|
1764
1778
|
void
|
1765
1779
|
View::remove_child (View* child)
|
1766
1780
|
{
|
1767
|
-
if (!child
|
1781
|
+
if (!child)
|
1782
|
+
argument_error(__FILE__, __LINE__);
|
1783
|
+
if (child == this)
|
1768
1784
|
argument_error(__FILE__, __LINE__);
|
1769
1785
|
|
1770
1786
|
bool found = std::find(child_begin(), child_end(), child) != child_end();
|
@@ -2517,7 +2533,13 @@ namespace Reflex
|
|
2517
2533
|
}
|
2518
2534
|
|
2519
2535
|
void
|
2520
|
-
View::
|
2536
|
+
View::create_world (float pixels_per_meter)
|
2537
|
+
{
|
2538
|
+
self->create_world(this, pixels_per_meter);
|
2539
|
+
}
|
2540
|
+
|
2541
|
+
void
|
2542
|
+
View::update_world (float duration)
|
2521
2543
|
{
|
2522
2544
|
World* w = self->pchild_world.get();
|
2523
2545
|
if (w) w->update(duration);
|
data/src/win32/event.cpp
CHANGED
@@ -135,9 +135,8 @@ namespace Reflex
|
|
135
135
|
get_mouse_action(msg),
|
136
136
|
Point(GET_X_LPARAM(lp), GET_Y_LPARAM(lp)),
|
137
137
|
get_modifiers(),
|
138
|
-
is_mouse_dragging(msg, wp),
|
139
138
|
get_mouse_click_count(msg),
|
140
|
-
|
139
|
+
is_mouse_dragging(msg, wp),
|
141
140
|
Xot::time()));
|
142
141
|
}
|
143
142
|
|
@@ -197,9 +196,8 @@ namespace Reflex
|
|
197
196
|
action,
|
198
197
|
get_touch_position(hwnd, touch),
|
199
198
|
get_modifiers(),
|
200
|
-
action == Pointer::MOVE,
|
201
199
|
action == Pointer::DOWN ? 1 : 0,
|
202
|
-
|
200
|
+
action == Pointer::MOVE,
|
203
201
|
get_touch_time(touch));
|
204
202
|
Pointer_set_system_id(&pointer, touch.dwID);
|
205
203
|
|
data/src/window.cpp
CHANGED
@@ -19,9 +19,7 @@ namespace Reflex
|
|
19
19
|
|
20
20
|
using ExtractedPointerIDSet = std::set<Pointer::ID>;
|
21
21
|
|
22
|
-
using
|
23
|
-
|
24
|
-
using TargetPointerMap = Window::Data::TargetPointerMap;
|
22
|
+
using CaptureTargetIDList = Window::Data::CaptureTargetIDList;
|
25
23
|
|
26
24
|
|
27
25
|
Window::Data::Data ()
|
@@ -35,16 +33,12 @@ namespace Reflex
|
|
35
33
|
}
|
36
34
|
|
37
35
|
|
38
|
-
Window::Data::PointerData::PointerData (uint view_index)
|
39
|
-
: view_index(view_index)
|
40
|
-
{
|
41
|
-
}
|
42
|
-
|
43
|
-
|
44
36
|
void
|
45
37
|
Window_set_focus (Window* window, View* view)
|
46
38
|
{
|
47
|
-
if (!window
|
39
|
+
if (!window)
|
40
|
+
argument_error(__FILE__, __LINE__);
|
41
|
+
if (!view)
|
48
42
|
argument_error(__FILE__, __LINE__);
|
49
43
|
|
50
44
|
View* current = window->self->focus.get();
|
@@ -89,8 +83,7 @@ namespace Reflex
|
|
89
83
|
}
|
90
84
|
|
91
85
|
void
|
92
|
-
Window_register_capture (
|
93
|
-
Window* window, View* view, Pointer::ID target, uint view_index)
|
86
|
+
Window_register_capture (Window* window, View* view, Pointer::ID target)
|
94
87
|
{
|
95
88
|
if (!view)
|
96
89
|
argument_error(__FILE__, __LINE__);
|
@@ -101,10 +94,12 @@ namespace Reflex
|
|
101
94
|
if (target < 0) return;
|
102
95
|
|
103
96
|
auto& targets = window->self->captures[view];
|
104
|
-
if (targets.
|
97
|
+
if (std::find(targets.begin(), targets.end(), target) != targets.end())
|
105
98
|
return;
|
106
99
|
|
107
|
-
targets.insert(
|
100
|
+
targets.insert(
|
101
|
+
target == CAPTURE_ALL ? targets.begin() : targets.end(),
|
102
|
+
target);
|
108
103
|
}
|
109
104
|
|
110
105
|
void
|
@@ -117,7 +112,7 @@ namespace Reflex
|
|
117
112
|
if (captures_it == window->self->captures.end()) return;
|
118
113
|
|
119
114
|
auto& targets = captures_it->second;
|
120
|
-
auto targets_it = targets.
|
115
|
+
auto targets_it = std::find(targets.begin(), targets.end(), target);
|
121
116
|
if (targets_it == targets.end()) return;
|
122
117
|
|
123
118
|
targets.erase(targets_it);
|
@@ -157,7 +152,9 @@ namespace Reflex
|
|
157
152
|
void
|
158
153
|
Window_call_draw_event (Window* window, DrawEvent* event)
|
159
154
|
{
|
160
|
-
if (!window
|
155
|
+
if (!window)
|
156
|
+
argument_error(__FILE__, __LINE__);
|
157
|
+
if (!event)
|
161
158
|
argument_error(__FILE__, __LINE__);
|
162
159
|
|
163
160
|
Painter* painter = window->painter();
|
@@ -182,12 +179,12 @@ namespace Reflex
|
|
182
179
|
}
|
183
180
|
|
184
181
|
static bool
|
185
|
-
|
186
|
-
const View* view, const
|
182
|
+
is_capturing_all (
|
183
|
+
const View* view, const CaptureTargetIDList& targets, View::Capture type)
|
187
184
|
{
|
188
185
|
return
|
189
186
|
!targets.empty() &&
|
190
|
-
targets
|
187
|
+
targets[0] == CAPTURE_ALL &&
|
191
188
|
(view->capture() & type) == type;
|
192
189
|
}
|
193
190
|
|
@@ -210,8 +207,12 @@ namespace Reflex
|
|
210
207
|
|
211
208
|
for (auto& [view, targets] : window->self->captures)
|
212
209
|
{
|
213
|
-
if (
|
210
|
+
if (
|
211
|
+
!view->window() ||
|
212
|
+
!is_capturing_all(view.get(), targets, View::CAPTURE_KEY))
|
213
|
+
{
|
214
214
|
continue;
|
215
|
+
}
|
215
216
|
|
216
217
|
KeyEvent e = event->dup();
|
217
218
|
KeyEvent_set_captured(&e, true);
|
@@ -335,7 +336,7 @@ namespace Reflex
|
|
335
336
|
result->clear();
|
336
337
|
for (const auto& [view, targets] : window->self->captures)
|
337
338
|
{
|
338
|
-
if (
|
339
|
+
if (is_capturing_all(view.get(), targets, View::CAPTURE_POINTER))
|
339
340
|
result->emplace_back(view);
|
340
341
|
}
|
341
342
|
}
|
@@ -361,28 +362,24 @@ namespace Reflex
|
|
361
362
|
static void
|
362
363
|
extract_pointer (
|
363
364
|
PointerEvent* event, ExtractedPointerIDSet* extracteds,
|
364
|
-
const Pointer& pointer
|
365
|
+
const Pointer& pointer)
|
365
366
|
{
|
366
|
-
PointerEvent_add_pointer(event, pointer
|
367
|
-
{
|
368
|
-
Pointer_set_view_index(p, view_index);
|
369
|
-
});
|
370
|
-
|
367
|
+
PointerEvent_add_pointer(event, pointer);
|
371
368
|
extracteds->insert(pointer.id());
|
372
369
|
}
|
373
370
|
|
374
371
|
static void
|
375
372
|
extract_targeted_pointers (
|
376
373
|
PointerEvent* event, ExtractedPointerIDSet* extracteds,
|
377
|
-
const
|
374
|
+
const CaptureTargetIDList& targets, const PointerMap& pointers)
|
378
375
|
{
|
379
376
|
assert(event->empty());
|
380
377
|
|
381
|
-
for (auto
|
378
|
+
for (auto pointer_id : targets)
|
382
379
|
{
|
383
380
|
auto it = pointers.find(pointer_id);
|
384
381
|
if (it != pointers.end())
|
385
|
-
extract_pointer(event, extracteds, it->second
|
382
|
+
extract_pointer(event, extracteds, it->second);
|
386
383
|
}
|
387
384
|
}
|
388
385
|
|
data/src/window.h
CHANGED
@@ -28,18 +28,9 @@ namespace Reflex
|
|
28
28
|
struct Window::Data
|
29
29
|
{
|
30
30
|
|
31
|
-
|
32
|
-
{
|
33
|
-
|
34
|
-
uint view_index;
|
35
|
-
|
36
|
-
PointerData (uint view_index);
|
31
|
+
typedef std::vector<Pointer::ID> CaptureTargetIDList;
|
37
32
|
|
38
|
-
|
39
|
-
|
40
|
-
typedef std::map<Pointer::ID, PointerData> TargetPointerMap;
|
41
|
-
|
42
|
-
typedef std::map<View::Ref, TargetPointerMap> CaptureMap;
|
33
|
+
typedef std::map<View::Ref, CaptureTargetIDList> CaptureMap;
|
43
34
|
|
44
35
|
int hide_count = 1;
|
45
36
|
|
@@ -112,7 +103,7 @@ namespace Reflex
|
|
112
103
|
void Window_set_focus (Window* window, View* view);
|
113
104
|
|
114
105
|
void Window_register_capture (
|
115
|
-
Window* window, View* view, Pointer::ID target
|
106
|
+
Window* window, View* view, Pointer::ID target);
|
116
107
|
|
117
108
|
void Window_unregister_capture (
|
118
109
|
Window* window, View* view, Pointer::ID target);
|
data/test/test_pointer.rb
CHANGED
@@ -23,11 +23,11 @@ class TestPointer < Test::Unit::TestCase
|
|
23
23
|
|
24
24
|
def pointer(
|
25
25
|
id: 0, types: TYPE_NONE, action: ACTION_NONE,
|
26
|
-
position: 0, modifiers: 0,
|
26
|
+
position: 0, modifiers: 0, click_count: 0, drag: false,
|
27
27
|
time: 0)
|
28
28
|
|
29
29
|
Reflex::Pointer.new(
|
30
|
-
id, types, action, position, modifiers,
|
30
|
+
id, types, action, position, modifiers, click_count, drag, time)
|
31
31
|
end
|
32
32
|
|
33
33
|
def test_initialize()
|
@@ -35,8 +35,8 @@ class TestPointer < Test::Unit::TestCase
|
|
35
35
|
|
36
36
|
p = pointer(
|
37
37
|
id: 1, types: TOUCH, action: UP,
|
38
|
-
position: [2, 3], modifiers: 4,
|
39
|
-
time:
|
38
|
+
position: [2, 3], modifiers: 4, click_count: 5, drag: true,
|
39
|
+
time: 6)
|
40
40
|
|
41
41
|
assert_equal 1, p.id
|
42
42
|
assert_equal [:touch], p.types
|
@@ -45,10 +45,9 @@ class TestPointer < Test::Unit::TestCase
|
|
45
45
|
assert_equal 2, p.x
|
46
46
|
assert_equal 3, p.y
|
47
47
|
assert_equal 4, p.modifiers
|
48
|
-
assert_equal true, p.drag?
|
49
48
|
assert_equal 5, p.click_count
|
50
|
-
assert_equal
|
51
|
-
assert_equal
|
49
|
+
assert_equal true, p.drag?
|
50
|
+
assert_equal 6, p.time
|
52
51
|
assert_nil p.prev
|
53
52
|
assert_nil p.down
|
54
53
|
end
|
@@ -147,10 +146,9 @@ class TestPointer < Test::Unit::TestCase
|
|
147
146
|
assert_not_equal pointer, pointer(action: Reflex::Pointer::UP)
|
148
147
|
assert_not_equal pointer, pointer(position: 2)
|
149
148
|
assert_not_equal pointer, pointer(modifiers: 3)
|
150
|
-
assert_not_equal pointer, pointer(drag: true)
|
151
149
|
assert_not_equal pointer, pointer(click_count: 4)
|
152
|
-
assert_not_equal pointer, pointer(
|
153
|
-
assert_not_equal pointer, pointer(time:
|
150
|
+
assert_not_equal pointer, pointer(drag: true)
|
151
|
+
assert_not_equal pointer, pointer(time: 5)
|
154
152
|
end
|
155
153
|
|
156
154
|
end# TestPointer
|
data/test/test_pointer_event.rb
CHANGED
@@ -17,11 +17,11 @@ class TestPointerEvent < Test::Unit::TestCase
|
|
17
17
|
|
18
18
|
def pointer(
|
19
19
|
id: 0, type: TYPE_NONE, action: ACTION_NONE,
|
20
|
-
position: 0, modifiers: 0,
|
20
|
+
position: 0, modifiers: 0, click_count: 0, drag: false,
|
21
21
|
time: 0)
|
22
22
|
|
23
23
|
Reflex::Pointer.new(
|
24
|
-
id, type, action, position, modifiers,
|
24
|
+
id, type, action, position, modifiers, click_count, drag, time)
|
25
25
|
end
|
26
26
|
|
27
27
|
def test_initialize()
|
@@ -31,12 +31,12 @@ class TestPointerEvent < Test::Unit::TestCase
|
|
31
31
|
|
32
32
|
p1 = pointer(
|
33
33
|
id: 1, type: TOUCH, action: DOWN,
|
34
|
-
position: [2, 3], modifiers: 4, drag: true, click_count: 5,
|
35
|
-
time:
|
34
|
+
position: [2, 3], modifiers: 4, drag: true, click_count: 5,
|
35
|
+
time: 6)
|
36
36
|
p2 = pointer(
|
37
37
|
id: 10, type: PEN, action: UP,
|
38
|
-
position: [20, 30], modifiers: 40, drag: false, click_count: 50,
|
39
|
-
time:
|
38
|
+
position: [20, 30], modifiers: 40, drag: false, click_count: 50,
|
39
|
+
time: 60)
|
40
40
|
e = event p1, p2
|
41
41
|
|
42
42
|
assert_equal [p1, p2], e.pointers.to_a
|
@@ -51,10 +51,9 @@ class TestPointerEvent < Test::Unit::TestCase
|
|
51
51
|
assert_equal 2, e.x
|
52
52
|
assert_equal 3, e.y
|
53
53
|
assert_equal 4, e.modifiers
|
54
|
-
assert_equal true, e.drag?
|
55
54
|
assert_equal 5, e.click_count
|
56
|
-
assert_equal
|
57
|
-
assert_equal
|
55
|
+
assert_equal true, e.drag?
|
56
|
+
assert_equal 6, e.time
|
58
57
|
end
|
59
58
|
|
60
59
|
def test_dup()
|