reflexion 0.3.2 → 0.3.4
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/application.cpp +13 -0
- data/ChangeLog.md +17 -0
- data/VERSION +1 -1
- data/ext/reflex/application.cpp +14 -0
- data/ext/reflex/extconf.rb +3 -3
- data/include/reflex/application.h +16 -0
- data/include/reflex/view.h +10 -10
- data/lib/reflex/application.rb +6 -2
- data/lib/reflex/helper.rb +0 -12
- data/lib/reflex/shape.rb +2 -1
- data/lib/reflex/view.rb +10 -3
- data/lib/reflex/window.rb +2 -1
- data/lib/reflexion.rb +1 -2
- data/reflex.gemspec +3 -4
- data/src/application.cpp +88 -0
- data/src/application.h +28 -0
- data/src/body.cpp +15 -5
- data/src/ios/app_delegate.mm +7 -5
- data/src/ios/application.h +8 -5
- data/src/ios/application.mm +16 -43
- data/src/ios/view_controller.mm +5 -7
- data/src/osx/app_delegate.mm +7 -5
- data/src/osx/application.h +8 -5
- data/src/osx/application.mm +16 -43
- data/src/osx/native_window.mm +5 -7
- data/src/view.cpp +4 -2
- data/src/win32/application.cpp +48 -50
- data/src/win32/window.cpp +8 -50
- data/src/win32/window.h +20 -0
- data/src/window.cpp +100 -34
- data/src/window.h +11 -1
- data/test/test_view.rb +51 -0
- metadata +17 -34
data/src/window.cpp
CHANGED
@@ -22,6 +22,37 @@ namespace Reflex
|
|
22
22
|
using CaptureTargetIDList = Window::Data::CaptureTargetIDList;
|
23
23
|
|
24
24
|
|
25
|
+
void
|
26
|
+
Window_register (Window* win)
|
27
|
+
{
|
28
|
+
auto& all = Window_all();
|
29
|
+
|
30
|
+
auto it = std::find(all.begin(), all.end(), win);
|
31
|
+
if (it != all.end())
|
32
|
+
invalid_state_error(__FILE__, __LINE__);
|
33
|
+
|
34
|
+
all.push_back(win);
|
35
|
+
}
|
36
|
+
|
37
|
+
void
|
38
|
+
Window_unregister (Window* win)
|
39
|
+
{
|
40
|
+
auto& all = Window_all();
|
41
|
+
|
42
|
+
auto it = std::find(all.begin(), all.end(), win);
|
43
|
+
if (it == all.end()) return;
|
44
|
+
|
45
|
+
all.erase(it);
|
46
|
+
}
|
47
|
+
|
48
|
+
Application::WindowList&
|
49
|
+
Window_all ()
|
50
|
+
{
|
51
|
+
static Application::WindowList windows;
|
52
|
+
return windows;
|
53
|
+
}
|
54
|
+
|
55
|
+
|
25
56
|
Window::Data::Data ()
|
26
57
|
: flags(Window_default_flags())
|
27
58
|
{
|
@@ -98,7 +129,7 @@ namespace Reflex
|
|
98
129
|
return;
|
99
130
|
|
100
131
|
targets.insert(
|
101
|
-
target ==
|
132
|
+
target == CAPTURE_ALL_EVENTS ? targets.begin() : targets.end(),
|
102
133
|
target);
|
103
134
|
}
|
104
135
|
|
@@ -132,23 +163,38 @@ namespace Reflex
|
|
132
163
|
}
|
133
164
|
|
134
165
|
void
|
135
|
-
Window_call_activate_event (
|
166
|
+
Window_call_activate_event (Window* window)
|
136
167
|
{
|
137
168
|
if (!window) return;
|
138
169
|
|
139
|
-
|
170
|
+
Event e;
|
140
171
|
window->on_activate(&e);
|
141
172
|
}
|
142
173
|
|
143
174
|
void
|
144
|
-
Window_call_deactivate_event (
|
175
|
+
Window_call_deactivate_event (Window* window)
|
145
176
|
{
|
146
177
|
if (!window) return;
|
147
178
|
|
148
|
-
|
179
|
+
Event e;
|
149
180
|
window->on_deactivate(&e);
|
150
181
|
}
|
151
182
|
|
183
|
+
void
|
184
|
+
Window_call_update_event (Window* window)
|
185
|
+
{
|
186
|
+
Window::Data* self = window->self.get();
|
187
|
+
|
188
|
+
double now = Xot::time();
|
189
|
+
UpdateEvent e(now, now - self->prev_time_update);
|
190
|
+
self->prev_time_update = now;
|
191
|
+
|
192
|
+
window->on_update(&e);
|
193
|
+
if (e.is_blocked()) return;
|
194
|
+
|
195
|
+
View_update_tree(window->root(), e);
|
196
|
+
}
|
197
|
+
|
152
198
|
void
|
153
199
|
Window_call_draw_event (Window* window, DrawEvent* event)
|
154
200
|
{
|
@@ -172,19 +218,19 @@ namespace Reflex
|
|
172
218
|
|
173
219
|
window->on_draw(event);
|
174
220
|
if (!event->is_blocked())
|
175
|
-
|
221
|
+
View_draw_tree(window->root(), event, 0, frame.move_to(0));
|
176
222
|
|
177
223
|
painter->pop_state();
|
178
224
|
painter->end();
|
179
225
|
}
|
180
226
|
|
181
227
|
static bool
|
182
|
-
|
228
|
+
is_capturing (
|
183
229
|
const View* view, const CaptureTargetIDList& targets, View::Capture type)
|
184
230
|
{
|
185
231
|
return
|
186
232
|
!targets.empty() &&
|
187
|
-
targets[0] ==
|
233
|
+
targets[0] == CAPTURE_ALL_EVENTS &&
|
188
234
|
(view->capture() & type) == type;
|
189
235
|
}
|
190
236
|
|
@@ -196,20 +242,11 @@ namespace Reflex
|
|
196
242
|
if (!event)
|
197
243
|
argument_error(__FILE__, __LINE__);
|
198
244
|
|
199
|
-
window->on_key(event);
|
200
|
-
|
201
|
-
switch (event->action())
|
202
|
-
{
|
203
|
-
case KeyEvent::DOWN: window->on_key_down(event); break;
|
204
|
-
case KeyEvent::UP: window->on_key_up(event); break;
|
205
|
-
default: break;
|
206
|
-
}
|
207
|
-
|
208
245
|
for (auto& [view, targets] : window->self->captures)
|
209
246
|
{
|
210
247
|
if (
|
211
248
|
!view->window() ||
|
212
|
-
!
|
249
|
+
!is_capturing(view.get(), targets, View::CAPTURE_KEY))
|
213
250
|
{
|
214
251
|
continue;
|
215
252
|
}
|
@@ -217,9 +254,24 @@ namespace Reflex
|
|
217
254
|
KeyEvent e = event->dup();
|
218
255
|
KeyEvent_set_captured(&e, true);
|
219
256
|
View_call_key_event(const_cast<View*>(view.get()), &e);
|
257
|
+
|
258
|
+
if (e.is_blocked()) event->block();
|
220
259
|
}
|
221
260
|
|
222
|
-
if (
|
261
|
+
if (!event->is_blocked())
|
262
|
+
window->on_key(event);
|
263
|
+
|
264
|
+
if (!event->is_blocked())
|
265
|
+
{
|
266
|
+
switch (event->action())
|
267
|
+
{
|
268
|
+
case KeyEvent::DOWN: window->on_key_down(event); break;
|
269
|
+
case KeyEvent::UP: window->on_key_up(event); break;
|
270
|
+
default: break;
|
271
|
+
}
|
272
|
+
}
|
273
|
+
|
274
|
+
if (!event->is_blocked() && window->self->focus)
|
223
275
|
View_call_key_event(window->self->focus.get(), event);
|
224
276
|
|
225
277
|
cleanup_captures(window);
|
@@ -336,7 +388,7 @@ namespace Reflex
|
|
336
388
|
result->clear();
|
337
389
|
for (const auto& [view, targets] : window->self->captures)
|
338
390
|
{
|
339
|
-
if (
|
391
|
+
if (is_capturing(view.get(), targets, View::CAPTURE_POINTER))
|
340
392
|
result->emplace_back(view);
|
341
393
|
}
|
342
394
|
}
|
@@ -385,7 +437,7 @@ namespace Reflex
|
|
385
437
|
|
386
438
|
static void
|
387
439
|
capture_targeted_pointers_and_call_events (
|
388
|
-
ExtractedPointerIDSet* extracteds,
|
440
|
+
ExtractedPointerIDSet* extracteds, bool* blocked,
|
389
441
|
Window* window, const PointerMap& pointers)
|
390
442
|
{
|
391
443
|
for (auto& [view, targets] : window->self->captures)
|
@@ -399,6 +451,8 @@ namespace Reflex
|
|
399
451
|
|
400
452
|
PointerEvent_update_for_capturing_view(&event, view);
|
401
453
|
View_call_pointer_event(const_cast<View*>(view.get()), &event);
|
454
|
+
|
455
|
+
if (event.is_blocked()) *blocked = true;
|
402
456
|
}
|
403
457
|
}
|
404
458
|
|
@@ -420,7 +474,7 @@ namespace Reflex
|
|
420
474
|
|
421
475
|
static void
|
422
476
|
capture_hovering_pointers_and_call_events (
|
423
|
-
ExtractedPointerIDSet* extracteds,
|
477
|
+
ExtractedPointerIDSet* extracteds, bool* blocked,
|
424
478
|
const ViewList& views_capturing_all, const PointerMap& pointers)
|
425
479
|
{
|
426
480
|
assert(extracteds);
|
@@ -439,6 +493,8 @@ namespace Reflex
|
|
439
493
|
PointerEvent e = event.dup();
|
440
494
|
PointerEvent_update_for_capturing_view(&e, view);
|
441
495
|
View_call_pointer_event(const_cast<View*>(view.get()), &e);
|
496
|
+
|
497
|
+
if (e.is_blocked()) *blocked = true;
|
442
498
|
}
|
443
499
|
}
|
444
500
|
|
@@ -481,11 +537,17 @@ namespace Reflex
|
|
481
537
|
});
|
482
538
|
|
483
539
|
ExtractedPointerIDSet extracteds;
|
484
|
-
|
540
|
+
bool blocked = false;
|
541
|
+
|
542
|
+
capture_targeted_pointers_and_call_events(
|
543
|
+
&extracteds, &blocked, window, pointers);
|
485
544
|
erase_extracted_pointers(&pointers, extracteds);
|
486
545
|
|
487
|
-
capture_hovering_pointers_and_call_events(
|
546
|
+
capture_hovering_pointers_and_call_events(
|
547
|
+
&extracteds, &blocked, views_capturing_all, pointers);
|
488
548
|
erase_extracted_pointers(event, extracteds);
|
549
|
+
|
550
|
+
if (blocked) event->block();
|
489
551
|
}
|
490
552
|
|
491
553
|
void
|
@@ -498,20 +560,24 @@ namespace Reflex
|
|
498
560
|
|
499
561
|
setup_pointer_event(window, event);
|
500
562
|
|
501
|
-
window
|
563
|
+
call_captured_pointer_events(window, event);
|
564
|
+
|
565
|
+
if (!event->is_blocked() && !event->empty())
|
566
|
+
window->on_pointer(event);
|
502
567
|
|
503
|
-
|
568
|
+
if (!event->is_blocked() && !event->empty())
|
504
569
|
{
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
|
509
|
-
|
570
|
+
switch ((*event)[0].action())
|
571
|
+
{
|
572
|
+
case Pointer::DOWN: window->on_pointer_down(event); break;
|
573
|
+
case Pointer::UP: window->on_pointer_up(event); break;
|
574
|
+
case Pointer::MOVE: window->on_pointer_move(event); break;
|
575
|
+
case Pointer::CANCEL: window->on_pointer_cancel(event); break;
|
576
|
+
default: break;
|
577
|
+
}
|
510
578
|
}
|
511
579
|
|
512
|
-
|
513
|
-
|
514
|
-
if (!event->empty())
|
580
|
+
if (!event->is_blocked() && !event->empty())
|
515
581
|
{
|
516
582
|
PointerEvent_update_for_child_view(event, window->root());
|
517
583
|
View_call_pointer_event(window->root(), event);
|
data/src/window.h
CHANGED
@@ -12,6 +12,7 @@
|
|
12
12
|
#include <rays/painter.h>
|
13
13
|
#include "reflex/window.h"
|
14
14
|
#include "reflex/view.h"
|
15
|
+
#include "application.h"
|
15
16
|
#include "pointer.h"
|
16
17
|
|
17
18
|
|
@@ -22,7 +23,7 @@ namespace Reflex
|
|
22
23
|
typedef std::list<Pointer> PointerList;
|
23
24
|
|
24
25
|
|
25
|
-
enum {
|
26
|
+
enum {CAPTURE_ALL_EVENTS = INT_MAX};
|
26
27
|
|
27
28
|
|
28
29
|
struct Window::Data
|
@@ -75,6 +76,13 @@ namespace Reflex
|
|
75
76
|
|
76
77
|
Window::Data* Window_create_data ();
|
77
78
|
|
79
|
+
void Window_register (Window* win);
|
80
|
+
|
81
|
+
void Window_unregister (Window* win);
|
82
|
+
|
83
|
+
Application::WindowList& Window_all ();
|
84
|
+
|
85
|
+
|
78
86
|
uint Window_default_flags ();
|
79
87
|
|
80
88
|
void Window_initialize (Window* window);
|
@@ -112,6 +120,8 @@ namespace Reflex
|
|
112
120
|
|
113
121
|
void Window_call_deactivate_event (Window* window);
|
114
122
|
|
123
|
+
void Window_call_update_event (Window* window);
|
124
|
+
|
115
125
|
void Window_call_draw_event (Window* window, DrawEvent* event);
|
116
126
|
|
117
127
|
void Window_call_key_event (Window* window, KeyEvent* event);
|
data/test/test_view.rb
CHANGED
@@ -373,6 +373,57 @@ class TestView < Test::Unit::TestCase
|
|
373
373
|
assert_raise(ArgumentError) {v.scroll_by 100}
|
374
374
|
end
|
375
375
|
|
376
|
+
def test_capture()
|
377
|
+
v, w = view, window
|
378
|
+
w.add v
|
379
|
+
assert_equal [], v.capture
|
380
|
+
|
381
|
+
v.capture = :key; assert_equal [:key], v.capture
|
382
|
+
v.capture = :pointer; assert_equal [:pointer], v.capture
|
383
|
+
v.capture = :all; assert_equal [:key, :pointer], v.capture
|
384
|
+
|
385
|
+
v.capture -= [:key]; assert_equal [:pointer], v.capture
|
386
|
+
v.capture += [:key]; assert_equal [:key, :pointer], v.capture
|
387
|
+
|
388
|
+
v.capture = []; assert_equal [], v.capture
|
389
|
+
v.capture += [:key, :pointer]; assert_equal [:key, :pointer], v.capture
|
390
|
+
v.capture = []; assert_equal [], v.capture
|
391
|
+
v.capture += [:all]; assert_equal [:key, :pointer], v.capture
|
392
|
+
|
393
|
+
v.capture -= []; assert_equal [:key, :pointer], v.capture
|
394
|
+
v.capture = []; assert_equal [], v.capture
|
395
|
+
v.capture += []; assert_equal [], v.capture
|
396
|
+
end
|
397
|
+
|
398
|
+
def test_capturing()
|
399
|
+
v, w = view, window
|
400
|
+
w.add v
|
401
|
+
|
402
|
+
v.capture = []
|
403
|
+
assert_false v.capturing?
|
404
|
+
assert_false v.capturing? :key
|
405
|
+
assert_false v.capturing? :pointer
|
406
|
+
assert_false v.capturing? :all
|
407
|
+
|
408
|
+
v.capture = :key
|
409
|
+
assert_true v.capturing?
|
410
|
+
assert_true v.capturing? :key
|
411
|
+
assert_false v.capturing? :pointer
|
412
|
+
assert_false v.capturing? :all
|
413
|
+
|
414
|
+
v.capture = :pointer
|
415
|
+
assert_true v.capturing?
|
416
|
+
assert_false v.capturing? :key
|
417
|
+
assert_true v.capturing? :pointer
|
418
|
+
assert_false v.capturing? :all
|
419
|
+
|
420
|
+
v.capture = :all
|
421
|
+
assert_true v.capturing?
|
422
|
+
assert_true v.capturing? :key
|
423
|
+
assert_true v.capturing? :pointer
|
424
|
+
assert_true v.capturing? :all
|
425
|
+
end
|
426
|
+
|
376
427
|
def test_parent()
|
377
428
|
parent, child = view, view
|
378
429
|
parent.add_child child
|
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.3.
|
4
|
+
version: 0.3.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- xordog
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-
|
11
|
+
date: 2025-03-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: xot
|
@@ -16,80 +16,60 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.3.
|
19
|
+
version: 0.3.4
|
20
20
|
- - ">="
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: 0.3.
|
22
|
+
version: 0.3.4
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
26
26
|
requirements:
|
27
27
|
- - "~>"
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: 0.3.
|
29
|
+
version: 0.3.4
|
30
30
|
- - ">="
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version: 0.3.
|
32
|
+
version: 0.3.4
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
34
|
name: rucy
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
36
36
|
requirements:
|
37
37
|
- - "~>"
|
38
38
|
- !ruby/object:Gem::Version
|
39
|
-
version: 0.3.
|
39
|
+
version: 0.3.4
|
40
40
|
- - ">="
|
41
41
|
- !ruby/object:Gem::Version
|
42
|
-
version: 0.3.
|
42
|
+
version: 0.3.4
|
43
43
|
type: :runtime
|
44
44
|
prerelease: false
|
45
45
|
version_requirements: !ruby/object:Gem::Requirement
|
46
46
|
requirements:
|
47
47
|
- - "~>"
|
48
48
|
- !ruby/object:Gem::Version
|
49
|
-
version: 0.3.
|
49
|
+
version: 0.3.4
|
50
50
|
- - ">="
|
51
51
|
- !ruby/object:Gem::Version
|
52
|
-
version: 0.3.
|
53
|
-
- !ruby/object:Gem::Dependency
|
54
|
-
name: beeps
|
55
|
-
requirement: !ruby/object:Gem::Requirement
|
56
|
-
requirements:
|
57
|
-
- - "~>"
|
58
|
-
- !ruby/object:Gem::Version
|
59
|
-
version: 0.3.2
|
60
|
-
- - ">="
|
61
|
-
- !ruby/object:Gem::Version
|
62
|
-
version: 0.3.2
|
63
|
-
type: :runtime
|
64
|
-
prerelease: false
|
65
|
-
version_requirements: !ruby/object:Gem::Requirement
|
66
|
-
requirements:
|
67
|
-
- - "~>"
|
68
|
-
- !ruby/object:Gem::Version
|
69
|
-
version: 0.3.2
|
70
|
-
- - ">="
|
71
|
-
- !ruby/object:Gem::Version
|
72
|
-
version: 0.3.2
|
52
|
+
version: 0.3.4
|
73
53
|
- !ruby/object:Gem::Dependency
|
74
54
|
name: rays
|
75
55
|
requirement: !ruby/object:Gem::Requirement
|
76
56
|
requirements:
|
77
57
|
- - "~>"
|
78
58
|
- !ruby/object:Gem::Version
|
79
|
-
version: 0.3.
|
59
|
+
version: 0.3.4
|
80
60
|
- - ">="
|
81
61
|
- !ruby/object:Gem::Version
|
82
|
-
version: 0.3.
|
62
|
+
version: 0.3.4
|
83
63
|
type: :runtime
|
84
64
|
prerelease: false
|
85
65
|
version_requirements: !ruby/object:Gem::Requirement
|
86
66
|
requirements:
|
87
67
|
- - "~>"
|
88
68
|
- !ruby/object:Gem::Version
|
89
|
-
version: 0.3.
|
69
|
+
version: 0.3.4
|
90
70
|
- - ">="
|
91
71
|
- !ruby/object:Gem::Version
|
92
|
-
version: 0.3.
|
72
|
+
version: 0.3.4
|
93
73
|
description: This library helps you to develop interactive graphical user interface.
|
94
74
|
email: xordog@gmail.com
|
95
75
|
executables: []
|
@@ -341,6 +321,8 @@ files:
|
|
341
321
|
- samples/tree.rb
|
342
322
|
- samples/views.rb
|
343
323
|
- samples/visuals.rb
|
324
|
+
- src/application.cpp
|
325
|
+
- src/application.h
|
344
326
|
- src/body.cpp
|
345
327
|
- src/body.h
|
346
328
|
- src/event.cpp
|
@@ -402,6 +384,7 @@ files:
|
|
402
384
|
- src/win32/screen.cpp
|
403
385
|
- src/win32/screen.h
|
404
386
|
- src/win32/window.cpp
|
387
|
+
- src/win32/window.h
|
405
388
|
- src/window.cpp
|
406
389
|
- src/window.h
|
407
390
|
- src/world.cpp
|