reflexion 0.1.44 → 0.1.45
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 +13 -5
- data/ChangeLog.md +7 -0
- data/VERSION +1 -1
- data/ext/reflex/pointer.cpp +14 -5
- data/include/reflex/pointer.h +6 -2
- data/lib/reflex/pointer.rb +7 -7
- data/lib/reflex/pointer_event.rb +3 -7
- data/reflex.gemspec +4 -4
- data/src/ios/event.mm +16 -10
- data/src/ios/view_controller.mm +3 -0
- data/src/osx/native_window.mm +40 -29
- data/src/pointer.cpp +53 -26
- data/src/pointer.h +12 -5
- data/test/test_pointer.rb +6 -5
- 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: 341401b7f3ada1fc9bcaca9dcd65829a010f6055afa95b67fad2c23230cfa741
|
4
|
+
data.tar.gz: b7955057b7f3fcc7a1047f16b1df64cb92015cb8c7c9e7aadee9e59c5906dee5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5090da288b1f24bc631490edcde601d5bff64e276b0fc4dda56c1f68f75b0595e3c8330ca4f98f4c9de49ef2ce476413548cc09b1a768fb3bbc707bc1fec38fb
|
7
|
+
data.tar.gz: 5b5810a8dfe254e4e35a5d15df365d46c72b1d84f844562672044cfd50f2644bcd18221f1fb116390a32ed238962e5fa3a777807293127e1d3a41d315b6fae35
|
data/.doc/ext/reflex/pointer.cpp
CHANGED
@@ -20,13 +20,13 @@ VALUE alloc(VALUE klass)
|
|
20
20
|
|
21
21
|
static
|
22
22
|
VALUE initialize(VALUE self, VALUE
|
23
|
-
id, VALUE
|
23
|
+
id, VALUE types, VALUE action, VALUE position, VALUE modifiers, VALUE drag, VALUE click_count, VALUE view_index, VALUE time)
|
24
24
|
{
|
25
25
|
CHECK;
|
26
26
|
|
27
27
|
*THIS = Reflex::Pointer(
|
28
28
|
to<Reflex::Pointer::ID>(id),
|
29
|
-
to<uint>(
|
29
|
+
to<uint>(types),
|
30
30
|
(Reflex::Pointer::Action) to<int>(action),
|
31
31
|
to<Rays::Point>(position),
|
32
32
|
to<uint>(modifiers),
|
@@ -53,10 +53,10 @@ VALUE get_id(VALUE self)
|
|
53
53
|
}
|
54
54
|
|
55
55
|
static
|
56
|
-
VALUE
|
56
|
+
VALUE get_types(VALUE self)
|
57
57
|
{
|
58
58
|
CHECK;
|
59
|
-
return value(THIS->
|
59
|
+
return value(THIS->types());
|
60
60
|
}
|
61
61
|
|
62
62
|
static
|
@@ -115,6 +115,13 @@ VALUE get_prev(VALUE self)
|
|
115
115
|
return value(THIS->prev());
|
116
116
|
}
|
117
117
|
|
118
|
+
static
|
119
|
+
VALUE get_down(VALUE self)
|
120
|
+
{
|
121
|
+
CHECK;
|
122
|
+
return value(THIS->down());
|
123
|
+
}
|
124
|
+
|
118
125
|
|
119
126
|
static Class cPointer;
|
120
127
|
|
@@ -128,7 +135,7 @@ Init_reflex_pointer ()
|
|
128
135
|
rb_define_private_method(cPointer, "initialize", RUBY_METHOD_FUNC(initialize), 9);
|
129
136
|
rb_define_private_method(cPointer, "initialize_copy", RUBY_METHOD_FUNC(initialize_copy), 1);
|
130
137
|
rb_define_method(cPointer, "id", RUBY_METHOD_FUNC(get_id), 0);
|
131
|
-
rb_define_private_method(cPointer, "
|
138
|
+
rb_define_private_method(cPointer, "get_types", RUBY_METHOD_FUNC(get_types), 0);
|
132
139
|
rb_define_private_method(cPointer, "get_action", RUBY_METHOD_FUNC(get_action), 0);
|
133
140
|
rb_define_method(cPointer, "position", RUBY_METHOD_FUNC(get_position), 0);
|
134
141
|
rb_define_method(cPointer, "modifiers", RUBY_METHOD_FUNC(get_modifiers), 0);
|
@@ -137,6 +144,7 @@ Init_reflex_pointer ()
|
|
137
144
|
rb_define_method(cPointer, "view_index", RUBY_METHOD_FUNC(get_view_index), 0);
|
138
145
|
rb_define_method(cPointer, "time", RUBY_METHOD_FUNC(get_time), 0);
|
139
146
|
rb_define_method(cPointer, "prev", RUBY_METHOD_FUNC(get_prev), 0);
|
147
|
+
rb_define_method(cPointer, "down", RUBY_METHOD_FUNC(get_down), 0);
|
140
148
|
cPointer.define_const("TYPE_NONE", Reflex::Pointer::TYPE_NONE);
|
141
149
|
cPointer.define_const("MOUSE", Reflex::Pointer::MOUSE);
|
142
150
|
cPointer.define_const("MOUSE_LEFT", Reflex::Pointer::MOUSE_LEFT);
|
data/ChangeLog.md
CHANGED
@@ -1,6 +1,13 @@
|
|
1
1
|
# reflex ChangeLog
|
2
2
|
|
3
3
|
|
4
|
+
## [v0.1.45] - 2023-06-11
|
5
|
+
|
6
|
+
- Add Pointer#down() which saves the first 'pointer_down' pointer
|
7
|
+
- PointerEvent includes Enumerable
|
8
|
+
- Rename Pointer#type to Pointer#types
|
9
|
+
|
10
|
+
|
4
11
|
## [v0.1.44] - 2023-06-08
|
5
12
|
|
6
13
|
- Fix compile error
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.45
|
data/ext/reflex/pointer.cpp
CHANGED
@@ -21,13 +21,13 @@ RUCY_END
|
|
21
21
|
|
22
22
|
static
|
23
23
|
RUCY_DEF9(initialize,
|
24
|
-
id,
|
24
|
+
id, types, action, position, modifiers, drag, click_count, view_index, time)
|
25
25
|
{
|
26
26
|
CHECK;
|
27
27
|
|
28
28
|
*THIS = Reflex::Pointer(
|
29
29
|
to<Reflex::Pointer::ID>(id),
|
30
|
-
to<uint>(
|
30
|
+
to<uint>(types),
|
31
31
|
(Reflex::Pointer::Action) to<int>(action),
|
32
32
|
to<Rays::Point>(position),
|
33
33
|
to<uint>(modifiers),
|
@@ -57,10 +57,10 @@ RUCY_DEF0(get_id)
|
|
57
57
|
RUCY_END
|
58
58
|
|
59
59
|
static
|
60
|
-
RUCY_DEF0(
|
60
|
+
RUCY_DEF0(get_types)
|
61
61
|
{
|
62
62
|
CHECK;
|
63
|
-
return value(THIS->
|
63
|
+
return value(THIS->types());
|
64
64
|
}
|
65
65
|
RUCY_END
|
66
66
|
|
@@ -128,6 +128,14 @@ RUCY_DEF0(get_prev)
|
|
128
128
|
}
|
129
129
|
RUCY_END
|
130
130
|
|
131
|
+
static
|
132
|
+
RUCY_DEF0(get_down)
|
133
|
+
{
|
134
|
+
CHECK;
|
135
|
+
return value(THIS->down());
|
136
|
+
}
|
137
|
+
RUCY_END
|
138
|
+
|
131
139
|
|
132
140
|
static Class cPointer;
|
133
141
|
|
@@ -141,7 +149,7 @@ Init_reflex_pointer ()
|
|
141
149
|
cPointer.define_private_method("initialize", initialize);
|
142
150
|
cPointer.define_private_method("initialize_copy", initialize_copy);
|
143
151
|
cPointer.define_method("id", get_id);
|
144
|
-
cPointer.define_private_method("
|
152
|
+
cPointer.define_private_method("get_types", get_types);
|
145
153
|
cPointer.define_private_method("get_action", get_action);
|
146
154
|
cPointer.define_method("position", get_position);
|
147
155
|
cPointer.define_method("modifiers", get_modifiers);
|
@@ -150,6 +158,7 @@ Init_reflex_pointer ()
|
|
150
158
|
cPointer.define_method("view_index", get_view_index);
|
151
159
|
cPointer.define_method("time", get_time);
|
152
160
|
cPointer.define_method("prev", get_prev);
|
161
|
+
cPointer.define_method("down", get_down);
|
153
162
|
cPointer.define_const("TYPE_NONE", Reflex::Pointer::TYPE_NONE);
|
154
163
|
cPointer.define_const("MOUSE", Reflex::Pointer::MOUSE);
|
155
164
|
cPointer.define_const("MOUSE_LEFT", Reflex::Pointer::MOUSE_LEFT);
|
data/include/reflex/pointer.h
CHANGED
@@ -40,6 +40,8 @@ namespace Reflex
|
|
40
40
|
|
41
41
|
PEN = Xot::bit(5),
|
42
42
|
|
43
|
+
TYPE_LAST = PEN
|
44
|
+
|
43
45
|
};// Type
|
44
46
|
|
45
47
|
enum Action
|
@@ -62,7 +64,7 @@ namespace Reflex
|
|
62
64
|
Pointer ();
|
63
65
|
|
64
66
|
Pointer (
|
65
|
-
ID id, uint
|
67
|
+
ID id, uint types, Action action,
|
66
68
|
const Point& position, uint modifiers, bool drag,
|
67
69
|
uint click_count, uint view_index, double time);
|
68
70
|
|
@@ -74,7 +76,7 @@ namespace Reflex
|
|
74
76
|
|
75
77
|
ID id () const;
|
76
78
|
|
77
|
-
uint
|
79
|
+
uint types () const;
|
78
80
|
|
79
81
|
Action action () const;
|
80
82
|
|
@@ -92,6 +94,8 @@ namespace Reflex
|
|
92
94
|
|
93
95
|
const Pointer* prev () const;
|
94
96
|
|
97
|
+
const Pointer* down () const;
|
98
|
+
|
95
99
|
operator bool () const;
|
96
100
|
|
97
101
|
bool operator ! () const;
|
data/lib/reflex/pointer.rb
CHANGED
@@ -10,7 +10,7 @@ module Reflex
|
|
10
10
|
|
11
11
|
include Comparable
|
12
12
|
|
13
|
-
alias types
|
13
|
+
alias types get_types
|
14
14
|
alias action get_action
|
15
15
|
|
16
16
|
bit_flag_reader :types, **{
|
@@ -33,19 +33,19 @@ module Reflex
|
|
33
33
|
}
|
34
34
|
|
35
35
|
def mouse?()
|
36
|
-
(
|
36
|
+
(get_types & MOUSE) != 0
|
37
37
|
end
|
38
38
|
|
39
39
|
def mouse_left?()
|
40
|
-
(
|
40
|
+
(get_types & MOUSE_LEFT) != 0
|
41
41
|
end
|
42
42
|
|
43
43
|
def mouse_right?()
|
44
|
-
(
|
44
|
+
(get_types & MOUSE_RIGHT) != 0
|
45
45
|
end
|
46
46
|
|
47
47
|
def mouse_middle?()
|
48
|
-
(
|
48
|
+
(get_types & MOUSE_MIDDLE) != 0
|
49
49
|
end
|
50
50
|
|
51
51
|
alias left? mouse_left?
|
@@ -53,11 +53,11 @@ module Reflex
|
|
53
53
|
alias middle? mouse_middle?
|
54
54
|
|
55
55
|
def touch?()
|
56
|
-
(
|
56
|
+
(get_types & TOUCH) != 0
|
57
57
|
end
|
58
58
|
|
59
59
|
def pen?()
|
60
|
-
(
|
60
|
+
(get_types & PEN) != 0
|
61
61
|
end
|
62
62
|
|
63
63
|
def down?()
|
data/lib/reflex/pointer_event.rb
CHANGED
@@ -7,6 +7,8 @@ module Reflex
|
|
7
7
|
|
8
8
|
class PointerEvent < Event
|
9
9
|
|
10
|
+
include Enumerable
|
11
|
+
|
10
12
|
extend Forwardable
|
11
13
|
|
12
14
|
def_delegators :first,
|
@@ -15,7 +17,7 @@ module Reflex
|
|
15
17
|
:mouse_left?, :left?, :mouse_right?, :right?, :mouse_middle?, :middle?,
|
16
18
|
:action, :down?, :up?, :move?, :cancel?, :stay?,
|
17
19
|
:position, :pos, :x, :y, :modifiers, :drag?, :click_count, :view_index,
|
18
|
-
:time, :prev
|
20
|
+
:time, :prev, :down
|
19
21
|
|
20
22
|
def pointers()
|
21
23
|
to_enum :each
|
@@ -25,12 +27,6 @@ module Reflex
|
|
25
27
|
"#<Reflex::PointerEvent id:#{id} #{types} #{action} (#{x.round 2}, #{y.round 2}) mod:#{modifiers} drag:#{drag?} click:#{click_count} view:#{view_index} time:#{time.round 2}>"
|
26
28
|
end
|
27
29
|
|
28
|
-
private
|
29
|
-
|
30
|
-
def first()
|
31
|
-
self[0]
|
32
|
-
end
|
33
|
-
|
34
30
|
end# PointerEvent
|
35
31
|
|
36
32
|
|
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.1.
|
29
|
-
s.add_runtime_dependency 'rucy', '~> 0.1.
|
30
|
-
s.add_runtime_dependency 'beeps', '~> 0.1.
|
31
|
-
s.add_runtime_dependency 'rays', '~> 0.1.
|
28
|
+
s.add_runtime_dependency 'xot', '~> 0.1.39'
|
29
|
+
s.add_runtime_dependency 'rucy', '~> 0.1.39'
|
30
|
+
s.add_runtime_dependency 'beeps', '~> 0.1.40'
|
31
|
+
s.add_runtime_dependency 'rays', '~> 0.1.42'
|
32
32
|
|
33
33
|
s.add_development_dependency 'rake'
|
34
34
|
s.add_development_dependency 'test-unit'
|
data/src/ios/event.mm
CHANGED
@@ -69,31 +69,35 @@ namespace Reflex
|
|
69
69
|
(flags & UIKeyModifierNumericPad) ? MOD_NUMPAD : 0;
|
70
70
|
}
|
71
71
|
|
72
|
+
static void
|
73
|
+
set_pasts (Pointer* pointer, const Pointer* prev)
|
74
|
+
{
|
75
|
+
Pointer_set_prev(pointer, prev);
|
76
|
+
if (prev && prev->down())
|
77
|
+
Pointer_set_down(pointer, prev->down());
|
78
|
+
}
|
79
|
+
|
72
80
|
static void
|
73
81
|
attach_prev_pointer (
|
74
82
|
Pointer* pointer, PrevPointerList* prev_pointers, const Point& prev_position)
|
75
83
|
{
|
76
|
-
assert(pointer && prev_pointers);
|
77
|
-
|
78
84
|
auto it = std::find_if(
|
79
85
|
prev_pointers->begin(), prev_pointers->end(),
|
80
|
-
[&](const
|
86
|
+
[&](const Pointer& p) {return p.position() == prev_position;});
|
81
87
|
|
82
88
|
if (it != prev_pointers->end())
|
83
89
|
{
|
84
|
-
|
90
|
+
set_pasts(pointer, &*it);
|
85
91
|
prev_pointers->erase(it);
|
86
92
|
}
|
87
93
|
else if (prev_pointers->size() == 1)
|
88
94
|
{
|
89
|
-
|
95
|
+
set_pasts(pointer, &prev_pointers->front());
|
90
96
|
prev_pointers->clear();
|
91
97
|
}
|
92
|
-
else
|
93
|
-
Reflex::Pointer_set_prev(pointer, NULL);
|
94
98
|
|
95
99
|
if (pointer->prev())
|
96
|
-
|
100
|
+
Pointer_set_id(pointer, pointer->prev()->id());
|
97
101
|
}
|
98
102
|
|
99
103
|
static Pointer
|
@@ -101,8 +105,8 @@ namespace Reflex
|
|
101
105
|
UITouch* touch, UIEvent* event, UIView* view, double time,
|
102
106
|
Pointer::ID pointer_id, PrevPointerList* prev_pointers)
|
103
107
|
{
|
104
|
-
|
105
|
-
|
108
|
+
Pointer::Action action = get_action(touch);
|
109
|
+
Pointer pointer(
|
106
110
|
pointer_id,
|
107
111
|
get_type(touch),
|
108
112
|
action,
|
@@ -119,6 +123,8 @@ namespace Reflex
|
|
119
123
|
&pointer, prev_pointers,
|
120
124
|
to_point([touch previousLocationInView: view]));
|
121
125
|
}
|
126
|
+
else
|
127
|
+
Pointer_set_down(&pointer, &pointer);
|
122
128
|
|
123
129
|
return pointer;
|
124
130
|
}
|
data/src/ios/view_controller.mm
CHANGED
@@ -495,6 +495,9 @@ ReflexViewController_get_show_fun ()
|
|
495
495
|
for (size_t i = 0; i < size; ++i)
|
496
496
|
{
|
497
497
|
prev_pointers.emplace_back(event[i]);
|
498
|
+
if (prev_pointers.size() > 10)
|
499
|
+
Reflex::invalid_state_error(__FILE__, __LINE__);
|
500
|
+
|
498
501
|
Reflex::Pointer_set_prev(&prev_pointers.back(), NULL);
|
499
502
|
}
|
500
503
|
}
|
data/src/osx/native_window.mm
CHANGED
@@ -12,6 +12,12 @@
|
|
12
12
|
#import "opengl_view.h"
|
13
13
|
|
14
14
|
|
15
|
+
static const uint MOUSE_BUTTONS =
|
16
|
+
Reflex::Pointer::MOUSE_LEFT |
|
17
|
+
Reflex::Pointer::MOUSE_RIGHT |
|
18
|
+
Reflex::Pointer::MOUSE_MIDDLE;
|
19
|
+
|
20
|
+
|
15
21
|
static NSWindowStyleMask
|
16
22
|
default_style_mask ()
|
17
23
|
{
|
@@ -20,20 +26,6 @@ default_style_mask ()
|
|
20
26
|
NSTitledWindowMask | NSTexturedBackgroundWindowMask);
|
21
27
|
}
|
22
28
|
|
23
|
-
static int
|
24
|
-
count_mouse_buttons (const Reflex::PointerEvent& e)
|
25
|
-
{
|
26
|
-
uint nbuttons = 0;
|
27
|
-
PointerEvent_each_pointer(&e, [&](const auto& pointer) {
|
28
|
-
uint t = pointer.type();
|
29
|
-
nbuttons +=
|
30
|
-
(t & Reflex::Pointer::MOUSE_LEFT ? 1 : 0) +
|
31
|
-
(t & Reflex::Pointer::MOUSE_RIGHT ? 1 : 0) +
|
32
|
-
(t & Reflex::Pointer::MOUSE_MIDDLE ? 1 : 0);
|
33
|
-
});
|
34
|
-
return nbuttons;
|
35
|
-
}
|
36
|
-
|
37
29
|
static void
|
38
30
|
update_pixel_density (Reflex::Window* window)
|
39
31
|
{
|
@@ -58,7 +50,6 @@ update_pixel_density (Reflex::Window* window)
|
|
58
50
|
OpenGLView* view;
|
59
51
|
NSTimer* timer;
|
60
52
|
int update_count;
|
61
|
-
int clicking_count;
|
62
53
|
Reflex::Pointer::ID pointer_id;
|
63
54
|
Reflex::Pointer prev_pointer;
|
64
55
|
}
|
@@ -77,7 +68,6 @@ update_pixel_density (Reflex::Window* window)
|
|
77
68
|
view = nil;
|
78
69
|
timer = nil;
|
79
70
|
update_count = 0;
|
80
|
-
clicking_count = 0;
|
81
71
|
pointer_id = 0;
|
82
72
|
|
83
73
|
[self setDelegate: self];
|
@@ -351,7 +341,8 @@ update_pixel_density (Reflex::Window* window)
|
|
351
341
|
Reflex::Window* win = self.window;
|
352
342
|
if (!win) return;
|
353
343
|
|
354
|
-
if (
|
344
|
+
if (Reflex::Pointer_mask_flag(prev_pointer, MOUSE_BUTTONS) == 0)
|
345
|
+
++pointer_id;
|
355
346
|
|
356
347
|
Reflex::NativePointerEvent e(event, view, pointer_id, Reflex::Pointer::DOWN);
|
357
348
|
|
@@ -362,9 +353,7 @@ update_pixel_density (Reflex::Window* window)
|
|
362
353
|
return;
|
363
354
|
}
|
364
355
|
|
365
|
-
[self
|
366
|
-
|
367
|
-
clicking_count += count_mouse_buttons(e);
|
356
|
+
[self attachAndUpdatePastPointers: &e];
|
368
357
|
|
369
358
|
Window_call_pointer_event(win, &e);
|
370
359
|
}
|
@@ -375,13 +364,13 @@ update_pixel_density (Reflex::Window* window)
|
|
375
364
|
if (!win) return;
|
376
365
|
|
377
366
|
Reflex::NativePointerEvent e(event, view, pointer_id, Reflex::Pointer::UP);
|
378
|
-
[self
|
367
|
+
[self attachAndUpdatePastPointers: &e];
|
379
368
|
|
380
|
-
|
381
|
-
|
369
|
+
if (prev_pointer && Reflex::Pointer_mask_flag(prev_pointer, MOUSE_BUTTONS) == 0)
|
370
|
+
{
|
382
371
|
++pointer_id;
|
383
|
-
|
384
|
-
|
372
|
+
Pointer_set_down(&prev_pointer, NULL);
|
373
|
+
}
|
385
374
|
|
386
375
|
Window_call_pointer_event(win, &e);
|
387
376
|
}
|
@@ -392,7 +381,7 @@ update_pixel_density (Reflex::Window* window)
|
|
392
381
|
if (!win) return;
|
393
382
|
|
394
383
|
Reflex::NativePointerEvent e(event, view, pointer_id, Reflex::Pointer::MOVE);
|
395
|
-
[self
|
384
|
+
[self attachAndUpdatePastPointers: &e];
|
396
385
|
|
397
386
|
Window_call_pointer_event(win, &e);
|
398
387
|
}
|
@@ -403,18 +392,40 @@ update_pixel_density (Reflex::Window* window)
|
|
403
392
|
if (!win) return;
|
404
393
|
|
405
394
|
Reflex::NativePointerEvent e(event, view, pointer_id, Reflex::Pointer::MOVE);
|
406
|
-
[self
|
395
|
+
[self attachAndUpdatePastPointers: &e];
|
407
396
|
|
408
397
|
Window_call_pointer_event(win, &e);
|
409
398
|
}
|
410
399
|
|
411
|
-
- (void)
|
400
|
+
- (void) attachAndUpdatePastPointers: (Reflex::PointerEvent*) e
|
412
401
|
{
|
402
|
+
using namespace Reflex;
|
403
|
+
|
413
404
|
assert(e->size() == 1);
|
414
405
|
|
415
|
-
|
406
|
+
Pointer& pointer = PointerEvent_pointer_at(e, 0);
|
407
|
+
|
416
408
|
if (prev_pointer)
|
409
|
+
{
|
410
|
+
Pointer_add_flag(&pointer, Pointer_mask_flag(prev_pointer, MOUSE_BUTTONS));
|
417
411
|
Reflex::Pointer_set_prev(&pointer, &prev_pointer);
|
412
|
+
}
|
413
|
+
|
414
|
+
switch (pointer.action())
|
415
|
+
{
|
416
|
+
case Pointer::DOWN:
|
417
|
+
Pointer_add_flag(&pointer, pointer.types());
|
418
|
+
break;
|
419
|
+
|
420
|
+
case Pointer::UP:
|
421
|
+
Pointer_remove_flag(&pointer, pointer.types());
|
422
|
+
break;
|
423
|
+
}
|
424
|
+
|
425
|
+
if (prev_pointer && prev_pointer.down())
|
426
|
+
Reflex::Pointer_set_down(&pointer, prev_pointer.down());
|
427
|
+
else if (pointer.action() == Reflex::Pointer::DOWN)
|
428
|
+
Reflex::Pointer_set_down(&pointer, &pointer);
|
418
429
|
|
419
430
|
prev_pointer = pointer;
|
420
431
|
Reflex::Pointer_set_prev(&prev_pointer, NULL);
|
data/src/pointer.cpp
CHANGED
@@ -28,17 +28,17 @@ namespace Reflex
|
|
28
28
|
enum Flag
|
29
29
|
{
|
30
30
|
|
31
|
-
DRAG = Xot::bit(0),
|
31
|
+
DRAG = Xot::bit(0, TYPE_LAST),
|
32
32
|
|
33
|
-
ENTER = Xot::bit(1),
|
33
|
+
ENTER = Xot::bit(1, TYPE_LAST),
|
34
34
|
|
35
|
-
EXIT = Xot::bit(2),
|
35
|
+
EXIT = Xot::bit(2, TYPE_LAST),
|
36
36
|
|
37
37
|
};// Flag
|
38
38
|
|
39
39
|
ID id;
|
40
40
|
|
41
|
-
uint
|
41
|
+
uint types;
|
42
42
|
|
43
43
|
Action action;
|
44
44
|
|
@@ -50,14 +50,14 @@ namespace Reflex
|
|
50
50
|
|
51
51
|
double time;
|
52
52
|
|
53
|
-
PrevPointerPtr prev;
|
53
|
+
PrevPointerPtr prev, down;
|
54
54
|
|
55
55
|
Data (
|
56
|
-
ID id = -1, uint
|
56
|
+
ID id = -1, uint types = TYPE_NONE, Action action = ACTION_NONE,
|
57
57
|
const Point& position = 0, uint modifiers = 0,
|
58
58
|
bool drag = false, bool enter = false, bool exit = false,
|
59
59
|
uint click_count = 0, uint view_index = 0, double time = 0)
|
60
|
-
: id(id),
|
60
|
+
: id(id), types(types), action(action),
|
61
61
|
position(position), modifiers(modifiers),
|
62
62
|
flags(make_flags(drag, enter, exit)),
|
63
63
|
click_count(click_count), view_index(view_index), time(time)
|
@@ -78,36 +78,57 @@ namespace Reflex
|
|
78
78
|
|
79
79
|
|
80
80
|
void
|
81
|
-
Pointer_update_positions (Pointer*
|
81
|
+
Pointer_update_positions (Pointer* it, std::function<void(Point*)> fun)
|
82
82
|
{
|
83
|
-
auto& self =
|
83
|
+
auto& self = it->self;
|
84
84
|
fun(&self->position);
|
85
|
-
if (self->prev)
|
86
|
-
|
85
|
+
if (self->prev) fun(&self->prev->self->position);
|
86
|
+
if (self->down) fun(&self->down->self->position);
|
87
87
|
}
|
88
88
|
|
89
89
|
void
|
90
|
-
Pointer_set_id (Pointer*
|
90
|
+
Pointer_set_id (Pointer* it, Pointer::ID id)
|
91
91
|
{
|
92
|
-
|
92
|
+
it->self->id = id;
|
93
93
|
}
|
94
94
|
|
95
95
|
void
|
96
|
-
Pointer_set_view_index (Pointer*
|
96
|
+
Pointer_set_view_index (Pointer* it, uint view_index)
|
97
97
|
{
|
98
98
|
if (view_index >= USHRT_MAX)
|
99
99
|
argument_error(__FILE__, __LINE__);
|
100
100
|
|
101
|
-
|
101
|
+
it->self->view_index = view_index;
|
102
102
|
}
|
103
103
|
|
104
104
|
void
|
105
|
-
|
105
|
+
Pointer_add_flag (Pointer* it, uint flag)
|
106
106
|
{
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
107
|
+
Xot::add_flag(&it->self->flags, flag);
|
108
|
+
}
|
109
|
+
|
110
|
+
void
|
111
|
+
Pointer_remove_flag (Pointer* it, uint flag)
|
112
|
+
{
|
113
|
+
Xot::remove_flag(&it->self->flags, flag);
|
114
|
+
}
|
115
|
+
|
116
|
+
uint
|
117
|
+
Pointer_mask_flag (const Pointer& it, uint mask)
|
118
|
+
{
|
119
|
+
return Xot::mask_flag(it.self->flags, mask);
|
120
|
+
}
|
121
|
+
|
122
|
+
void
|
123
|
+
Pointer_set_prev (Pointer* it, const Pointer* prev)
|
124
|
+
{
|
125
|
+
it->self->prev.reset(prev ? new Pointer(*prev) : NULL);
|
126
|
+
}
|
127
|
+
|
128
|
+
void
|
129
|
+
Pointer_set_down (Pointer* it, const Pointer* down)
|
130
|
+
{
|
131
|
+
it->self->down.reset(down ? new Pointer(*down) : NULL);
|
111
132
|
}
|
112
133
|
|
113
134
|
|
@@ -116,11 +137,11 @@ namespace Reflex
|
|
116
137
|
}
|
117
138
|
|
118
139
|
Pointer::Pointer (
|
119
|
-
ID id, uint
|
140
|
+
ID id, uint types, Action action,
|
120
141
|
const Point& position, uint modifiers, bool drag,
|
121
142
|
uint click_count, uint view_index, double time)
|
122
143
|
: self(new Data(
|
123
|
-
id,
|
144
|
+
id, types, action,
|
124
145
|
position, modifiers, drag, false, false,
|
125
146
|
click_count, view_index, time))
|
126
147
|
{
|
@@ -149,9 +170,9 @@ namespace Reflex
|
|
149
170
|
}
|
150
171
|
|
151
172
|
uint
|
152
|
-
Pointer::
|
173
|
+
Pointer::types () const
|
153
174
|
{
|
154
|
-
return self->
|
175
|
+
return self->types;
|
155
176
|
}
|
156
177
|
|
157
178
|
Pointer::Action
|
@@ -175,7 +196,7 @@ namespace Reflex
|
|
175
196
|
bool
|
176
197
|
Pointer::is_drag () const
|
177
198
|
{
|
178
|
-
return self->flags
|
199
|
+
return Xot::has_flag(self->flags, Data::DRAG);
|
179
200
|
}
|
180
201
|
|
181
202
|
uint
|
@@ -202,10 +223,16 @@ namespace Reflex
|
|
202
223
|
return self->prev.get();
|
203
224
|
}
|
204
225
|
|
226
|
+
const Pointer*
|
227
|
+
Pointer::down () const
|
228
|
+
{
|
229
|
+
return self->down.get();
|
230
|
+
}
|
231
|
+
|
205
232
|
Pointer::operator bool () const
|
206
233
|
{
|
207
234
|
return
|
208
|
-
self->
|
235
|
+
self->types != TYPE_NONE &&
|
209
236
|
ACTION_NONE < self->action && self->action <= STAY;
|
210
237
|
}
|
211
238
|
|
data/src/pointer.h
CHANGED
@@ -12,14 +12,21 @@ namespace Reflex
|
|
12
12
|
{
|
13
13
|
|
14
14
|
|
15
|
-
void Pointer_update_positions (
|
16
|
-
Pointer* pthis, std::function<void(Point*)> fun);
|
15
|
+
void Pointer_update_positions (Pointer* it, std::function<void(Point*)> fun);
|
17
16
|
|
18
|
-
void Pointer_set_id (Pointer*
|
17
|
+
void Pointer_set_id (Pointer* it, Pointer::ID id);
|
19
18
|
|
20
|
-
void Pointer_set_view_index (Pointer*
|
19
|
+
void Pointer_set_view_index (Pointer* it, uint view_index);
|
21
20
|
|
22
|
-
void
|
21
|
+
void Pointer_add_flag (Pointer* it, uint flag);
|
22
|
+
|
23
|
+
void Pointer_remove_flag (Pointer* it, uint flag);
|
24
|
+
|
25
|
+
uint Pointer_mask_flag (const Pointer& it, uint mask);
|
26
|
+
|
27
|
+
void Pointer_set_prev (Pointer* it, const Pointer* prev);
|
28
|
+
|
29
|
+
void Pointer_set_down (Pointer* it, const Pointer* down);
|
23
30
|
|
24
31
|
|
25
32
|
}// Reflex
|
data/test/test_pointer.rb
CHANGED
@@ -22,19 +22,19 @@ class TestPointer < Test::Unit::TestCase
|
|
22
22
|
F = false
|
23
23
|
|
24
24
|
def pointer(
|
25
|
-
id: 0,
|
25
|
+
id: 0, types: TYPE_NONE, action: ACTION_NONE,
|
26
26
|
position: 0, modifiers: 0, drag: false, click_count: 0, view_index: 0,
|
27
27
|
time: 0)
|
28
28
|
|
29
29
|
Reflex::Pointer.new(
|
30
|
-
id,
|
30
|
+
id, types, action, position, modifiers, drag, click_count, view_index, time)
|
31
31
|
end
|
32
32
|
|
33
33
|
def test_initialize()
|
34
34
|
assert_nothing_raised {pointer}
|
35
35
|
|
36
36
|
p = pointer(
|
37
|
-
id: 1,
|
37
|
+
id: 1, types: TOUCH, action: DOWN,
|
38
38
|
position: [2, 3], modifiers: 4, drag: true, click_count: 5, view_index: 6,
|
39
39
|
time: 7)
|
40
40
|
|
@@ -50,11 +50,12 @@ class TestPointer < Test::Unit::TestCase
|
|
50
50
|
assert_equal 6, p.view_index
|
51
51
|
assert_equal 7, p.time
|
52
52
|
assert_nil p.prev
|
53
|
+
assert_nil p.down
|
53
54
|
end
|
54
55
|
|
55
56
|
def test_types()
|
56
57
|
def create(t)
|
57
|
-
pointer(
|
58
|
+
pointer(types: t).tap do |o|
|
58
59
|
def o.test()
|
59
60
|
[types, mouse?, left?, right?, middle?, touch?, pen?]
|
60
61
|
end
|
@@ -137,7 +138,7 @@ class TestPointer < Test::Unit::TestCase
|
|
137
138
|
assert_equal pointer, pointer
|
138
139
|
|
139
140
|
assert_not_equal pointer, pointer(id: 1)
|
140
|
-
assert_not_equal pointer, pointer(
|
141
|
+
assert_not_equal pointer, pointer(types: Reflex::Pointer::PEN)
|
141
142
|
assert_not_equal pointer, pointer(action: Reflex::Pointer::UP)
|
142
143
|
assert_not_equal pointer, pointer(position: 2)
|
143
144
|
assert_not_equal pointer, pointer(modifiers: 3)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: reflexion
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.45
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- xordog
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-06-
|
11
|
+
date: 2023-06-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: xot
|
@@ -16,56 +16,56 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.1.
|
19
|
+
version: 0.1.39
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.1.
|
26
|
+
version: 0.1.39
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rucy
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0.1.
|
33
|
+
version: 0.1.39
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 0.1.
|
40
|
+
version: 0.1.39
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: beeps
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 0.1.
|
47
|
+
version: 0.1.40
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 0.1.
|
54
|
+
version: 0.1.40
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rays
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 0.1.
|
61
|
+
version: 0.1.42
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: 0.1.
|
68
|
+
version: 0.1.42
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rake
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|