reflexion 0.3 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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/ChangeLog.md +12 -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 +10 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f0787ee344f23edde4f87bfb7d5d129a30bbc8ce0723bcf4d0da918196bfbc9f
|
4
|
+
data.tar.gz: 6153596e926fce9e12d27a843871e12025d39722a27f8d473811426a69285464
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6f0f485cab308f5246c44ee0e12c55541ccc7c0247403b6e1bcc676946ab1a9be2260d7d28316a8c12c4630230168ee1b9c93b1a1f398b828b93ead6acc8e8e3
|
7
|
+
data.tar.gz: a39e8b85065a9eacb9bb36db287066f9e53ab5e40f47e9f05d67915dfdea4296120aa8a81953104926440448432642ae0ac763688d53ac0b47792e5cd3153e78
|
data/.doc/ext/reflex/pointer.cpp
CHANGED
@@ -20,7 +20,7 @@ VALUE alloc(VALUE klass)
|
|
20
20
|
|
21
21
|
static
|
22
22
|
VALUE initialize(VALUE self, VALUE
|
23
|
-
id, VALUE types, VALUE action, VALUE position, VALUE modifiers, VALUE
|
23
|
+
id, VALUE types, VALUE action, VALUE position, VALUE modifiers, VALUE click_count, VALUE drag, VALUE time)
|
24
24
|
{
|
25
25
|
CHECK;
|
26
26
|
|
@@ -30,9 +30,8 @@ VALUE initialize(VALUE self, VALUE
|
|
30
30
|
(Reflex::Pointer::Action) to<int>(action),
|
31
31
|
to<Rays::Point>(position),
|
32
32
|
to<uint>(modifiers),
|
33
|
-
to<bool>(drag),
|
34
33
|
to<uint>(click_count),
|
35
|
-
to<
|
34
|
+
to<bool>(drag),
|
36
35
|
to<double>(time));
|
37
36
|
return self;
|
38
37
|
}
|
@@ -80,13 +79,6 @@ VALUE get_modifiers(VALUE self)
|
|
80
79
|
return value(THIS->modifiers());
|
81
80
|
}
|
82
81
|
|
83
|
-
static
|
84
|
-
VALUE is_drag(VALUE self)
|
85
|
-
{
|
86
|
-
CHECK;
|
87
|
-
return value(THIS->is_drag());
|
88
|
-
}
|
89
|
-
|
90
82
|
static
|
91
83
|
VALUE get_click_count(VALUE self)
|
92
84
|
{
|
@@ -95,10 +87,10 @@ VALUE get_click_count(VALUE self)
|
|
95
87
|
}
|
96
88
|
|
97
89
|
static
|
98
|
-
VALUE
|
90
|
+
VALUE is_drag(VALUE self)
|
99
91
|
{
|
100
92
|
CHECK;
|
101
|
-
return value(THIS->
|
93
|
+
return value(THIS->is_drag());
|
102
94
|
}
|
103
95
|
|
104
96
|
static
|
@@ -132,16 +124,15 @@ Init_reflex_pointer ()
|
|
132
124
|
|
133
125
|
cPointer = rb_define_class_under(mReflex, "Pointer", rb_cObject);
|
134
126
|
rb_define_alloc_func(cPointer, alloc);
|
135
|
-
rb_define_private_method(cPointer, "initialize", RUBY_METHOD_FUNC(initialize),
|
127
|
+
rb_define_private_method(cPointer, "initialize", RUBY_METHOD_FUNC(initialize), 8);
|
136
128
|
rb_define_private_method(cPointer, "initialize_copy", RUBY_METHOD_FUNC(initialize_copy), 1);
|
137
129
|
rb_define_method(cPointer, "id", RUBY_METHOD_FUNC(get_id), 0);
|
138
130
|
rb_define_private_method(cPointer, "get_types", RUBY_METHOD_FUNC(get_types), 0);
|
139
131
|
rb_define_private_method(cPointer, "get_action", RUBY_METHOD_FUNC(get_action), 0);
|
140
132
|
rb_define_method(cPointer, "position", RUBY_METHOD_FUNC(get_position), 0);
|
141
133
|
rb_define_method(cPointer, "modifiers", RUBY_METHOD_FUNC(get_modifiers), 0);
|
142
|
-
cPointer.define_method("drag?", is_drag);
|
143
134
|
rb_define_method(cPointer, "click_count", RUBY_METHOD_FUNC(get_click_count), 0);
|
144
|
-
|
135
|
+
cPointer.define_method("drag?", is_drag);
|
145
136
|
rb_define_method(cPointer, "time", RUBY_METHOD_FUNC(get_time), 0);
|
146
137
|
rb_define_method(cPointer, "prev", RUBY_METHOD_FUNC(get_prev), 0);
|
147
138
|
rb_define_method(cPointer, "down", RUBY_METHOD_FUNC(get_down), 0);
|
data/.doc/ext/reflex/view.cpp
CHANGED
@@ -272,7 +272,7 @@ to_shape (Value value)
|
|
272
272
|
if (value.is_nil())
|
273
273
|
return NULL;
|
274
274
|
|
275
|
-
if (value.
|
275
|
+
if (value.is_a(Rays::polygon_class()))
|
276
276
|
{
|
277
277
|
Reflex::PolygonShape* shape = new Reflex::PolygonShape();
|
278
278
|
shape->set_polygon(to<Rays::Polygon&>(value));
|
@@ -409,7 +409,7 @@ VALUE set_pivot(VALUE self)
|
|
409
409
|
{
|
410
410
|
CHECK;
|
411
411
|
|
412
|
-
if (argv[0].
|
412
|
+
if (argv[0].is_a(Rays::point_class()))
|
413
413
|
{
|
414
414
|
check_arg_count(__FILE__, __LINE__, "View#pivot=(Point)", argc, 1);
|
415
415
|
|
@@ -446,7 +446,7 @@ VALUE scroll_to(VALUE self)
|
|
446
446
|
{
|
447
447
|
CHECK;
|
448
448
|
|
449
|
-
if (argv[0].
|
449
|
+
if (argv[0].is_a(Rays::point_class()))
|
450
450
|
{
|
451
451
|
check_arg_count(__FILE__, __LINE__, "View#scroll_to(Point)", argc, 1);
|
452
452
|
|
@@ -476,7 +476,7 @@ VALUE scroll_by(VALUE self)
|
|
476
476
|
{
|
477
477
|
CHECK;
|
478
478
|
|
479
|
-
if (argv[0].
|
479
|
+
if (argv[0].is_a(Rays::point_class()))
|
480
480
|
{
|
481
481
|
check_arg_count(__FILE__, __LINE__, "View#scroll_by", argc, 1);
|
482
482
|
|
@@ -819,13 +819,20 @@ VALUE get_gravity_scale(VALUE self)
|
|
819
819
|
}
|
820
820
|
|
821
821
|
static
|
822
|
-
VALUE
|
822
|
+
VALUE create_world(VALUE self, VALUE pixels_per_meter)
|
823
823
|
{
|
824
824
|
CHECK;
|
825
|
-
|
825
|
+
THIS->create_world(to<float>(pixels_per_meter));
|
826
|
+
}
|
827
|
+
|
828
|
+
static
|
829
|
+
VALUE update_world(VALUE self)
|
830
|
+
{
|
831
|
+
CHECK;
|
832
|
+
check_arg_count(__FILE__, __LINE__, "View#update_world", argc, 0, 1);
|
826
833
|
|
827
834
|
float duration = argc >= 1 ? to<float>(argv[0]) : 0;
|
828
|
-
THIS->
|
835
|
+
THIS->update_world(duration);
|
829
836
|
return self;
|
830
837
|
}
|
831
838
|
|
@@ -1182,7 +1189,8 @@ Init_reflex_view ()
|
|
1182
1189
|
rb_define_method(cView, "gravity_scale=", RUBY_METHOD_FUNC(set_gravity_scale), 1);
|
1183
1190
|
rb_define_method(cView, "gravity_scale", RUBY_METHOD_FUNC(get_gravity_scale), 0);
|
1184
1191
|
|
1185
|
-
rb_define_method(cView, "
|
1192
|
+
rb_define_method(cView, "create_world", RUBY_METHOD_FUNC(create_world), 1);
|
1193
|
+
rb_define_method(cView, "update_world", RUBY_METHOD_FUNC(update_world), -1);
|
1186
1194
|
rb_define_method(cView, "meter2pixel", RUBY_METHOD_FUNC(meter2pixel), -1);
|
1187
1195
|
rb_define_method(cView, "gravity=", RUBY_METHOD_FUNC(set_gravity), -1);
|
1188
1196
|
rb_define_method(cView, "gravity", RUBY_METHOD_FUNC(get_gravity), 0);
|
data/ChangeLog.md
CHANGED
@@ -1,6 +1,18 @@
|
|
1
1
|
# reflex ChangeLog
|
2
2
|
|
3
3
|
|
4
|
+
## [v0.3.1] - 2025-01-13
|
5
|
+
|
6
|
+
- Add View#create_world(pixels_per_meter)
|
7
|
+
- Rename View#update_physics to View#update_world
|
8
|
+
- Delete Pointer#view_index
|
9
|
+
- Update LICENSE
|
10
|
+
|
11
|
+
- Fix crash in unregister_captures() called immediately after deleting a view
|
12
|
+
- Fix that incorrect determination whether the pointer is in a view or not
|
13
|
+
- Fix a bug that caused some pointer events to be ignored in zoomed views
|
14
|
+
|
15
|
+
|
4
16
|
## [v0.3] - 2024-07-06
|
5
17
|
|
6
18
|
- Support Windows
|
data/Gemfile.lock
CHANGED
data/LICENSE
CHANGED
data/Rakefile
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3
|
1
|
+
0.3.1
|
data/ext/reflex/pointer.cpp
CHANGED
@@ -20,8 +20,8 @@ RUCY_DEF_ALLOC(alloc, klass)
|
|
20
20
|
RUCY_END
|
21
21
|
|
22
22
|
static
|
23
|
-
|
24
|
-
id, types, action, position, modifiers,
|
23
|
+
RUCY_DEF8(initialize,
|
24
|
+
id, types, action, position, modifiers, click_count, drag, time)
|
25
25
|
{
|
26
26
|
CHECK;
|
27
27
|
|
@@ -31,9 +31,8 @@ RUCY_DEF9(initialize,
|
|
31
31
|
(Reflex::Pointer::Action) to<int>(action),
|
32
32
|
to<Rays::Point>(position),
|
33
33
|
to<uint>(modifiers),
|
34
|
-
to<bool>(drag),
|
35
34
|
to<uint>(click_count),
|
36
|
-
to<
|
35
|
+
to<bool>(drag),
|
37
36
|
to<double>(time));
|
38
37
|
return self;
|
39
38
|
}
|
@@ -88,14 +87,6 @@ RUCY_DEF0(get_modifiers)
|
|
88
87
|
}
|
89
88
|
RUCY_END
|
90
89
|
|
91
|
-
static
|
92
|
-
RUCY_DEF0(is_drag)
|
93
|
-
{
|
94
|
-
CHECK;
|
95
|
-
return value(THIS->is_drag());
|
96
|
-
}
|
97
|
-
RUCY_END
|
98
|
-
|
99
90
|
static
|
100
91
|
RUCY_DEF0(get_click_count)
|
101
92
|
{
|
@@ -105,10 +96,10 @@ RUCY_DEF0(get_click_count)
|
|
105
96
|
RUCY_END
|
106
97
|
|
107
98
|
static
|
108
|
-
RUCY_DEF0(
|
99
|
+
RUCY_DEF0(is_drag)
|
109
100
|
{
|
110
101
|
CHECK;
|
111
|
-
return value(THIS->
|
102
|
+
return value(THIS->is_drag());
|
112
103
|
}
|
113
104
|
RUCY_END
|
114
105
|
|
@@ -153,9 +144,8 @@ Init_reflex_pointer ()
|
|
153
144
|
cPointer.define_private_method("get_action", get_action);
|
154
145
|
cPointer.define_method("position", get_position);
|
155
146
|
cPointer.define_method("modifiers", get_modifiers);
|
156
|
-
cPointer.define_method("drag?", is_drag);
|
157
147
|
cPointer.define_method("click_count", get_click_count);
|
158
|
-
cPointer.define_method("
|
148
|
+
cPointer.define_method("drag?", is_drag);
|
159
149
|
cPointer.define_method("time", get_time);
|
160
150
|
cPointer.define_method("prev", get_prev);
|
161
151
|
cPointer.define_method("down", get_down);
|
data/ext/reflex/style_length.cpp
CHANGED
data/ext/reflex/view.cpp
CHANGED
@@ -298,7 +298,7 @@ to_shape (Value value)
|
|
298
298
|
if (value.is_nil())
|
299
299
|
return NULL;
|
300
300
|
|
301
|
-
if (value.
|
301
|
+
if (value.is_a(Rays::polygon_class()))
|
302
302
|
{
|
303
303
|
Reflex::PolygonShape* shape = new Reflex::PolygonShape();
|
304
304
|
shape->set_polygon(to<Rays::Polygon&>(value));
|
@@ -450,7 +450,7 @@ RUCY_DEFN(set_pivot)
|
|
450
450
|
{
|
451
451
|
CHECK;
|
452
452
|
|
453
|
-
if (argv[0].
|
453
|
+
if (argv[0].is_a(Rays::point_class()))
|
454
454
|
{
|
455
455
|
check_arg_count(__FILE__, __LINE__, "View#pivot=(Point)", argc, 1);
|
456
456
|
|
@@ -489,7 +489,7 @@ RUCY_DEFN(scroll_to)
|
|
489
489
|
{
|
490
490
|
CHECK;
|
491
491
|
|
492
|
-
if (argv[0].
|
492
|
+
if (argv[0].is_a(Rays::point_class()))
|
493
493
|
{
|
494
494
|
check_arg_count(__FILE__, __LINE__, "View#scroll_to(Point)", argc, 1);
|
495
495
|
|
@@ -520,7 +520,7 @@ RUCY_DEFN(scroll_by)
|
|
520
520
|
{
|
521
521
|
CHECK;
|
522
522
|
|
523
|
-
if (argv[0].
|
523
|
+
if (argv[0].is_a(Rays::point_class()))
|
524
524
|
{
|
525
525
|
check_arg_count(__FILE__, __LINE__, "View#scroll_by", argc, 1);
|
526
526
|
|
@@ -903,13 +903,21 @@ RUCY_DEF0(get_gravity_scale)
|
|
903
903
|
RUCY_END
|
904
904
|
|
905
905
|
static
|
906
|
-
|
906
|
+
RUCY_DEF1(create_world, pixels_per_meter)
|
907
907
|
{
|
908
908
|
CHECK;
|
909
|
-
|
909
|
+
THIS->create_world(to<float>(pixels_per_meter));
|
910
|
+
}
|
911
|
+
RUCY_END
|
912
|
+
|
913
|
+
static
|
914
|
+
RUCY_DEFN(update_world)
|
915
|
+
{
|
916
|
+
CHECK;
|
917
|
+
check_arg_count(__FILE__, __LINE__, "View#update_world", argc, 0, 1);
|
910
918
|
|
911
919
|
float duration = argc >= 1 ? to<float>(argv[0]) : 0;
|
912
|
-
THIS->
|
920
|
+
THIS->update_world(duration);
|
913
921
|
return self;
|
914
922
|
}
|
915
923
|
RUCY_END
|
@@ -1302,7 +1310,8 @@ Init_reflex_view ()
|
|
1302
1310
|
cView.define_method("gravity_scale=", set_gravity_scale);
|
1303
1311
|
cView.define_method("gravity_scale", get_gravity_scale);
|
1304
1312
|
|
1305
|
-
cView.define_method("
|
1313
|
+
cView.define_method("create_world", create_world);
|
1314
|
+
cView.define_method("update_world", update_world);
|
1306
1315
|
cView.define_method("meter2pixel", meter2pixel);
|
1307
1316
|
cView.define_method("gravity=", set_gravity);
|
1308
1317
|
cView.define_method("gravity", get_gravity);
|
data/include/reflex/pointer.h
CHANGED
@@ -65,8 +65,8 @@ namespace Reflex
|
|
65
65
|
|
66
66
|
Pointer (
|
67
67
|
ID id, uint types, Action action,
|
68
|
-
const Point& position, uint modifiers, bool drag,
|
69
|
-
|
68
|
+
const Point& position, uint modifiers, uint click_count, bool drag,
|
69
|
+
double time);
|
70
70
|
|
71
71
|
Pointer (const This& obj);
|
72
72
|
|
@@ -84,11 +84,9 @@ namespace Reflex
|
|
84
84
|
|
85
85
|
uint modifiers () const;
|
86
86
|
|
87
|
-
bool is_drag () const;
|
88
|
-
|
89
87
|
uint click_count () const;
|
90
88
|
|
91
|
-
|
89
|
+
bool is_drag () const;
|
92
90
|
|
93
91
|
double time () const;
|
94
92
|
|
data/include/reflex/ruby/timer.h
CHANGED
data/include/reflex/view.h
CHANGED
@@ -309,7 +309,9 @@ namespace Reflex
|
|
309
309
|
//
|
310
310
|
// for physics child world
|
311
311
|
//
|
312
|
-
virtual void
|
312
|
+
virtual void create_world (float pixels_per_meter);
|
313
|
+
|
314
|
+
virtual void update_world (float duration = 0);
|
313
315
|
|
314
316
|
virtual float meter2pixel (float meter = 1, bool create_world = true);
|
315
317
|
|
data/lib/reflex/pointer.rb
CHANGED
@@ -95,7 +95,7 @@ module Reflex
|
|
95
95
|
end
|
96
96
|
|
97
97
|
def inspect()
|
98
|
-
"#<Reflex::Pointer id:#{id} #{types} #{action} (#{x.round 2}, #{y.round 2}) mod:#{modifiers}
|
98
|
+
"#<Reflex::Pointer id:#{id} #{types} #{action} (#{x.round 2}, #{y.round 2}) mod:#{modifiers} click:#{click_count} drag:#{drag?} time:#{time.round 2}>"
|
99
99
|
end
|
100
100
|
|
101
101
|
end# Pointer
|
data/lib/reflex/pointer_event.rb
CHANGED
@@ -16,7 +16,7 @@ module Reflex
|
|
16
16
|
:types, :mouse?, :touch?, :pen?,
|
17
17
|
:mouse_left?, :left?, :mouse_right?, :right?, :mouse_middle?, :middle?,
|
18
18
|
:action, :down?, :up?, :move?, :cancel?, :stay?,
|
19
|
-
:position, :pos, :x, :y, :modifiers, :
|
19
|
+
:position, :pos, :x, :y, :modifiers, :click_count, :drag?,
|
20
20
|
:time, :prev, :down
|
21
21
|
|
22
22
|
def pointers()
|
@@ -24,7 +24,7 @@ module Reflex
|
|
24
24
|
end
|
25
25
|
|
26
26
|
def inspect()
|
27
|
-
"#<Reflex::PointerEvent id:#{id} #{types} #{action} (#{x.round 2}, #{y.round 2}) mod:#{modifiers}
|
27
|
+
"#<Reflex::PointerEvent id:#{id} #{types} #{action} (#{x.round 2}, #{y.round 2}) mod:#{modifiers} click:#{click_count} drag:#{drag?} time:#{time.round 2}>"
|
28
28
|
end
|
29
29
|
|
30
30
|
end# PointerEvent
|
data/reflex.gemspec
CHANGED
@@ -25,10 +25,10 @@ Gem::Specification.new do |s|
|
|
25
25
|
s.platform = Gem::Platform::RUBY
|
26
26
|
s.required_ruby_version = '>= 3.0.0'
|
27
27
|
|
28
|
-
s.add_runtime_dependency 'xot', '~> 0.3'
|
29
|
-
s.add_runtime_dependency 'rucy', '~> 0.3'
|
30
|
-
s.add_runtime_dependency 'beeps', '~> 0.3'
|
31
|
-
s.add_runtime_dependency 'rays', '~> 0.3'
|
28
|
+
s.add_runtime_dependency 'xot', '~> 0.3.1'
|
29
|
+
s.add_runtime_dependency 'rucy', '~> 0.3.1'
|
30
|
+
s.add_runtime_dependency 'beeps', '~> 0.3.1'
|
31
|
+
s.add_runtime_dependency 'rays', '~> 0.3.1'
|
32
32
|
|
33
33
|
s.files = `git ls-files`.split $/
|
34
34
|
s.executables = s.files.grep(%r{^bin/}) {|f| File.basename f}
|
data/src/body.cpp
CHANGED
@@ -284,24 +284,30 @@ namespace Reflex
|
|
284
284
|
void
|
285
285
|
Body_copy_attributes (Body* to, const Body& from)
|
286
286
|
{
|
287
|
-
if (!to)
|
288
|
-
return;
|
289
|
-
|
290
|
-
if (to->self->ppm != from.self->ppm)
|
291
|
-
physics_error(__FILE__, __LINE__);
|
287
|
+
if (!to) return;
|
292
288
|
|
293
289
|
b2Body* b2to = Body_get_b2ptr(to);
|
294
290
|
const b2Body* b2from = Body_get_b2ptr(&from);
|
295
291
|
assert(b2to && b2from);
|
296
292
|
|
297
293
|
b2to->SetType( b2from->GetType());
|
298
|
-
b2to->SetTransform( b2from->GetPosition(), b2from->GetAngle());
|
299
294
|
b2to->SetLinearVelocity( b2from->GetLinearVelocity());
|
300
295
|
b2to->SetAngularVelocity(b2from->GetAngularVelocity());
|
301
296
|
b2to->SetLinearDamping( b2from->GetLinearDamping());
|
302
297
|
b2to->SetAngularDamping( b2from->GetAngularDamping());
|
303
298
|
b2to->SetGravityScale( b2from->GetGravityScale());
|
304
299
|
b2to->SetBullet( b2from->IsBullet());
|
300
|
+
|
301
|
+
float ppm_to = to->self->ppm;
|
302
|
+
float ppm_from = from.self->ppm;
|
303
|
+
if (ppm_to == ppm_from)
|
304
|
+
b2to->SetTransform(b2from->GetPosition(), b2from->GetAngle());
|
305
|
+
else
|
306
|
+
{
|
307
|
+
auto pos = b2from->GetPosition();
|
308
|
+
pos *= ppm_from / ppm_to;
|
309
|
+
b2to->SetTransform(pos, b2from->GetAngle());
|
310
|
+
}
|
305
311
|
}
|
306
312
|
|
307
313
|
Body*
|
data/src/event.cpp
CHANGED
@@ -592,28 +592,16 @@ namespace Reflex
|
|
592
592
|
{
|
593
593
|
}
|
594
594
|
|
595
|
-
void increment_view_indices ()
|
596
|
-
{
|
597
|
-
for (auto& pointer : pointers)
|
598
|
-
Pointer_set_view_index(&pointer, pointer.view_index() + 1);
|
599
|
-
|
600
|
-
if (parent) parent->increment_view_indices();
|
601
|
-
}
|
602
|
-
|
603
595
|
};// PointerEvent::Data
|
604
596
|
|
605
597
|
|
606
598
|
void
|
607
|
-
PointerEvent_add_pointer (
|
608
|
-
PointerEvent* pthis, const Pointer& pointer,
|
609
|
-
std::function<void(Pointer*)> fun)
|
599
|
+
PointerEvent_add_pointer (PointerEvent* pthis, const Pointer& pointer)
|
610
600
|
{
|
611
601
|
if (!pthis)
|
612
602
|
argument_error(__FILE__, __LINE__);
|
613
603
|
|
614
604
|
pthis->self->pointers.emplace_back(pointer);
|
615
|
-
|
616
|
-
if (fun) fun(&pthis->self->pointers.back());
|
617
605
|
}
|
618
606
|
|
619
607
|
void
|
@@ -659,15 +647,6 @@ namespace Reflex
|
|
659
647
|
fun(pointer);
|
660
648
|
}
|
661
649
|
|
662
|
-
void
|
663
|
-
PointerEvent_increment_view_indices (PointerEvent* pthis)
|
664
|
-
{
|
665
|
-
if (!pthis)
|
666
|
-
argument_error(__FILE__, __LINE__);
|
667
|
-
|
668
|
-
pthis->self->increment_view_indices();
|
669
|
-
}
|
670
|
-
|
671
650
|
void
|
672
651
|
PointerEvent_set_captured (PointerEvent* pthis, bool captured)
|
673
652
|
{
|
@@ -680,23 +659,24 @@ namespace Reflex
|
|
680
659
|
void
|
681
660
|
PointerEvent_update_for_child_view (PointerEvent* pthis, const View* child)
|
682
661
|
{
|
683
|
-
if (!pthis
|
662
|
+
if (!pthis)
|
663
|
+
argument_error(__FILE__, __LINE__);
|
664
|
+
if (!child)
|
684
665
|
argument_error(__FILE__, __LINE__);
|
685
666
|
|
686
667
|
const Bounds& frame = child->frame();
|
687
|
-
Bounds bounds = frame.dup().move_to(0, 0);
|
688
668
|
|
689
669
|
std::vector<Pointer> pointers;
|
690
670
|
for (const auto& pointer : pthis->self->pointers)
|
691
671
|
{
|
672
|
+
if (!frame.is_include(pointer.position()))
|
673
|
+
continue;
|
674
|
+
|
692
675
|
pointers.emplace_back(pointer);
|
693
676
|
Pointer_update_positions(&pointers.back(), [&](Point* pos)
|
694
677
|
{
|
695
678
|
*pos = child->from_parent(*pos);
|
696
679
|
});
|
697
|
-
|
698
|
-
if (!bounds.is_include(pointers.back().position()))
|
699
|
-
pointers.pop_back();
|
700
680
|
}
|
701
681
|
pthis->self->pointers = pointers;
|
702
682
|
}
|
@@ -704,7 +684,9 @@ namespace Reflex
|
|
704
684
|
void
|
705
685
|
PointerEvent_update_for_capturing_view (PointerEvent* pthis, const View* view)
|
706
686
|
{
|
707
|
-
if (!pthis
|
687
|
+
if (!pthis)
|
688
|
+
argument_error(__FILE__, __LINE__);
|
689
|
+
if (!view)
|
708
690
|
argument_error(__FILE__, __LINE__);
|
709
691
|
|
710
692
|
for (auto& pointer : pthis->self->pointers)
|
data/src/event.h
CHANGED
@@ -24,9 +24,7 @@ namespace Reflex
|
|
24
24
|
void KeyEvent_set_captured (KeyEvent* pthis, bool captured);
|
25
25
|
|
26
26
|
|
27
|
-
void PointerEvent_add_pointer (
|
28
|
-
PointerEvent* pthis, const Pointer& pointer,
|
29
|
-
std::function<void(Pointer*)> fun = NULL);
|
27
|
+
void PointerEvent_add_pointer (PointerEvent* pthis, const Pointer& pointer);
|
30
28
|
|
31
29
|
void PointerEvent_erase_pointer (PointerEvent* pthis, Pointer::ID id);
|
32
30
|
|
data/src/filter.cpp
CHANGED
data/src/ios/event.mm
CHANGED
data/src/osx/application.mm
CHANGED
@@ -4,6 +4,7 @@
|
|
4
4
|
|
5
5
|
#import <AppKit/NSApplication.h>
|
6
6
|
#include "reflex/exception.h"
|
7
|
+
#include "reflex/debug.h"
|
7
8
|
#import "app_delegate.h"
|
8
9
|
|
9
10
|
|
@@ -42,11 +43,11 @@ namespace Reflex
|
|
42
43
|
static ReflexAppDelegate*
|
43
44
|
setup_app_delegate (NSApplication* app)
|
44
45
|
{
|
45
|
-
id<NSApplicationDelegate> delegate =
|
46
|
+
id<NSApplicationDelegate> delegate = app.delegate;
|
46
47
|
if (!delegate)
|
47
48
|
{
|
48
|
-
delegate
|
49
|
-
|
49
|
+
delegate = [[[ReflexAppDelegate alloc] init] autorelease];
|
50
|
+
app.delegate = delegate;
|
50
51
|
}
|
51
52
|
|
52
53
|
if (![delegate isKindOfClass: ReflexAppDelegate.class])
|
@@ -58,11 +59,11 @@ namespace Reflex
|
|
58
59
|
void
|
59
60
|
Application::start ()
|
60
61
|
{
|
61
|
-
NSApplication* app =
|
62
|
+
NSApplication* app = NSApplication.sharedApplication;
|
62
63
|
ReflexAppDelegate* delegate = setup_app_delegate(app);
|
63
64
|
[delegate bind: this];
|
64
65
|
|
65
|
-
if (!
|
66
|
+
if (!app.isRunning)
|
66
67
|
[app run];
|
67
68
|
else
|
68
69
|
[delegate callOnStart];
|
data/src/osx/event.mm
CHANGED