reflexion 0.1.41 → 0.1.42

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b412c2e913baaeacdd4afff628c339c01a6ce7359572901d6193fc97d772a426
4
- data.tar.gz: f8cba434ac873919a9bd75ea5c5e08d0436eb672313e60541d5634b210b81b76
3
+ metadata.gz: fa7ec97efd9d68e5053ddc3bf852f718a66ff883a5bb8693f605dcf45e962732
4
+ data.tar.gz: f2fd1319de6f1032802ce96c6657e9ac7dc0327a10c9ef9b1ba2f910c117c57a
5
5
  SHA512:
6
- metadata.gz: 7b6f7fd46e08e459010a98facf5c8e800c326f93d0482b0649c4f20a6bc54537947e5e3316285db7e759870c7739c68ab5284fba8f4640fb88e5dc02c106b598
7
- data.tar.gz: a30e5f7bde2f8f9b09ff0e76847d2bbbfefe9187e3888224409ebfe04a72c05e36387ab4a976f0dd385f1ead5aa749d1ba8478182030e73058879792b0ca051e
6
+ metadata.gz: 61d0f5a9fc7ec41480642825f071d103d211035a38bcfda25eb90789fb642cf2663dce3f18771cc3702482e0a78d0385c4601ab23b4654f677f946af6000b425
7
+ data.tar.gz: abd4d92237cd9d49795ce5010b38565d7f3a4abd0b73ae4b18ca1989e748e911144ac3b11bdc6869400599c8eac6f120f751f75484c821a483b7475aefcec78a
data/ChangeLog.md CHANGED
@@ -1,6 +1,14 @@
1
1
  # reflex ChangeLog
2
2
 
3
3
 
4
+ ## [v0.1.42] - 2023-06-02
5
+
6
+ - Implement the Screen class for iOS
7
+ - Implement Window_get_screen() for iOS
8
+ - Implement window flags for iOS
9
+ - Update reflexView's size on viewDidLayoutSubviews
10
+
11
+
4
12
  ## [v0.1.41] - 2023-05-29
5
13
 
6
14
  - Add Reflex::Screen class
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.41
1
+ 0.1.42
data/src/ios/screen.h ADDED
@@ -0,0 +1,20 @@
1
+ // -*- c++ -*-
2
+ #pragma once
3
+ #ifndef __REFLEX_SRC_IOS_SCREEN_H__
4
+ #define __REFLEX_SRC_IOS_SCREEN_H__
5
+
6
+
7
+ #include "reflex/screen.h"
8
+
9
+
10
+ namespace Reflex
11
+ {
12
+
13
+
14
+ void Screen_initialize (Screen* pthis, UIScreen* screen);
15
+
16
+
17
+ }// Reflex
18
+
19
+
20
+ #endif//EOH
data/src/ios/screen.mm ADDED
@@ -0,0 +1,62 @@
1
+ // -*- mode: objc -*-
2
+ #include "screen.h"
3
+
4
+
5
+ #include "reflex/exception.h"
6
+
7
+
8
+ namespace Reflex
9
+ {
10
+
11
+
12
+ struct Screen::Data
13
+ {
14
+
15
+ UIScreen* screen = nil;
16
+
17
+ ~Data ()
18
+ {
19
+ if (screen) [screen release];
20
+ }
21
+
22
+ };// Screen::Data
23
+
24
+
25
+ void
26
+ Screen_initialize (Screen* pthis, UIScreen* screen)
27
+ {
28
+ pthis->self->screen = [screen retain];
29
+ }
30
+
31
+
32
+ Screen::Screen ()
33
+ {
34
+ }
35
+
36
+ Screen::~Screen ()
37
+ {
38
+ }
39
+
40
+ Bounds
41
+ Screen::frame () const
42
+ {
43
+ if (!*this)
44
+ invalid_state_error(__FILE__, __LINE__);
45
+
46
+ CGRect b = self->screen.bounds;
47
+ return Bounds(b.origin.x, b.origin.y, b.size.width, b.size.height);
48
+ }
49
+
50
+ Screen::operator bool () const
51
+ {
52
+ return self->screen;
53
+ }
54
+
55
+ bool
56
+ Screen::operator ! () const
57
+ {
58
+ return !operator bool();
59
+ }
60
+
61
+
62
+ }// Reflex
@@ -17,6 +17,8 @@
17
17
 
18
18
  - (void) stopTimer;
19
19
 
20
+ - (void) update;
21
+
20
22
  - (void) viewDidResize;
21
23
 
22
24
  - (void) titleDidChange;
@@ -293,6 +293,12 @@ ReflexViewController_get_show_fun ()
293
293
  [super viewDidDisappear: animated];
294
294
  }
295
295
 
296
+ - (void)viewDidLayoutSubviews
297
+ {
298
+ [super viewDidLayoutSubviews];
299
+ self.reflexView.frame = self.view.bounds;
300
+ }
301
+
296
302
  - (void) startTimer
297
303
  {
298
304
  [self startTimer: 60];
data/src/ios/window.h CHANGED
@@ -17,9 +17,7 @@ namespace Reflex
17
17
  struct WindowData : public Window::Data
18
18
  {
19
19
 
20
- ReflexViewController* view_controller;
21
-
22
- WindowData ();
20
+ ReflexViewController* view_controller = nil;
23
21
 
24
22
  bool is_valid () const
25
23
  {
data/src/ios/window.mm CHANGED
@@ -3,6 +3,7 @@
3
3
 
4
4
 
5
5
  #include "reflex/exception.h"
6
+ #include "screen.h"
6
7
  #import "view_controller.h"
7
8
 
8
9
 
@@ -48,6 +49,12 @@ namespace Reflex
48
49
  return new WindowData();
49
50
  }
50
51
 
52
+ uint
53
+ Window_default_flags ()
54
+ {
55
+ return 0;
56
+ }
57
+
51
58
  void
52
59
  Window_initialize (Window* window)
53
60
  {
@@ -127,24 +134,44 @@ namespace Reflex
127
134
  Bounds
128
135
  Window_get_frame (const Window& window)
129
136
  {
130
- CGRect rect = get_vc(&window).reflexView.bounds;
131
- return Bounds(
132
- rect.origin.x,
133
- rect.origin.y,
134
- rect.size.width,
135
- rect.size.height);
137
+ CGRect b = get_vc(&window).reflexView.bounds;
138
+ return Bounds(b.origin.x, b.origin.y, b.size.width, b.size.height);
136
139
  }
137
140
 
138
141
  void
139
- Window_set_resizable (Window* window, bool state)
142
+ Window_set_flags (Window* window, uint flags)
140
143
  {
141
- //not_implemented_error(__FILE__, __LINE__);
144
+ if (Xot::has_flag(flags, Window::FLAG_CLOSABLE))
145
+ argument_error(__FILE__, __LINE__, "FLAG_CLOSABLE is not supported");
146
+
147
+ if (Xot::has_flag(flags, Window::FLAG_MINIMIZABLE))
148
+ argument_error(__FILE__, __LINE__, "FLAG_MINIMIZABLE is not supported");
149
+
150
+ if (Xot::has_flag(flags, Window::FLAG_RESIZABLE))
151
+ argument_error(__FILE__, __LINE__, "FLAG_RESIZABLE is not supported");
152
+ }
153
+
154
+ static UIScreen*
155
+ get_screen (const Window& window)
156
+ {
157
+ UIWindow* w = get_vc(&window).view.window;
158
+ if (@available(iOS 13.0, *))
159
+ {
160
+ return w.windowScene.screen;
161
+ }
162
+ else
163
+ {
164
+ return w.screen;
165
+ }
142
166
  }
143
167
 
144
- bool
145
- Window_is_resizable (const Window& window)
168
+ Screen
169
+ Window_get_screen (const Window& window)
146
170
  {
147
- return false;
171
+ Screen s;
172
+ UIScreen* screen = get_screen(window);
173
+ Screen_initialize(&s, screen ? screen : UIScreen.mainScreen);
174
+ return s;
148
175
  }
149
176
 
150
177
  float
@@ -154,10 +181,4 @@ namespace Reflex
154
181
  }
155
182
 
156
183
 
157
- WindowData::WindowData ()
158
- {
159
- view_controller = nil;
160
- }
161
-
162
-
163
184
  }// Reflex
@@ -15,8 +15,8 @@
15
15
  static NSWindowStyleMask
16
16
  default_style_mask ()
17
17
  {
18
- return Window_make_style_mask(
19
- Reflex::Window::Data::FLAG_DEFAULT,
18
+ return Reflex::Window_make_style_mask(
19
+ Reflex::Window_default_flags(),
20
20
  NSTitledWindowMask | NSTexturedBackgroundWindowMask);
21
21
  }
22
22
 
data/src/osx/screen.mm CHANGED
@@ -2,6 +2,9 @@
2
2
  #include "screen.h"
3
3
 
4
4
 
5
+ #include "reflex/exception.h"
6
+
7
+
5
8
  namespace Reflex
6
9
  {
7
10
 
@@ -37,10 +40,11 @@ namespace Reflex
37
40
  Bounds
38
41
  Screen::frame () const
39
42
  {
40
- NSRect frame = self->screen.frame;
41
- return Bounds(
42
- frame.origin.x, frame.origin.y,
43
- frame.size.width, frame.size.height);
43
+ if (!*this)
44
+ invalid_state_error(__FILE__, __LINE__);
45
+
46
+ NSRect f = self->screen.frame;
47
+ return Bounds(f.origin.x, f.origin.y, f.size.width, f.size.height);
44
48
  }
45
49
 
46
50
  Screen::operator bool () const
data/src/osx/window.h CHANGED
@@ -18,12 +18,10 @@ namespace Reflex
18
18
  struct WindowData : public Window::Data
19
19
  {
20
20
 
21
- NativeWindow* native;
21
+ NativeWindow* native = nil;
22
22
 
23
23
  mutable String title_tmp;
24
24
 
25
- WindowData ();
26
-
27
25
  bool is_valid () const
28
26
  {
29
27
  return native;
data/src/osx/window.mm CHANGED
@@ -70,6 +70,15 @@ namespace Reflex
70
70
  return new WindowData();
71
71
  }
72
72
 
73
+ uint
74
+ Window_default_flags ()
75
+ {
76
+ return
77
+ Window::FLAG_CLOSABLE |
78
+ Window::FLAG_MINIMIZABLE |
79
+ Window::FLAG_RESIZABLE;
80
+ }
81
+
73
82
  void
74
83
  Window_initialize (Window* window)
75
84
  {
@@ -126,12 +135,8 @@ namespace Reflex
126
135
  Window_get_frame (const Window& window)
127
136
  {
128
137
  NativeWindow* native = get_native(&window);
129
- NSRect rect = [native contentRectForFrameRect: [native frame]];
130
- return Bounds(
131
- rect.origin.x,
132
- rect.origin.y,
133
- rect.size.width,
134
- rect.size.height);
138
+ NSRect r = [native contentRectForFrameRect: [native frame]];
139
+ return Bounds(r.origin.x, r.origin.y, r.size.width, r.size.height);
135
140
  }
136
141
 
137
142
  void
@@ -149,8 +154,8 @@ namespace Reflex
149
154
  Window_get_screen (const Window& window)
150
155
  {
151
156
  Screen s;
152
- NativeWindow* native = get_native(&window);
153
- if (native && native.screen) Screen_initialize(&s, native.screen);
157
+ NSScreen* screen = get_native(&window).screen;
158
+ if (screen) Screen_initialize(&s, screen);
154
159
  return s;
155
160
  }
156
161
 
@@ -161,10 +166,4 @@ namespace Reflex
161
166
  }
162
167
 
163
168
 
164
- WindowData::WindowData ()
165
- {
166
- native = nil;
167
- }
168
-
169
-
170
169
  }// Reflex
data/src/window.cpp CHANGED
@@ -22,6 +22,17 @@ namespace Reflex
22
22
  using TargetPointerMap = Window::Data::TargetPointerMap;
23
23
 
24
24
 
25
+ Window::Data::Data ()
26
+ : flags(Window_default_flags())
27
+ {
28
+ prev_time_update = prev_time_draw = Xot::time();
29
+ }
30
+
31
+ Window::Data::~Data ()
32
+ {
33
+ }
34
+
35
+
25
36
  Window::Data::PointerData::PointerData (uint view_index)
26
37
  : view_index(view_index)
27
38
  {
@@ -520,17 +531,23 @@ namespace Reflex
520
531
  void
521
532
  Window::add_flag (uint flags)
522
533
  {
523
- Xot::add_flag(&self->flags, flags);
534
+ uint value = self->flags;
535
+ Xot::add_flag(&value, flags);
524
536
 
525
- Window_set_flags(this, self->flags);
537
+ Window_set_flags(this, value);
538
+
539
+ self->flags = value;
526
540
  }
527
541
 
528
542
  void
529
543
  Window::remove_flag (uint flags)
530
544
  {
531
- Xot::remove_flag(&self->flags, flags);
545
+ uint value = self->flags;
546
+ Xot::remove_flag(&value, flags);
547
+
548
+ Window_set_flags(this, value);
532
549
 
533
- Window_set_flags(this, self->flags);
550
+ self->flags = value;
534
551
  }
535
552
 
536
553
  bool
data/src/window.h CHANGED
@@ -37,8 +37,6 @@ namespace Reflex
37
37
 
38
38
  typedef std::map<View::Ref, TargetPointerMap> CaptureMap;
39
39
 
40
- enum {FLAG_DEFAULT = FLAG_CLOSABLE | FLAG_MINIMIZABLE | FLAG_RESIZABLE};
41
-
42
40
  int hide_count = 1;
43
41
 
44
42
  bool redraw = true;
@@ -53,16 +51,11 @@ namespace Reflex
53
51
 
54
52
  CaptureMap captures;
55
53
 
56
- uint flags = FLAG_DEFAULT;
54
+ uint flags;
57
55
 
58
- Data ()
59
- {
60
- prev_time_update = prev_time_draw = Xot::time();
61
- }
56
+ Data ();
62
57
 
63
- virtual ~Data ()
64
- {
65
- }
58
+ virtual ~Data ();
66
59
 
67
60
  virtual bool is_valid () const = 0;
68
61
 
@@ -81,6 +74,8 @@ namespace Reflex
81
74
 
82
75
  Window::Data* Window_create_data ();
83
76
 
77
+ uint Window_default_flags ();
78
+
84
79
  void Window_initialize (Window* window);
85
80
 
86
81
  void Window_show (Window* window);
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.41
4
+ version: 0.1.42
5
5
  platform: ruby
6
6
  authors:
7
7
  - xordog
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-05-29 00:00:00.000000000 Z
11
+ date: 2023-06-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: xot
@@ -355,6 +355,8 @@ files:
355
355
  - src/ios/event.h
356
356
  - src/ios/event.mm
357
357
  - src/ios/reflex.mm
358
+ - src/ios/screen.h
359
+ - src/ios/screen.mm
358
360
  - src/ios/view_controller.h
359
361
  - src/ios/view_controller.mm
360
362
  - src/ios/window.h