reflexion 0.1.57 → 0.2.1
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/exception.cpp +1 -1
- data/.doc/ext/reflex/key_event.cpp +22 -7
- data/.doc/ext/reflex/reflex.cpp +203 -0
- data/.doc/ext/reflex/style.cpp +2 -2
- data/.doc/ext/reflex/view.cpp +1 -1
- data/.github/workflows/release-gem.yml +1 -1
- data/.github/workflows/tag.yml +1 -1
- data/.github/workflows/test.yml +7 -1
- data/ChangeLog.md +19 -0
- data/Gemfile.lock +1 -1
- data/VERSION +1 -1
- data/ext/reflex/exception.cpp +1 -1
- data/ext/reflex/key_event.cpp +22 -7
- data/ext/reflex/reflex.cpp +203 -0
- data/ext/reflex/style.cpp +2 -2
- data/ext/reflex/view.cpp +1 -1
- data/include/reflex/defs.h +199 -188
- data/include/reflex/ruby.h +4 -1
- data/include/reflex.h +2 -0
- data/lib/reflex/key_event.rb +23 -1
- data/reflex.gemspec +4 -4
- data/samples/key.rb +1 -1
- data/src/event.cpp +1 -0
- data/src/ios/event.h +1 -11
- data/src/ios/event.mm +10 -57
- data/src/ios/view_controller.mm +21 -44
- data/src/ios/window.mm +19 -19
- data/src/osx/event.h +1 -1
- data/src/osx/event.mm +51 -189
- data/src/osx/native_window.mm +33 -84
- data/src/osx/window.mm +12 -12
- data/src/pointer.cpp +53 -11
- data/src/pointer.h +8 -0
- data/src/view.cpp +4 -79
- data/src/window.cpp +105 -0
- data/src/window.h +13 -3
- data/test/helper.rb +0 -6
- data/test/test_key_event.rb +17 -8
- data/test/test_pointer.rb +7 -2
- data/test/test_screen.rb +0 -4
- metadata +10 -10
data/src/osx/window.mm
CHANGED
@@ -74,9 +74,9 @@ namespace Reflex
|
|
74
74
|
Window_default_flags ()
|
75
75
|
{
|
76
76
|
return
|
77
|
-
Window::FLAG_CLOSABLE
|
78
|
-
Window::
|
79
|
-
Window::
|
77
|
+
Window::FLAG_CLOSABLE |
|
78
|
+
Window::FLAG_RESIZABLE |
|
79
|
+
Window::FLAG_MINIMIZABLE;
|
80
80
|
}
|
81
81
|
|
82
82
|
void
|
@@ -143,6 +143,15 @@ namespace Reflex
|
|
143
143
|
return Bounds(f.origin.x, f.origin.y, f.size.width, f.size.height);
|
144
144
|
}
|
145
145
|
|
146
|
+
Screen
|
147
|
+
Window_get_screen (const Window& window)
|
148
|
+
{
|
149
|
+
Screen s;
|
150
|
+
NSScreen* screen = get_native(&window).screen;
|
151
|
+
if (screen) Screen_initialize(&s, screen);
|
152
|
+
return s;
|
153
|
+
}
|
154
|
+
|
146
155
|
void
|
147
156
|
Window_set_flags (Window* window, uint flags)
|
148
157
|
{
|
@@ -163,15 +172,6 @@ namespace Reflex
|
|
163
172
|
[native toggleFullScreen: native];
|
164
173
|
}
|
165
174
|
|
166
|
-
Screen
|
167
|
-
Window_get_screen (const Window& window)
|
168
|
-
{
|
169
|
-
Screen s;
|
170
|
-
NSScreen* screen = get_native(&window).screen;
|
171
|
-
if (screen) Screen_initialize(&s, screen);
|
172
|
-
return s;
|
173
|
-
}
|
174
|
-
|
175
175
|
float
|
176
176
|
Window_get_pixel_density (const Window& window)
|
177
177
|
{
|
data/src/pointer.cpp
CHANGED
@@ -28,21 +28,25 @@ namespace Reflex
|
|
28
28
|
enum Flag
|
29
29
|
{
|
30
30
|
|
31
|
-
DRAG
|
31
|
+
DRAG = Xot::bit(0, TYPE_LAST),
|
32
32
|
|
33
|
-
ENTER
|
33
|
+
ENTER = Xot::bit(1, TYPE_LAST),
|
34
34
|
|
35
|
-
EXIT
|
35
|
+
EXIT = Xot::bit(2, TYPE_LAST),
|
36
|
+
|
37
|
+
HAS_SYSTEM_ID = Xot::bit(3, TYPE_LAST),
|
38
|
+
|
39
|
+
HAS_PREV_POS = Xot::bit(4, TYPE_LAST),
|
36
40
|
|
37
41
|
};// Flag
|
38
42
|
|
39
|
-
ID id;
|
43
|
+
ID id, system_id;
|
40
44
|
|
41
45
|
uint types;
|
42
46
|
|
43
47
|
Action action;
|
44
48
|
|
45
|
-
Point position;
|
49
|
+
Point position, prev_position;
|
46
50
|
|
47
51
|
uint modifiers, flags;
|
48
52
|
|
@@ -74,6 +78,11 @@ namespace Reflex
|
|
74
78
|
(exit ? EXIT : 0);
|
75
79
|
}
|
76
80
|
|
81
|
+
bool is_valid () const
|
82
|
+
{
|
83
|
+
return id >= 0 && types != TYPE_NONE && action != ACTION_NONE;
|
84
|
+
}
|
85
|
+
|
77
86
|
};// Pointer::Data
|
78
87
|
|
79
88
|
|
@@ -122,13 +131,43 @@ namespace Reflex
|
|
122
131
|
void
|
123
132
|
Pointer_set_prev (Pointer* it, const Pointer* prev)
|
124
133
|
{
|
125
|
-
it->self->prev.reset(prev ? new Pointer(*prev) : NULL);
|
134
|
+
it->self->prev.reset(prev && *prev ? new Pointer(*prev) : NULL);
|
126
135
|
}
|
127
136
|
|
128
137
|
void
|
129
138
|
Pointer_set_down (Pointer* it, const Pointer* down)
|
130
139
|
{
|
131
|
-
it->self->down.reset(down ? new Pointer(*down) : NULL);
|
140
|
+
it->self->down.reset(down && *down ? new Pointer(*down) : NULL);
|
141
|
+
}
|
142
|
+
|
143
|
+
void
|
144
|
+
Pointer_set_system_id (Pointer*it, Pointer::ID id)
|
145
|
+
{
|
146
|
+
it->self->system_id = id;
|
147
|
+
Xot::add_flag(&it->self->flags, Pointer::Data::HAS_SYSTEM_ID);
|
148
|
+
}
|
149
|
+
|
150
|
+
const Pointer::ID*
|
151
|
+
Pointer_get_system_id (const Pointer& it)
|
152
|
+
{
|
153
|
+
if (!Xot::has_flag(it.self->flags, Pointer::Data::HAS_SYSTEM_ID))
|
154
|
+
return NULL;
|
155
|
+
return &it.self->system_id;
|
156
|
+
}
|
157
|
+
|
158
|
+
void
|
159
|
+
Pointer_set_prev_position (Pointer* it, const Point& position)
|
160
|
+
{
|
161
|
+
it->self->prev_position = position;
|
162
|
+
Xot::add_flag(&it->self->flags, Pointer::Data::HAS_PREV_POS);
|
163
|
+
}
|
164
|
+
|
165
|
+
const Point*
|
166
|
+
Pointer_get_prev_position (const Pointer& it)
|
167
|
+
{
|
168
|
+
if (!Xot::has_flag(it.self->flags, Pointer::Data::HAS_PREV_POS))
|
169
|
+
return NULL;
|
170
|
+
return &it.self->prev_position;
|
132
171
|
}
|
133
172
|
|
134
173
|
|
@@ -226,14 +265,17 @@ namespace Reflex
|
|
226
265
|
const Pointer*
|
227
266
|
Pointer::down () const
|
228
267
|
{
|
229
|
-
|
268
|
+
if (self->down)
|
269
|
+
return self->down.get();
|
270
|
+
else if (action() == DOWN)
|
271
|
+
return this;
|
272
|
+
else
|
273
|
+
return NULL;
|
230
274
|
}
|
231
275
|
|
232
276
|
Pointer::operator bool () const
|
233
277
|
{
|
234
|
-
return
|
235
|
-
self->types != TYPE_NONE &&
|
236
|
-
ACTION_NONE < self->action && self->action <= STAY;
|
278
|
+
return self->is_valid();
|
237
279
|
}
|
238
280
|
|
239
281
|
bool
|
data/src/pointer.h
CHANGED
@@ -28,6 +28,14 @@ namespace Reflex
|
|
28
28
|
|
29
29
|
void Pointer_set_down (Pointer* it, const Pointer* down);
|
30
30
|
|
31
|
+
void Pointer_set_system_id (Pointer* it, Pointer::ID id);
|
32
|
+
|
33
|
+
const Pointer::ID* Pointer_get_system_id (const Pointer& it);
|
34
|
+
|
35
|
+
void Pointer_set_prev_position (Pointer* it, const Point& position);
|
36
|
+
|
37
|
+
const Point* Pointer_get_prev_position (const Pointer& it);
|
38
|
+
|
31
39
|
|
32
40
|
}// Reflex
|
33
41
|
|
data/src/view.cpp
CHANGED
@@ -245,7 +245,7 @@ namespace Reflex
|
|
245
245
|
void
|
246
246
|
get_view2body_matrix (Matrix* m)
|
247
247
|
{
|
248
|
-
assert(
|
248
|
+
assert(*m == 1 && ppivot && *ppivot != 0);
|
249
249
|
|
250
250
|
Point pivot = *ppivot * frame.size();
|
251
251
|
m->translate(frame.position() + pivot)
|
@@ -256,7 +256,7 @@ namespace Reflex
|
|
256
256
|
void
|
257
257
|
get_body2view_matrix (Matrix* m)
|
258
258
|
{
|
259
|
-
assert(
|
259
|
+
assert(*m == 1 && ppivot && *ppivot != 0 && pbody);
|
260
260
|
|
261
261
|
Point pos = pbody->position();
|
262
262
|
Point pivot = *ppivot * frame.size();
|
@@ -288,8 +288,6 @@ namespace Reflex
|
|
288
288
|
|
289
289
|
World* child_world (View* view, bool create = true)
|
290
290
|
{
|
291
|
-
assert(view);
|
292
|
-
|
293
291
|
if (!pchild_world && create)
|
294
292
|
{
|
295
293
|
pchild_world.reset(new World());
|
@@ -301,8 +299,6 @@ namespace Reflex
|
|
301
299
|
|
302
300
|
void create_walls (View* view)
|
303
301
|
{
|
304
|
-
assert(view);
|
305
|
-
|
306
302
|
clear_walls(view);
|
307
303
|
|
308
304
|
View* wall = new View(WALL_NAME);
|
@@ -314,8 +310,6 @@ namespace Reflex
|
|
314
310
|
|
315
311
|
void clear_walls (View* view)
|
316
312
|
{
|
317
|
-
assert(view);
|
318
|
-
|
319
313
|
for (auto& wall : view->find_children(WALL_NAME))
|
320
314
|
view->remove_child(wall.get());
|
321
315
|
}
|
@@ -364,8 +358,6 @@ namespace Reflex
|
|
364
358
|
|
365
359
|
void do_sort_children ()
|
366
360
|
{
|
367
|
-
assert(pchildren);
|
368
|
-
|
369
361
|
auto& children = *pchildren;
|
370
362
|
|
371
363
|
size_t size = children.size();
|
@@ -475,8 +467,6 @@ namespace Reflex
|
|
475
467
|
|
476
468
|
static void get_flow_sign (schar* h, schar* v, Style::Flow flow)
|
477
469
|
{
|
478
|
-
assert(h && v);
|
479
|
-
|
480
470
|
switch (flow)
|
481
471
|
{
|
482
472
|
case Style::FLOW_RIGHT: *h = +1; *v = 0; break;
|
@@ -491,8 +481,6 @@ namespace Reflex
|
|
491
481
|
iterator* line_end, coord* main_fill_size, coord* sub_size_max,
|
492
482
|
iterator begin, iterator end)
|
493
483
|
{
|
494
|
-
assert(line_end && main_fill_size && sub_size_max);
|
495
|
-
|
496
484
|
*line_end = end;
|
497
485
|
*main_fill_size = 0;
|
498
486
|
*sub_size_max = 0;
|
@@ -545,8 +533,6 @@ namespace Reflex
|
|
545
533
|
void place_child (
|
546
534
|
View* child, Point* position, coord main_fill_size, coord sub_size_max)
|
547
535
|
{
|
548
|
-
assert(child && position);
|
549
|
-
|
550
536
|
const Style* style = child->self->pstyle.get();
|
551
537
|
Bounds frame = child->frame();
|
552
538
|
bool update = false;
|
@@ -567,8 +553,6 @@ namespace Reflex
|
|
567
553
|
Bounds* frame,
|
568
554
|
const Style* style, coord main_fill_size, coord sub_size_max)
|
569
555
|
{
|
570
|
-
assert(frame);
|
571
|
-
|
572
556
|
bool update = false;
|
573
557
|
|
574
558
|
if (has_fill_length(style, DIR_MAIN))
|
@@ -582,8 +566,6 @@ namespace Reflex
|
|
582
566
|
|
583
567
|
bool place_in_flow (Bounds* frame, Point* position)
|
584
568
|
{
|
585
|
-
assert(frame && position);
|
586
|
-
|
587
569
|
coord old_x = frame->x;
|
588
570
|
coord old_y = frame->y;
|
589
571
|
|
@@ -604,8 +586,6 @@ namespace Reflex
|
|
604
586
|
|
605
587
|
bool place_position (Bounds* frame, const Style* style)
|
606
588
|
{
|
607
|
-
assert(frame);
|
608
|
-
|
609
589
|
if (!style)
|
610
590
|
return false;
|
611
591
|
|
@@ -666,8 +646,6 @@ namespace Reflex
|
|
666
646
|
|
667
647
|
bool set_flow_size (Bounds* frame, coord size, FlowDirection dir) const
|
668
648
|
{
|
669
|
-
assert(frame);
|
670
|
-
|
671
649
|
coord& value = flow_value(frame->width, frame->height, dir);
|
672
650
|
if (value == size) return false;
|
673
651
|
|
@@ -745,15 +723,11 @@ namespace Reflex
|
|
745
723
|
static void
|
746
724
|
apply_style_to_children_have_variable_lengths (View* parent)
|
747
725
|
{
|
748
|
-
assert(parent);
|
749
|
-
|
750
726
|
View::ChildList* children = parent->self->children();
|
751
727
|
if (!children) return;
|
752
728
|
|
753
729
|
for (auto& child : *children)
|
754
730
|
{
|
755
|
-
assert(child);
|
756
|
-
|
757
731
|
if (child->self->has_flag(View::Data::HAS_VARIABLE_LENGTHS))
|
758
732
|
child->self->add_flag(View::Data::APPLY_STYLE);
|
759
733
|
}
|
@@ -762,7 +736,6 @@ namespace Reflex
|
|
762
736
|
static void
|
763
737
|
update_view_layout (View* view, bool update_parent = false)
|
764
738
|
{
|
765
|
-
assert(view);
|
766
739
|
View::Data* self = view->self.get();
|
767
740
|
|
768
741
|
self->add_flag(View::Data::UPDATE_LAYOUT);
|
@@ -776,7 +749,6 @@ namespace Reflex
|
|
776
749
|
View* view, const Bounds& frame, float zoom, float angle,
|
777
750
|
bool update_body = true)
|
778
751
|
{
|
779
|
-
assert(view);
|
780
752
|
View::Data* self = view->self.get();
|
781
753
|
|
782
754
|
if (frame == self->frame && zoom == self->zoom && angle == self->angle)
|
@@ -854,8 +826,6 @@ namespace Reflex
|
|
854
826
|
View::ChildList* result, const View* view, const Selector& selector,
|
855
827
|
bool recursive)
|
856
828
|
{
|
857
|
-
assert(result && view);
|
858
|
-
|
859
829
|
View::ChildList* children = view->self->children();
|
860
830
|
if (!children) return;
|
861
831
|
|
@@ -877,8 +847,6 @@ namespace Reflex
|
|
877
847
|
View::StyleList* result, const View* view, const Selector& selector,
|
878
848
|
bool recursive)
|
879
849
|
{
|
880
|
-
assert(result && view);
|
881
|
-
|
882
850
|
View::StyleList* pstyles = view->self->pstyles.get();
|
883
851
|
if (pstyles)
|
884
852
|
{
|
@@ -902,8 +870,6 @@ namespace Reflex
|
|
902
870
|
static void
|
903
871
|
fire_timers (View* view, double now)
|
904
872
|
{
|
905
|
-
assert(view);
|
906
|
-
|
907
873
|
Timers* timers = view->self->ptimers.get();
|
908
874
|
if (timers)
|
909
875
|
timers->fire(now);
|
@@ -912,7 +878,6 @@ namespace Reflex
|
|
912
878
|
static void
|
913
879
|
update_view_shapes (View* view)
|
914
880
|
{
|
915
|
-
assert(view);
|
916
881
|
View::Data* self = view->self.get();
|
917
882
|
|
918
883
|
bool create_shape = self->pbody && !self->pshape;
|
@@ -927,7 +892,6 @@ namespace Reflex
|
|
927
892
|
static void
|
928
893
|
update_view_body (View* view)
|
929
894
|
{
|
930
|
-
assert(view);
|
931
895
|
View::Data* self = view->self.get();
|
932
896
|
|
933
897
|
Body* body = self->pbody.get();
|
@@ -954,7 +918,6 @@ namespace Reflex
|
|
954
918
|
static void
|
955
919
|
update_child_world (View* view, float dt)
|
956
920
|
{
|
957
|
-
assert(view);
|
958
921
|
View::Data* self = view->self.get();
|
959
922
|
|
960
923
|
World* child_world = self->pchild_world.get();
|
@@ -973,7 +936,6 @@ namespace Reflex
|
|
973
936
|
static void
|
974
937
|
update_views_for_selectors (View* view)
|
975
938
|
{
|
976
|
-
assert(view);
|
977
939
|
View::Data* self = view->self.get();
|
978
940
|
|
979
941
|
View::Data::SelectorSet* sels = self->pselectors_for_update.get();
|
@@ -1001,8 +963,6 @@ namespace Reflex
|
|
1001
963
|
get_styles_for_selector (
|
1002
964
|
View::StyleList* result, View* view, const Selector& selector)
|
1003
965
|
{
|
1004
|
-
assert(result);
|
1005
|
-
|
1006
966
|
View* parent = view->parent();
|
1007
967
|
if (parent)
|
1008
968
|
get_styles_for_selector(result, parent, selector);
|
@@ -1013,8 +973,6 @@ namespace Reflex
|
|
1013
973
|
static bool
|
1014
974
|
get_styles_for_view (View::StyleList* result, View* view)
|
1015
975
|
{
|
1016
|
-
assert(result && view);
|
1017
|
-
|
1018
976
|
result->clear();
|
1019
977
|
|
1020
978
|
Selector* sel = view->self->pselector.get();
|
@@ -1028,7 +986,6 @@ namespace Reflex
|
|
1028
986
|
static void
|
1029
987
|
update_view_style (View* view)
|
1030
988
|
{
|
1031
|
-
assert(view);
|
1032
989
|
View::Data* self = view->self.get();
|
1033
990
|
|
1034
991
|
Style* pstyle = self->pstyle.get();
|
@@ -1057,8 +1014,6 @@ namespace Reflex
|
|
1057
1014
|
static void
|
1058
1015
|
fit_view_to_content (View* view)
|
1059
1016
|
{
|
1060
|
-
assert(view);
|
1061
|
-
|
1062
1017
|
Bounds bounds = view->content_bounds();
|
1063
1018
|
if (!bounds) return;
|
1064
1019
|
|
@@ -1121,7 +1076,6 @@ namespace Reflex
|
|
1121
1076
|
static bool
|
1122
1077
|
use_cache (View* view)
|
1123
1078
|
{
|
1124
|
-
assert(view);
|
1125
1079
|
View::Data* self = view->self.get();
|
1126
1080
|
|
1127
1081
|
return
|
@@ -1132,7 +1086,7 @@ namespace Reflex
|
|
1132
1086
|
static bool
|
1133
1087
|
reset_cache_image (View* view, const Painter& painter)
|
1134
1088
|
{
|
1135
|
-
assert(
|
1089
|
+
assert(use_cache(view));
|
1136
1090
|
View::Data* self = view->self.get();
|
1137
1091
|
|
1138
1092
|
Image* image = self->pcache_image.get();
|
@@ -1155,8 +1109,6 @@ namespace Reflex
|
|
1155
1109
|
static void
|
1156
1110
|
setup_painter (Painter* painter, const Color& fill, const Color& stroke)
|
1157
1111
|
{
|
1158
|
-
assert(painter);
|
1159
|
-
|
1160
1112
|
painter->set_fill(fill);
|
1161
1113
|
painter->set_stroke(stroke);
|
1162
1114
|
}
|
@@ -1164,11 +1116,7 @@ namespace Reflex
|
|
1164
1116
|
static void
|
1165
1117
|
draw_default_shape (View* view, DrawEvent* event)
|
1166
1118
|
{
|
1167
|
-
|
1168
|
-
|
1169
|
-
Painter* painter = event->painter();
|
1170
|
-
assert(painter);
|
1171
|
-
|
1119
|
+
Painter* painter = event->painter();
|
1172
1120
|
const Style& style = View_get_style(view);
|
1173
1121
|
const Color& back_fill = style.background_fill();
|
1174
1122
|
const Color& back_stroke = style.background_stroke();
|
@@ -1189,8 +1137,6 @@ namespace Reflex
|
|
1189
1137
|
static void
|
1190
1138
|
draw_content (View* view, DrawEvent* event)
|
1191
1139
|
{
|
1192
|
-
assert(view && event && event->painter());
|
1193
|
-
|
1194
1140
|
draw_default_shape(view, event);
|
1195
1141
|
|
1196
1142
|
const Style& style = View_get_style(view);
|
@@ -1211,7 +1157,6 @@ namespace Reflex
|
|
1211
1157
|
draw_view (
|
1212
1158
|
View* view, DrawEvent* event, const Point& offset, const Bounds& clip)
|
1213
1159
|
{
|
1214
|
-
assert(view && event && event->painter());
|
1215
1160
|
View::Data* self = view->self.get();
|
1216
1161
|
|
1217
1162
|
Painter* p = event->painter();
|
@@ -1250,8 +1195,6 @@ namespace Reflex
|
|
1250
1195
|
static void
|
1251
1196
|
draw_view_to_cache (View* view, DrawEvent* event)
|
1252
1197
|
{
|
1253
|
-
assert(view && event && event->painter() && view->self->pcache_image);
|
1254
|
-
|
1255
1198
|
Painter* view_painter = event->painter();
|
1256
1199
|
Painter cache_painter = view->self->pcache_image->painter();
|
1257
1200
|
|
@@ -1267,7 +1210,6 @@ namespace Reflex
|
|
1267
1210
|
static bool
|
1268
1211
|
draw_view_with_cache (View* view, DrawEvent* event, bool redraw)
|
1269
1212
|
{
|
1270
|
-
assert(view && event && event->painter());
|
1271
1213
|
View::Data* self = view->self.get();
|
1272
1214
|
|
1273
1215
|
if (!use_cache(view))
|
@@ -1403,8 +1345,6 @@ namespace Reflex
|
|
1403
1345
|
static void
|
1404
1346
|
call_children (View* parent, std::function<bool(View*)> fun, bool sort = true)
|
1405
1347
|
{
|
1406
|
-
assert(parent);
|
1407
|
-
|
1408
1348
|
auto* children = parent->self->children(false, sort);
|
1409
1349
|
if (!children) return;
|
1410
1350
|
|
@@ -1418,8 +1358,6 @@ namespace Reflex
|
|
1418
1358
|
static void
|
1419
1359
|
call_pointer_events_for_each_child (View* parent, PointerEvent* event)
|
1420
1360
|
{
|
1421
|
-
assert(parent && event);
|
1422
|
-
|
1423
1361
|
call_children(parent, [&](View* child) {
|
1424
1362
|
PointerEvent e = event->dup();
|
1425
1363
|
PointerEvent_update_for_child_view(&e, child);
|
@@ -1431,8 +1369,6 @@ namespace Reflex
|
|
1431
1369
|
static void
|
1432
1370
|
call_pointer_events (View* view, PointerEvent* event)
|
1433
1371
|
{
|
1434
|
-
assert(view && event);
|
1435
|
-
|
1436
1372
|
if (view->self->pbody)
|
1437
1373
|
view->self->pbody->awake();
|
1438
1374
|
|
@@ -1454,8 +1390,6 @@ namespace Reflex
|
|
1454
1390
|
static void
|
1455
1391
|
register_captures (View* view, const PointerEvent& event)
|
1456
1392
|
{
|
1457
|
-
assert(view);
|
1458
|
-
|
1459
1393
|
Window* win = view->window();
|
1460
1394
|
if (!win)
|
1461
1395
|
invalid_state_error(__FILE__, __LINE__);
|
@@ -1470,8 +1404,6 @@ namespace Reflex
|
|
1470
1404
|
static void
|
1471
1405
|
unregister_captures (View* view, const PointerEvent& event)
|
1472
1406
|
{
|
1473
|
-
assert(view);
|
1474
|
-
|
1475
1407
|
Window* win = view->window();
|
1476
1408
|
if (!win)
|
1477
1409
|
invalid_state_error(__FILE__, __LINE__);
|
@@ -1666,7 +1598,6 @@ namespace Reflex
|
|
1666
1598
|
static void
|
1667
1599
|
get_from_parent_matrix (Matrix* m, const View* view)
|
1668
1600
|
{
|
1669
|
-
assert(m && view);
|
1670
1601
|
View::Data* self = view->self.get();
|
1671
1602
|
|
1672
1603
|
const auto& frame = self->frame;
|
@@ -1689,7 +1620,6 @@ namespace Reflex
|
|
1689
1620
|
static void
|
1690
1621
|
get_to_parent_matrix (Matrix* m, const View* view)
|
1691
1622
|
{
|
1692
|
-
assert(m && view);
|
1693
1623
|
View::Data* self = view->self.get();
|
1694
1624
|
|
1695
1625
|
const auto& frame = self->frame;
|
@@ -1778,7 +1708,6 @@ namespace Reflex
|
|
1778
1708
|
static void
|
1779
1709
|
set_parent (View* view, View* parent)
|
1780
1710
|
{
|
1781
|
-
assert(view);
|
1782
1711
|
View::Data* self = view->self.get();
|
1783
1712
|
|
1784
1713
|
if (parent == self->parent) return;
|
@@ -1790,8 +1719,6 @@ namespace Reflex
|
|
1790
1719
|
static void
|
1791
1720
|
erase_child_from_children (View* parent, View* child)
|
1792
1721
|
{
|
1793
|
-
assert(parent && child);
|
1794
|
-
|
1795
1722
|
View::ChildList* children = parent->self->children();
|
1796
1723
|
if (!children) return;
|
1797
1724
|
|
@@ -1918,8 +1845,6 @@ namespace Reflex
|
|
1918
1845
|
static Style*
|
1919
1846
|
add_view_style (View* view, Style style)
|
1920
1847
|
{
|
1921
|
-
assert(view);
|
1922
|
-
|
1923
1848
|
if (!Style_set_owner(&style, view))
|
1924
1849
|
return NULL;
|
1925
1850
|
|
data/src/window.cpp
CHANGED
@@ -223,6 +223,109 @@ namespace Reflex
|
|
223
223
|
cleanup_captures(window);
|
224
224
|
}
|
225
225
|
|
226
|
+
static Pointer::ID
|
227
|
+
get_next_pointer_id (Window* window)
|
228
|
+
{
|
229
|
+
return window->self->next_pointer_id++;
|
230
|
+
}
|
231
|
+
|
232
|
+
static void
|
233
|
+
setup_mouse_pointer (Window* window, Pointer* pointer)
|
234
|
+
{
|
235
|
+
static const uint MOUSE_BUTTONS =
|
236
|
+
Pointer::MOUSE_LEFT |
|
237
|
+
Pointer::MOUSE_RIGHT |
|
238
|
+
Pointer::MOUSE_MIDDLE;
|
239
|
+
|
240
|
+
Window::Data* self = window->self.get();
|
241
|
+
|
242
|
+
auto action = pointer->action();
|
243
|
+
auto& prev_pointer = self->prev_mouse_pointer;
|
244
|
+
|
245
|
+
auto id = prev_pointer ? prev_pointer.id() : get_next_pointer_id(window);
|
246
|
+
auto* down = prev_pointer.down();
|
247
|
+
if (
|
248
|
+
Pointer_mask_flag(prev_pointer, MOUSE_BUTTONS) == 0 &&
|
249
|
+
(action == Pointer::DOWN || prev_pointer.action() == Pointer::UP))
|
250
|
+
{
|
251
|
+
id = get_next_pointer_id(window);
|
252
|
+
down = NULL;
|
253
|
+
}
|
254
|
+
|
255
|
+
Pointer_set_id(pointer, id);
|
256
|
+
Pointer_add_flag(pointer, Pointer_mask_flag(prev_pointer, MOUSE_BUTTONS));
|
257
|
+
Pointer_set_prev(pointer, &prev_pointer);
|
258
|
+
Pointer_set_down(pointer, down);
|
259
|
+
|
260
|
+
if (action == Pointer::DOWN)
|
261
|
+
Pointer_add_flag(pointer, pointer->types() & MOUSE_BUTTONS);
|
262
|
+
|
263
|
+
prev_pointer = *pointer;
|
264
|
+
Pointer_set_prev(&prev_pointer, NULL);
|
265
|
+
|
266
|
+
if (action == Pointer::UP || action == Pointer::CANCEL)
|
267
|
+
Pointer_remove_flag(&prev_pointer, prev_pointer.types() & MOUSE_BUTTONS);
|
268
|
+
}
|
269
|
+
|
270
|
+
static PointerList::const_iterator
|
271
|
+
find_prev_pointer (const Pointer& pointer, const PointerList& prev_pointers)
|
272
|
+
{
|
273
|
+
const auto* sys_id = Pointer_get_system_id(pointer);
|
274
|
+
const auto* prev_pos = Pointer_get_prev_position(pointer);
|
275
|
+
|
276
|
+
return std::find_if(
|
277
|
+
prev_pointers.begin(), prev_pointers.end(),
|
278
|
+
[&](const Pointer& p)
|
279
|
+
{
|
280
|
+
if (sys_id)
|
281
|
+
{
|
282
|
+
const auto* id = Pointer_get_system_id(p);
|
283
|
+
if (id && *id == *sys_id) return true;
|
284
|
+
}
|
285
|
+
return prev_pos && *prev_pos == p.position();
|
286
|
+
});
|
287
|
+
}
|
288
|
+
|
289
|
+
static void
|
290
|
+
setup_pointer (Window* window, Pointer* pointer)
|
291
|
+
{
|
292
|
+
Window::Data* self = window->self.get();
|
293
|
+
|
294
|
+
PointerList& prev_pointers = self->prev_pointers;
|
295
|
+
auto it = find_prev_pointer(*pointer, prev_pointers);
|
296
|
+
const Pointer* prev_pointer = it != prev_pointers.end() && *it ? &*it : NULL;
|
297
|
+
|
298
|
+
if (prev_pointer)
|
299
|
+
{
|
300
|
+
Pointer_set_id(pointer, prev_pointer->id());
|
301
|
+
Pointer_set_prev(pointer, prev_pointer);
|
302
|
+
Pointer_set_down(pointer, prev_pointer->down());
|
303
|
+
prev_pointers.erase(it);
|
304
|
+
}
|
305
|
+
else
|
306
|
+
Pointer_set_id(pointer, get_next_pointer_id(window));
|
307
|
+
|
308
|
+
auto action = pointer->action();
|
309
|
+
if (action != Pointer::UP && action != Pointer::CANCEL)
|
310
|
+
{
|
311
|
+
prev_pointers.emplace_back(*pointer);
|
312
|
+
Pointer_set_prev(&prev_pointers.back(), NULL);
|
313
|
+
}
|
314
|
+
}
|
315
|
+
|
316
|
+
static void
|
317
|
+
setup_pointer_event (Window* window, PointerEvent* event)
|
318
|
+
{
|
319
|
+
for (size_t i = 0; i < event->size(); ++i)
|
320
|
+
{
|
321
|
+
Pointer& pointer = PointerEvent_pointer_at(event, i);
|
322
|
+
if (pointer.types() & Pointer::MOUSE)
|
323
|
+
setup_mouse_pointer(window, &pointer);
|
324
|
+
else
|
325
|
+
setup_pointer(window, &pointer);
|
326
|
+
}
|
327
|
+
}
|
328
|
+
|
226
329
|
static void
|
227
330
|
get_views_capturing_all_pointers (Window* window, ViewList* result)
|
228
331
|
{
|
@@ -395,6 +498,8 @@ namespace Reflex
|
|
395
498
|
if (!event)
|
396
499
|
argument_error(__FILE__, __LINE__);
|
397
500
|
|
501
|
+
setup_pointer_event(window, event);
|
502
|
+
|
398
503
|
window->on_pointer(event);
|
399
504
|
|
400
505
|
switch ((*event)[0].action())
|