reflexion 0.1.48 → 0.1.50
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/device.cpp +19 -0
- data/.doc/ext/reflex/native.cpp +4 -0
- data/.doc/ext/reflex/window.cpp +33 -3
- data/ChangeLog.md +11 -0
- data/VERSION +1 -1
- data/ext/reflex/device.cpp +20 -0
- data/ext/reflex/native.cpp +4 -0
- data/ext/reflex/window.cpp +38 -6
- data/include/reflex/device.h +17 -0
- data/include/reflex/window.h +9 -1
- data/include/reflex.h +2 -0
- data/lib/reflex/window.rb +6 -0
- data/src/ios/device.mm +34 -0
- data/src/ios/view_controller.mm +31 -0
- data/src/ios/window.mm +98 -7
- data/src/osx/device.mm +19 -0
- data/src/osx/window.mm +6 -0
- data/src/shape.cpp +18 -19
- data/src/window.cpp +14 -0
- data/test/test_device.rb +10 -0
- data/test/test_window.rb +12 -0
- metadata +10 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 3f773bc073d0b238097405ee034cb7ae208307de725aebb5a6d3d1c21f38aa51
|
|
4
|
+
data.tar.gz: f746663ff6c04b5d81f0f16e7f175fecbea9a4ede0de64d97cd61e3265b9c593
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 065d20a7dc69dd9ed125b25767c00debab6afc4b79598cf3843536dea0f58258e56fb751d5e0684043c19d3cfe6dcf8e3ffd68977f5ad03076f3a0ea0594d49e
|
|
7
|
+
data.tar.gz: d2ef78f91a79970059f4073f9e3943d166961c26bc5a00ccbf474af8db89f08fdcb7edcc7c63d4ea710139f8d9e24cb3dda6160b82342acd850a273c5291bfd4
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
#include "reflex/device.h"
|
|
2
|
+
#include "defs.h"
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
static
|
|
6
|
+
VALUE vibrate(VALUE self)
|
|
7
|
+
{
|
|
8
|
+
Reflex::vibrate();
|
|
9
|
+
return self;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
void
|
|
14
|
+
Init_reflex_device ()
|
|
15
|
+
{
|
|
16
|
+
Module mReflex = rb_define_module("Reflex");
|
|
17
|
+
|
|
18
|
+
rb_define_singleton_method(mReflex, "vibrate", RUBY_METHOD_FUNC(vibrate), 0);
|
|
19
|
+
}
|
data/.doc/ext/reflex/native.cpp
CHANGED
|
@@ -36,6 +36,8 @@ void Init_reflex_screen ();
|
|
|
36
36
|
void Init_reflex_window ();
|
|
37
37
|
void Init_reflex_view ();
|
|
38
38
|
|
|
39
|
+
void Init_reflex_device ();
|
|
40
|
+
|
|
39
41
|
void Init_reflex_image_view ();
|
|
40
42
|
|
|
41
43
|
|
|
@@ -85,6 +87,8 @@ extern "C" void
|
|
|
85
87
|
Init_reflex_window();
|
|
86
88
|
Init_reflex_view();
|
|
87
89
|
|
|
90
|
+
Init_reflex_device();
|
|
91
|
+
|
|
88
92
|
Init_reflex_image_view();
|
|
89
93
|
|
|
90
94
|
RUCY_CATCH
|
data/.doc/ext/reflex/window.cpp
CHANGED
|
@@ -166,6 +166,31 @@ VALUE is_resizable(VALUE self)
|
|
|
166
166
|
return value(THIS->has_flag(Reflex::Window::FLAG_RESIZABLE));
|
|
167
167
|
}
|
|
168
168
|
|
|
169
|
+
static const uint ORIENTATION_MASK =
|
|
170
|
+
Reflex::Window::FLAG_PORTRAIT | Reflex::Window::FLAG_LANDSCAPE;
|
|
171
|
+
|
|
172
|
+
static
|
|
173
|
+
VALUE set_orientations(VALUE self, VALUE orientations)
|
|
174
|
+
{
|
|
175
|
+
using namespace Reflex;
|
|
176
|
+
|
|
177
|
+
CHECK;
|
|
178
|
+
|
|
179
|
+
uint flags = to<uint>(orientations);
|
|
180
|
+
THIS->set_flag(
|
|
181
|
+
( flags & ORIENTATION_MASK) |
|
|
182
|
+
(THIS->flags() & ~ORIENTATION_MASK));
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
static
|
|
186
|
+
VALUE get_orientations(VALUE self)
|
|
187
|
+
{
|
|
188
|
+
using namespace Reflex;
|
|
189
|
+
|
|
190
|
+
CHECK;
|
|
191
|
+
return value(THIS->flags() & ORIENTATION_MASK);
|
|
192
|
+
}
|
|
193
|
+
|
|
169
194
|
static
|
|
170
195
|
VALUE get_screen(VALUE self)
|
|
171
196
|
{
|
|
@@ -345,11 +370,13 @@ Init_reflex_window ()
|
|
|
345
370
|
rb_define_method(cWindow, "frame=", RUBY_METHOD_FUNC(set_frame), -1);
|
|
346
371
|
rb_define_method(cWindow, "frame", RUBY_METHOD_FUNC(get_frame), 0);
|
|
347
372
|
rb_define_method(cWindow, "closable=", RUBY_METHOD_FUNC(set_closable), 1);
|
|
348
|
-
cWindow.define_method("closable?",
|
|
373
|
+
cWindow.define_method("closable?", is_closable);
|
|
349
374
|
rb_define_method(cWindow, "minimizable=", RUBY_METHOD_FUNC(set_minimizable), 1);
|
|
350
|
-
cWindow.define_method("minimizable?",
|
|
375
|
+
cWindow.define_method("minimizable?", is_minimizable);
|
|
351
376
|
rb_define_method(cWindow, "resizable=", RUBY_METHOD_FUNC(set_resizable), 1);
|
|
352
|
-
cWindow.define_method("resizable?",
|
|
377
|
+
cWindow.define_method("resizable?", is_resizable);
|
|
378
|
+
rb_define_method(cWindow, "orientations=", RUBY_METHOD_FUNC(set_orientations), 1);
|
|
379
|
+
rb_define_method(cWindow, "orientations", RUBY_METHOD_FUNC(get_orientations), 0);
|
|
353
380
|
rb_define_method(cWindow, "hidden", RUBY_METHOD_FUNC(hidden), 0);
|
|
354
381
|
rb_define_method(cWindow, "screen", RUBY_METHOD_FUNC(get_screen), 0);
|
|
355
382
|
rb_define_method(cWindow, "root", RUBY_METHOD_FUNC(get_root), 0);
|
|
@@ -373,6 +400,9 @@ Init_reflex_window ()
|
|
|
373
400
|
rb_define_method(cWindow, "on_pointer_move", RUBY_METHOD_FUNC(on_pointer_move), 1);
|
|
374
401
|
rb_define_method(cWindow, "on_pointer_cancel", RUBY_METHOD_FUNC(on_pointer_cancel), 1);
|
|
375
402
|
rb_define_method(cWindow, "on_wheel", RUBY_METHOD_FUNC(on_wheel), 1);
|
|
403
|
+
|
|
404
|
+
cWindow.define_const("ORIENTATION_PORTRAIT", Reflex::Window::FLAG_PORTRAIT);
|
|
405
|
+
cWindow.define_const("ORIENTATION_LANDSCAPE", Reflex::Window::FLAG_LANDSCAPE);
|
|
376
406
|
}
|
|
377
407
|
|
|
378
408
|
|
data/ChangeLog.md
CHANGED
|
@@ -1,6 +1,17 @@
|
|
|
1
1
|
# reflex ChangeLog
|
|
2
2
|
|
|
3
3
|
|
|
4
|
+
## [v0.1.50] - 2023-07-30
|
|
5
|
+
|
|
6
|
+
- add Window::FLAG_PORTRAIT and Window::FLAG_LANDSCAPE
|
|
7
|
+
- add Reflex.vibrate()
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
## [v0.1.49] - 2023-07-11
|
|
11
|
+
|
|
12
|
+
- Fix assertion fail if the view size is 0
|
|
13
|
+
|
|
14
|
+
|
|
4
15
|
## [v0.1.48] - 2023-07-10
|
|
5
16
|
|
|
6
17
|
- Fix a problem that a rectangle shape would be split into 2 triangles for physics
|
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.1.
|
|
1
|
+
0.1.50
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
#include "reflex/device.h"
|
|
2
|
+
#include "defs.h"
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
static
|
|
6
|
+
RUCY_DEF0(vibrate)
|
|
7
|
+
{
|
|
8
|
+
Reflex::vibrate();
|
|
9
|
+
return self;
|
|
10
|
+
}
|
|
11
|
+
RUCY_END
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
void
|
|
15
|
+
Init_reflex_device ()
|
|
16
|
+
{
|
|
17
|
+
Module mReflex = define_module("Reflex");
|
|
18
|
+
|
|
19
|
+
mReflex.define_singleton_method("vibrate", vibrate);
|
|
20
|
+
}
|
data/ext/reflex/native.cpp
CHANGED
|
@@ -36,6 +36,8 @@ void Init_reflex_screen ();
|
|
|
36
36
|
void Init_reflex_window ();
|
|
37
37
|
void Init_reflex_view ();
|
|
38
38
|
|
|
39
|
+
void Init_reflex_device ();
|
|
40
|
+
|
|
39
41
|
void Init_reflex_image_view ();
|
|
40
42
|
|
|
41
43
|
|
|
@@ -85,6 +87,8 @@ extern "C" void
|
|
|
85
87
|
Init_reflex_window();
|
|
86
88
|
Init_reflex_view();
|
|
87
89
|
|
|
90
|
+
Init_reflex_device();
|
|
91
|
+
|
|
88
92
|
Init_reflex_image_view();
|
|
89
93
|
|
|
90
94
|
RUCY_CATCH
|
data/ext/reflex/window.cpp
CHANGED
|
@@ -184,6 +184,33 @@ RUCY_DEF0(is_resizable)
|
|
|
184
184
|
}
|
|
185
185
|
RUCY_END
|
|
186
186
|
|
|
187
|
+
static const uint ORIENTATION_MASK =
|
|
188
|
+
Reflex::Window::FLAG_PORTRAIT | Reflex::Window::FLAG_LANDSCAPE;
|
|
189
|
+
|
|
190
|
+
static
|
|
191
|
+
RUCY_DEF1(set_orientations, orientations)
|
|
192
|
+
{
|
|
193
|
+
using namespace Reflex;
|
|
194
|
+
|
|
195
|
+
CHECK;
|
|
196
|
+
|
|
197
|
+
uint flags = to<uint>(orientations);
|
|
198
|
+
THIS->set_flag(
|
|
199
|
+
( flags & ORIENTATION_MASK) |
|
|
200
|
+
(THIS->flags() & ~ORIENTATION_MASK));
|
|
201
|
+
}
|
|
202
|
+
RUCY_END
|
|
203
|
+
|
|
204
|
+
static
|
|
205
|
+
RUCY_DEF0(get_orientations)
|
|
206
|
+
{
|
|
207
|
+
using namespace Reflex;
|
|
208
|
+
|
|
209
|
+
CHECK;
|
|
210
|
+
return value(THIS->flags() & ORIENTATION_MASK);
|
|
211
|
+
}
|
|
212
|
+
RUCY_END
|
|
213
|
+
|
|
187
214
|
static
|
|
188
215
|
RUCY_DEF0(get_screen)
|
|
189
216
|
{
|
|
@@ -384,12 +411,14 @@ Init_reflex_window ()
|
|
|
384
411
|
cWindow.define_method("title", get_title);
|
|
385
412
|
cWindow.define_method("frame=", set_frame);
|
|
386
413
|
cWindow.define_method("frame", get_frame);
|
|
387
|
-
cWindow.define_method("closable=",
|
|
388
|
-
cWindow.define_method("closable?",
|
|
389
|
-
cWindow.define_method("minimizable=",
|
|
390
|
-
cWindow.define_method("minimizable?",
|
|
391
|
-
cWindow.define_method("resizable=",
|
|
392
|
-
cWindow.define_method("resizable?",
|
|
414
|
+
cWindow.define_method("closable=", set_closable);
|
|
415
|
+
cWindow.define_method("closable?", is_closable);
|
|
416
|
+
cWindow.define_method("minimizable=", set_minimizable);
|
|
417
|
+
cWindow.define_method("minimizable?", is_minimizable);
|
|
418
|
+
cWindow.define_method("resizable=", set_resizable);
|
|
419
|
+
cWindow.define_method("resizable?", is_resizable);
|
|
420
|
+
cWindow.define_method("orientations=", set_orientations);
|
|
421
|
+
cWindow.define_method("orientations", get_orientations);
|
|
393
422
|
cWindow.define_method("hidden", hidden);
|
|
394
423
|
cWindow.define_method("screen", get_screen);
|
|
395
424
|
cWindow.define_method("root", get_root);
|
|
@@ -413,6 +442,9 @@ Init_reflex_window ()
|
|
|
413
442
|
cWindow.define_method("on_pointer_move", on_pointer_move);
|
|
414
443
|
cWindow.define_method("on_pointer_cancel", on_pointer_cancel);
|
|
415
444
|
cWindow.define_method("on_wheel", on_wheel);
|
|
445
|
+
|
|
446
|
+
cWindow.define_const("ORIENTATION_PORTRAIT", Reflex::Window::FLAG_PORTRAIT);
|
|
447
|
+
cWindow.define_const("ORIENTATION_LANDSCAPE", Reflex::Window::FLAG_LANDSCAPE);
|
|
416
448
|
}
|
|
417
449
|
|
|
418
450
|
|
data/include/reflex/window.h
CHANGED
|
@@ -39,7 +39,11 @@ namespace Reflex
|
|
|
39
39
|
|
|
40
40
|
FLAG_RESIZABLE = Xot::bit(2),
|
|
41
41
|
|
|
42
|
-
|
|
42
|
+
FLAG_PORTRAIT = Xot::bit(3),
|
|
43
|
+
|
|
44
|
+
FLAG_LANDSCAPE = Xot::bit(4),
|
|
45
|
+
|
|
46
|
+
FLAG_LAST = FLAG_LANDSCAPE
|
|
43
47
|
|
|
44
48
|
};// Flag
|
|
45
49
|
|
|
@@ -69,6 +73,10 @@ namespace Reflex
|
|
|
69
73
|
|
|
70
74
|
virtual Bounds frame () const;
|
|
71
75
|
|
|
76
|
+
virtual void set_flag (uint flags);
|
|
77
|
+
|
|
78
|
+
virtual uint flags () const;
|
|
79
|
+
|
|
72
80
|
virtual void add_flag (uint flags);
|
|
73
81
|
|
|
74
82
|
virtual void remove_flag (uint flags);
|
data/include/reflex.h
CHANGED
data/lib/reflex/window.rb
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
require 'forwardable'
|
|
2
2
|
require 'xot/setter'
|
|
3
|
+
require 'xot/bit_flag_accessor'
|
|
3
4
|
require 'xot/universal_accessor'
|
|
4
5
|
require 'xot/block_util'
|
|
5
6
|
require 'xot/inspectable'
|
|
@@ -19,6 +20,11 @@ module Reflex
|
|
|
19
20
|
|
|
20
21
|
extend Forwardable
|
|
21
22
|
|
|
23
|
+
bit_flag_accessor :orientations do
|
|
24
|
+
flag :portrait, ORIENTATION_PORTRAIT
|
|
25
|
+
flag :landscape, ORIENTATION_LANDSCAPE
|
|
26
|
+
end
|
|
27
|
+
|
|
22
28
|
def_delegators :root,
|
|
23
29
|
:add_child, :add,
|
|
24
30
|
:remove_child, :remove,
|
data/src/ios/device.mm
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// -*- objc -*-
|
|
2
|
+
#include "reflex/device.h"
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
#import <UIKit/UIKit.h>
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
namespace Reflex
|
|
9
|
+
{
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
static UIImpactFeedbackGenerator* g_feedback_generator = nil;
|
|
13
|
+
|
|
14
|
+
static UIImpactFeedbackGenerator*
|
|
15
|
+
get_feedback_generator ()
|
|
16
|
+
{
|
|
17
|
+
if (g_feedback_generator == nil)
|
|
18
|
+
{
|
|
19
|
+
g_feedback_generator =
|
|
20
|
+
[[UIImpactFeedbackGenerator alloc]
|
|
21
|
+
initWithStyle: UIImpactFeedbackStyleLight];
|
|
22
|
+
}
|
|
23
|
+
return g_feedback_generator;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
void
|
|
27
|
+
viberate ()
|
|
28
|
+
{
|
|
29
|
+
//[get_feedback_generator() prepare];
|
|
30
|
+
[get_feedback_generator() impactOccurred];
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
}// Reflex
|
data/src/ios/view_controller.mm
CHANGED
|
@@ -440,6 +440,37 @@ ReflexViewController_get_show_fun ()
|
|
|
440
440
|
}
|
|
441
441
|
}
|
|
442
442
|
|
|
443
|
+
#if 0
|
|
444
|
+
- (BOOL)shouldAutorotate
|
|
445
|
+
{
|
|
446
|
+
Reflex::Window* win = self.window;
|
|
447
|
+
if (!win) return [super shouldAutorotate];
|
|
448
|
+
|
|
449
|
+
return win->has_flag(Reflex::Window::FLAG_RESIZABLE);
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
- (UIInterfaceOrientationMask)supportedInterfaceOrientations
|
|
453
|
+
{
|
|
454
|
+
Reflex::Window* win = self.window;
|
|
455
|
+
if (!win || !win->has_flag(Reflex::Window::FLAG_RESIZABLE))
|
|
456
|
+
return UIInterfaceOrientationMaskAll;
|
|
457
|
+
|
|
458
|
+
UIInterfaceOrientationMask mask = 0;
|
|
459
|
+
|
|
460
|
+
if (win->has_flag(Reflex::Window::FLAG_PORTRAIT))
|
|
461
|
+
{
|
|
462
|
+
mask |=
|
|
463
|
+
UIInterfaceOrientationMaskPortrait |
|
|
464
|
+
UIInterfaceOrientationMaskPortraitUpsideDown;
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
if (win->has_flag(Reflex::Window::FLAG_LANDSCAPE))
|
|
468
|
+
mask |= UIInterfaceOrientationMaskLandscape;
|
|
469
|
+
|
|
470
|
+
return mask;
|
|
471
|
+
}
|
|
472
|
+
#endif
|
|
473
|
+
|
|
443
474
|
- (void) titleDidChange
|
|
444
475
|
{
|
|
445
476
|
}
|
data/src/ios/window.mm
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
#include "window.h"
|
|
3
3
|
|
|
4
4
|
|
|
5
|
+
#import <UIKit/UIKit.h>
|
|
5
6
|
#include "reflex/exception.h"
|
|
6
7
|
#include "screen.h"
|
|
7
8
|
#import "view_controller.h"
|
|
@@ -52,7 +53,10 @@ namespace Reflex
|
|
|
52
53
|
uint
|
|
53
54
|
Window_default_flags ()
|
|
54
55
|
{
|
|
55
|
-
return
|
|
56
|
+
return
|
|
57
|
+
Window::FLAG_RESIZABLE |
|
|
58
|
+
Window::FLAG_PORTRAIT |
|
|
59
|
+
Window::FLAG_LANDSCAPE;
|
|
56
60
|
}
|
|
57
61
|
|
|
58
62
|
void
|
|
@@ -138,6 +142,96 @@ namespace Reflex
|
|
|
138
142
|
return Bounds(b.origin.x, b.origin.y, b.size.width, b.size.height);
|
|
139
143
|
}
|
|
140
144
|
|
|
145
|
+
static UIInterfaceOrientationMask g_orientation_mask =
|
|
146
|
+
UIInterfaceOrientationMaskAll;
|
|
147
|
+
|
|
148
|
+
static UIInterfaceOrientation
|
|
149
|
+
current_orientation (UIViewController* vc)
|
|
150
|
+
{
|
|
151
|
+
switch (UIDevice.currentDevice.orientation)
|
|
152
|
+
{
|
|
153
|
+
case UIDeviceOrientationPortrait: return UIInterfaceOrientationPortrait;
|
|
154
|
+
case UIDeviceOrientationLandscapeLeft: return UIInterfaceOrientationLandscapeLeft;
|
|
155
|
+
case UIDeviceOrientationLandscapeRight: return UIInterfaceOrientationLandscapeRight;
|
|
156
|
+
case UIDeviceOrientationPortraitUpsideDown: return UIInterfaceOrientationPortraitUpsideDown;
|
|
157
|
+
default: return vc.preferredInterfaceOrientationForPresentation;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
static UIInterfaceOrientationMask
|
|
162
|
+
to_mask (UIInterfaceOrientation orientation)
|
|
163
|
+
{
|
|
164
|
+
switch (orientation)
|
|
165
|
+
{
|
|
166
|
+
case UIInterfaceOrientationPortrait: return UIInterfaceOrientationMaskPortrait;
|
|
167
|
+
case UIInterfaceOrientationLandscapeLeft: return UIInterfaceOrientationMaskLandscapeLeft;
|
|
168
|
+
case UIInterfaceOrientationLandscapeRight: return UIInterfaceOrientationMaskLandscapeRight;
|
|
169
|
+
case UIInterfaceOrientationPortraitUpsideDown: return UIInterfaceOrientationMaskPortraitUpsideDown;
|
|
170
|
+
default: return 0;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
static UIInterfaceOrientation
|
|
175
|
+
get_proper_orientation (UIViewController* vc, UIInterfaceOrientationMask mask)
|
|
176
|
+
{
|
|
177
|
+
UIInterfaceOrientation current = current_orientation(vc);
|
|
178
|
+
if (to_mask(current) & mask) return current;
|
|
179
|
+
if (UIInterfaceOrientationMaskPortrait & mask) return UIInterfaceOrientationPortrait;
|
|
180
|
+
if (UIInterfaceOrientationMaskLandscapeLeft & mask) return UIInterfaceOrientationLandscapeLeft;
|
|
181
|
+
if (UIInterfaceOrientationMaskLandscapeRight & mask) return UIInterfaceOrientationLandscapeRight;
|
|
182
|
+
if (UIInterfaceOrientationMaskPortraitUpsideDown & mask) return UIInterfaceOrientationPortraitUpsideDown;
|
|
183
|
+
return UIInterfaceOrientationPortrait;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
static void
|
|
187
|
+
update_orientation_mask (UIViewController* vc, UIInterfaceOrientationMask mask)
|
|
188
|
+
{
|
|
189
|
+
if (!vc) return;
|
|
190
|
+
|
|
191
|
+
if (@available(iOS 16.0, *))
|
|
192
|
+
[vc setNeedsUpdateOfSupportedInterfaceOrientations];
|
|
193
|
+
else
|
|
194
|
+
{
|
|
195
|
+
[UIDevice.currentDevice
|
|
196
|
+
setValue: [NSNumber numberWithInteger: get_proper_orientation(vc, mask)]
|
|
197
|
+
forKey: @"orientation"];
|
|
198
|
+
[UIViewController attemptRotationToDeviceOrientation];
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
void
|
|
203
|
+
Window_set_orientation_mask (UIViewController* vc, UIInterfaceOrientationMask mask)
|
|
204
|
+
{
|
|
205
|
+
if (mask == g_orientation_mask) return;
|
|
206
|
+
|
|
207
|
+
g_orientation_mask = mask;
|
|
208
|
+
update_orientation_mask(vc, mask);
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
UIInterfaceOrientationMask
|
|
212
|
+
Window_get_orientation_mask ()
|
|
213
|
+
{
|
|
214
|
+
return g_orientation_mask;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
static UIInterfaceOrientationMask
|
|
218
|
+
flags_to_orientation_mask (uint flags)
|
|
219
|
+
{
|
|
220
|
+
UIInterfaceOrientationMask mask = 0;
|
|
221
|
+
|
|
222
|
+
if (flags & Window::FLAG_PORTRAIT)
|
|
223
|
+
{
|
|
224
|
+
mask |=
|
|
225
|
+
UIInterfaceOrientationMaskPortrait |
|
|
226
|
+
UIInterfaceOrientationPortraitUpsideDown;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
if (flags & Window::FLAG_LANDSCAPE)
|
|
230
|
+
mask |= UIInterfaceOrientationMaskLandscape;
|
|
231
|
+
|
|
232
|
+
return mask != 0 ? mask : UIInterfaceOrientationMaskAll;
|
|
233
|
+
}
|
|
234
|
+
|
|
141
235
|
void
|
|
142
236
|
Window_set_flags (Window* window, uint flags)
|
|
143
237
|
{
|
|
@@ -147,8 +241,9 @@ namespace Reflex
|
|
|
147
241
|
if (Xot::has_flag(flags, Window::FLAG_MINIMIZABLE))
|
|
148
242
|
argument_error(__FILE__, __LINE__, "FLAG_MINIMIZABLE is not supported");
|
|
149
243
|
|
|
150
|
-
|
|
151
|
-
|
|
244
|
+
Window_set_orientation_mask(
|
|
245
|
+
get_vc(window),
|
|
246
|
+
flags_to_orientation_mask(flags & (Window::FLAG_PORTRAIT | Window::FLAG_LANDSCAPE)));
|
|
152
247
|
}
|
|
153
248
|
|
|
154
249
|
static UIScreen*
|
|
@@ -156,13 +251,9 @@ namespace Reflex
|
|
|
156
251
|
{
|
|
157
252
|
UIWindow* w = get_vc(&window).view.window;
|
|
158
253
|
if (@available(iOS 13.0, *))
|
|
159
|
-
{
|
|
160
254
|
return w.windowScene.screen;
|
|
161
|
-
}
|
|
162
255
|
else
|
|
163
|
-
{
|
|
164
256
|
return w.screen;
|
|
165
|
-
}
|
|
166
257
|
}
|
|
167
258
|
|
|
168
259
|
Screen
|
data/src/osx/device.mm
ADDED
data/src/osx/window.mm
CHANGED
|
@@ -142,6 +142,12 @@ namespace Reflex
|
|
|
142
142
|
void
|
|
143
143
|
Window_set_flags (Window* window, uint flags)
|
|
144
144
|
{
|
|
145
|
+
if (Xot::has_flag(flags, Window::FLAG_PORTRAIT))
|
|
146
|
+
argument_error(__FILE__, __LINE__, "FLAG_PORTRAIT is not supported");
|
|
147
|
+
|
|
148
|
+
if (Xot::has_flag(flags, Window::FLAG_LANDSCAPE))
|
|
149
|
+
argument_error(__FILE__, __LINE__, "FLAG_LANDSCAPE is not supported");
|
|
150
|
+
|
|
145
151
|
NativeWindow* native = get_native(window);
|
|
146
152
|
NSWindowStyleMask styleMask =
|
|
147
153
|
Window_make_style_mask(window->self->flags, native.styleMask);
|
data/src/shape.cpp
CHANGED
|
@@ -795,28 +795,28 @@ namespace Reflex
|
|
|
795
795
|
|
|
796
796
|
Fixture* create_fixtures (Shape* shape) override
|
|
797
797
|
{
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
return
|
|
798
|
+
Bounds frame = get_frame();
|
|
799
|
+
bool rect = frame.size() != 0;
|
|
800
|
+
if (rect && !has_rounds())
|
|
801
|
+
return create_rect_fixture(shape, frame);
|
|
802
|
+
else if (rect && nsegment <= 1)
|
|
803
|
+
return create_rect_fixture_without_division(shape, frame);
|
|
802
804
|
else
|
|
803
805
|
return Super::create_fixtures(shape);
|
|
804
806
|
}
|
|
805
807
|
|
|
806
|
-
Fixture* create_rect_fixture (Shape* shape)
|
|
808
|
+
Fixture* create_rect_fixture (Shape* shape, const Bounds& frame)
|
|
807
809
|
{
|
|
808
810
|
assert(shape);
|
|
809
811
|
|
|
810
812
|
if (!owner)
|
|
811
813
|
invalid_state_error(__FILE__, __LINE__);
|
|
812
814
|
|
|
813
|
-
Bounds f = get_frame();
|
|
814
815
|
float ppm = owner->meter2pixel();
|
|
815
|
-
|
|
816
|
-
coord
|
|
817
|
-
coord
|
|
818
|
-
coord
|
|
819
|
-
coord b = to_b2coord(f.x + f.h, ppm);
|
|
816
|
+
coord l = to_b2coord(frame.x, ppm);
|
|
817
|
+
coord t = to_b2coord(frame.y, ppm);
|
|
818
|
+
coord r = to_b2coord(frame.x + frame.w, ppm);
|
|
819
|
+
coord b = to_b2coord(frame.x + frame.h, ppm);
|
|
820
820
|
b2Vec2 b2points[] = {{l, t}, {l, b}, {r, b}, {r, t}};
|
|
821
821
|
|
|
822
822
|
b2PolygonShape b2shape;
|
|
@@ -825,23 +825,22 @@ namespace Reflex
|
|
|
825
825
|
return FixtureBuilder(shape, &b2shape).fixtures();
|
|
826
826
|
}
|
|
827
827
|
|
|
828
|
-
Fixture* create_rect_fixture_without_division (
|
|
828
|
+
Fixture* create_rect_fixture_without_division (
|
|
829
|
+
Shape* shape, const Bounds& frame)
|
|
829
830
|
{
|
|
830
831
|
assert(shape);
|
|
831
832
|
|
|
832
833
|
if (!owner)
|
|
833
834
|
invalid_state_error(__FILE__, __LINE__);
|
|
834
835
|
|
|
835
|
-
Bounds f = get_frame();
|
|
836
|
-
float ppm = owner->meter2pixel();
|
|
837
|
-
|
|
838
836
|
Polygon polygon = Rays::create_rect(
|
|
839
|
-
|
|
837
|
+
frame.x, frame.y, frame.width, frame.height,
|
|
840
838
|
round_left_top, round_right_top,
|
|
841
839
|
round_left_bottom, round_right_bottom,
|
|
842
840
|
1);
|
|
843
841
|
assert(polygon.size() == 1);
|
|
844
842
|
|
|
843
|
+
float ppm = owner->meter2pixel();
|
|
845
844
|
const Polyline& polyline = polygon[0];
|
|
846
845
|
assert(polyline[0].size() <= 8);
|
|
847
846
|
|
|
@@ -1030,10 +1029,10 @@ namespace Reflex
|
|
|
1030
1029
|
|
|
1031
1030
|
Fixture* create_fixtures (Shape* shape) override
|
|
1032
1031
|
{
|
|
1033
|
-
Bounds
|
|
1034
|
-
bool circle
|
|
1032
|
+
Bounds frame = get_frame();
|
|
1033
|
+
bool circle = frame.size() != 0 && frame.width == frame.height;
|
|
1035
1034
|
if (circle && !has_angle() && !has_hole() && has_fill(shape))
|
|
1036
|
-
return create_circle_fixture(shape,
|
|
1035
|
+
return create_circle_fixture(shape, frame);
|
|
1037
1036
|
else
|
|
1038
1037
|
return Super::create_fixtures(shape);
|
|
1039
1038
|
}
|
data/src/window.cpp
CHANGED
|
@@ -546,6 +546,20 @@ namespace Reflex
|
|
|
546
546
|
return Window_get_frame(*this);
|
|
547
547
|
}
|
|
548
548
|
|
|
549
|
+
void
|
|
550
|
+
Window::set_flag (uint flags)
|
|
551
|
+
{
|
|
552
|
+
Window_set_flags(this, flags);
|
|
553
|
+
|
|
554
|
+
self->flags = flags;
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
uint
|
|
558
|
+
Window::flags () const
|
|
559
|
+
{
|
|
560
|
+
return self->flags;
|
|
561
|
+
}
|
|
562
|
+
|
|
549
563
|
void
|
|
550
564
|
Window::add_flag (uint flags)
|
|
551
565
|
{
|
data/test/test_device.rb
ADDED
data/test/test_window.rb
CHANGED
|
@@ -121,6 +121,18 @@ class TestWindow < Test::Unit::TestCase
|
|
|
121
121
|
assert_true w.resizable?
|
|
122
122
|
end
|
|
123
123
|
|
|
124
|
+
def test_orientations()
|
|
125
|
+
w = win
|
|
126
|
+
assert_equal [], w.orientations
|
|
127
|
+
|
|
128
|
+
assert_raise(ArgumentError) {w.orientations = [:portrait]}.then do |e|
|
|
129
|
+
assert_match /portrait.*not supported/i, e.message
|
|
130
|
+
end
|
|
131
|
+
assert_raise(ArgumentError) {w.orientations = [:landscape]}.then do |e|
|
|
132
|
+
assert_match /landscape.*not supported/i, e.message
|
|
133
|
+
end
|
|
134
|
+
end
|
|
135
|
+
|
|
124
136
|
def test_screen()
|
|
125
137
|
assert_not_nil win.screen
|
|
126
138
|
end
|
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.50
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- xordog
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2023-07-
|
|
11
|
+
date: 2023-07-30 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: xot
|
|
@@ -103,6 +103,7 @@ extra_rdoc_files:
|
|
|
103
103
|
- ".doc/ext/reflex/application.cpp"
|
|
104
104
|
- ".doc/ext/reflex/capture_event.cpp"
|
|
105
105
|
- ".doc/ext/reflex/contact_event.cpp"
|
|
106
|
+
- ".doc/ext/reflex/device.cpp"
|
|
106
107
|
- ".doc/ext/reflex/draw_event.cpp"
|
|
107
108
|
- ".doc/ext/reflex/ellipse_shape.cpp"
|
|
108
109
|
- ".doc/ext/reflex/event.cpp"
|
|
@@ -136,6 +137,7 @@ files:
|
|
|
136
137
|
- ".doc/ext/reflex/application.cpp"
|
|
137
138
|
- ".doc/ext/reflex/capture_event.cpp"
|
|
138
139
|
- ".doc/ext/reflex/contact_event.cpp"
|
|
140
|
+
- ".doc/ext/reflex/device.cpp"
|
|
139
141
|
- ".doc/ext/reflex/draw_event.cpp"
|
|
140
142
|
- ".doc/ext/reflex/ellipse_shape.cpp"
|
|
141
143
|
- ".doc/ext/reflex/event.cpp"
|
|
@@ -178,6 +180,7 @@ files:
|
|
|
178
180
|
- ext/reflex/capture_event.cpp
|
|
179
181
|
- ext/reflex/contact_event.cpp
|
|
180
182
|
- ext/reflex/defs.h
|
|
183
|
+
- ext/reflex/device.cpp
|
|
181
184
|
- ext/reflex/draw_event.cpp
|
|
182
185
|
- ext/reflex/ellipse_shape.cpp
|
|
183
186
|
- ext/reflex/event.cpp
|
|
@@ -213,6 +216,7 @@ files:
|
|
|
213
216
|
- include/reflex/application.h
|
|
214
217
|
- include/reflex/debug.h
|
|
215
218
|
- include/reflex/defs.h
|
|
219
|
+
- include/reflex/device.h
|
|
216
220
|
- include/reflex/event.h
|
|
217
221
|
- include/reflex/exception.h
|
|
218
222
|
- include/reflex/filter.h
|
|
@@ -352,6 +356,7 @@ files:
|
|
|
352
356
|
- src/ios/app_delegate.mm
|
|
353
357
|
- src/ios/application.h
|
|
354
358
|
- src/ios/application.mm
|
|
359
|
+
- src/ios/device.mm
|
|
355
360
|
- src/ios/event.h
|
|
356
361
|
- src/ios/event.mm
|
|
357
362
|
- src/ios/reflex.mm
|
|
@@ -365,6 +370,7 @@ files:
|
|
|
365
370
|
- src/osx/app_delegate.mm
|
|
366
371
|
- src/osx/application.h
|
|
367
372
|
- src/osx/application.mm
|
|
373
|
+
- src/osx/device.mm
|
|
368
374
|
- src/osx/event.h
|
|
369
375
|
- src/osx/event.mm
|
|
370
376
|
- src/osx/native_window.h
|
|
@@ -403,6 +409,7 @@ files:
|
|
|
403
409
|
- test/test_application.rb
|
|
404
410
|
- test/test_capture_event.rb
|
|
405
411
|
- test/test_contact_event.rb
|
|
412
|
+
- test/test_device.rb
|
|
406
413
|
- test/test_draw_event.rb
|
|
407
414
|
- test/test_event.rb
|
|
408
415
|
- test/test_focus_event.rb
|
|
@@ -453,6 +460,7 @@ test_files:
|
|
|
453
460
|
- test/test_application.rb
|
|
454
461
|
- test/test_capture_event.rb
|
|
455
462
|
- test/test_contact_event.rb
|
|
463
|
+
- test/test_device.rb
|
|
456
464
|
- test/test_draw_event.rb
|
|
457
465
|
- test/test_event.rb
|
|
458
466
|
- test/test_focus_event.rb
|