reflexion 0.1.56 → 0.1.57

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: b75a2425ed2b69cbe088066cc1b98fff892a899c015907245b697284d62f7455
4
- data.tar.gz: 5b10afa2ad4999bd0f98066790e8641712fece4e0029893cd6734bc8c4df2776
3
+ metadata.gz: 02fdc15de8ef558e7278dfdff35b09408002fc3f20f3ab0913ac887a72c74ea6
4
+ data.tar.gz: e67ba5410334498eeea9ca321ab29d39a60d837d97fa69945adc041560087829
5
5
  SHA512:
6
- metadata.gz: e76d094345bcf5c78ab57970a99900cefe3dfaf7ff0470ae9af5859767d417897ae422c229197ef5d3a352263335aaa278d9835e8f3e583c33f27ff0343b757a
7
- data.tar.gz: a97686a643c8c2b35115b686aef9cfa509b6c257f42266e703b3d53afed4082ef131dcbdcac73727270936595b2eeee18b988cdf37455060d53be31fa4b052ce
6
+ metadata.gz: 62e8dc0bfb08ad9bcd2403821d351aed82b7bc244abb5dd1267dc7190fb4c2c7aac7f63c7c82b64fad2a372c276332d877e22985e9632baa9ace583c6084e646
7
+ data.tar.gz: ee0dbbdab07c9e1b61ea4b7ee0a9f0ff2de25a8c3e3a8186bd9c7c822c5dc98a6b33d469b9883a688d6a0952eab88e23a0a663d8623476fe412e42169956c0cc
@@ -166,6 +166,26 @@ VALUE is_resizable(VALUE self)
166
166
  return value(THIS->has_flag(Reflex::Window::FLAG_RESIZABLE));
167
167
  }
168
168
 
169
+ static
170
+ VALUE set_fullscreen(VALUE self, VALUE state)
171
+ {
172
+ CHECK;
173
+
174
+ if (state)
175
+ THIS-> add_flag(Reflex::Window::FLAG_FULLSCREEN);
176
+ else
177
+ THIS->remove_flag(Reflex::Window::FLAG_FULLSCREEN);
178
+
179
+ return state;
180
+ }
181
+
182
+ static
183
+ VALUE is_fullscreen(VALUE self)
184
+ {
185
+ CHECK;
186
+ return value(THIS->has_flag(Reflex::Window::FLAG_FULLSCREEN));
187
+ }
188
+
169
189
  static const uint ORIENTATION_MASK =
170
190
  Reflex::Window::FLAG_PORTRAIT | Reflex::Window::FLAG_LANDSCAPE;
171
191
 
@@ -370,11 +390,13 @@ Init_reflex_window ()
370
390
  rb_define_method(cWindow, "frame=", RUBY_METHOD_FUNC(set_frame), -1);
371
391
  rb_define_method(cWindow, "frame", RUBY_METHOD_FUNC(get_frame), 0);
372
392
  rb_define_method(cWindow, "closable=", RUBY_METHOD_FUNC(set_closable), 1);
373
- cWindow.define_method("closable?", is_closable);
393
+ cWindow.define_method("closable?", is_closable);
374
394
  rb_define_method(cWindow, "minimizable=", RUBY_METHOD_FUNC(set_minimizable), 1);
375
- cWindow.define_method("minimizable?", is_minimizable);
395
+ cWindow.define_method("minimizable?", is_minimizable);
376
396
  rb_define_method(cWindow, "resizable=", RUBY_METHOD_FUNC(set_resizable), 1);
377
- cWindow.define_method("resizable?", is_resizable);
397
+ cWindow.define_method("resizable?", is_resizable);
398
+ rb_define_method(cWindow, "fullscreen=", RUBY_METHOD_FUNC(set_fullscreen), 1);
399
+ cWindow.define_method("fullscreen?", is_fullscreen);
378
400
  rb_define_method(cWindow, "orientations=", RUBY_METHOD_FUNC(set_orientations), 1);
379
401
  rb_define_method(cWindow, "orientations", RUBY_METHOD_FUNC(get_orientations), 0);
380
402
  rb_define_method(cWindow, "hidden", RUBY_METHOD_FUNC(hidden), 0);
data/ChangeLog.md CHANGED
@@ -1,6 +1,14 @@
1
1
  # reflex ChangeLog
2
2
 
3
3
 
4
+ ## [v0.1.57] - 2024-02-07
5
+
6
+ - Add Window#fullscreen accessor
7
+ - Window now appears on active screen when displayed
8
+
9
+ - Fix Window#set_frame updating to a position that was lower than the correct position by the height of the window title bar
10
+ - Fix a bug that the window position origin (0, 0) was at the bottom-left corner of the screen; now it is at the top-left corner of the screen
11
+
4
12
  ## [v0.1.56] - 2024-01-08
5
13
 
6
14
  - Delete Polygon::Line because it was merged into Polyline
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.56
1
+ 0.1.57
@@ -184,6 +184,28 @@ RUCY_DEF0(is_resizable)
184
184
  }
185
185
  RUCY_END
186
186
 
187
+ static
188
+ RUCY_DEF1(set_fullscreen, state)
189
+ {
190
+ CHECK;
191
+
192
+ if (state)
193
+ THIS-> add_flag(Reflex::Window::FLAG_FULLSCREEN);
194
+ else
195
+ THIS->remove_flag(Reflex::Window::FLAG_FULLSCREEN);
196
+
197
+ return state;
198
+ }
199
+ RUCY_END
200
+
201
+ static
202
+ RUCY_DEF0(is_fullscreen)
203
+ {
204
+ CHECK;
205
+ return value(THIS->has_flag(Reflex::Window::FLAG_FULLSCREEN));
206
+ }
207
+ RUCY_END
208
+
187
209
  static const uint ORIENTATION_MASK =
188
210
  Reflex::Window::FLAG_PORTRAIT | Reflex::Window::FLAG_LANDSCAPE;
189
211
 
@@ -411,12 +433,14 @@ Init_reflex_window ()
411
433
  cWindow.define_method("title", get_title);
412
434
  cWindow.define_method("frame=", set_frame);
413
435
  cWindow.define_method("frame", get_frame);
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);
436
+ cWindow.define_method("closable=", set_closable);
437
+ cWindow.define_method("closable?", is_closable);
438
+ cWindow.define_method("minimizable=", set_minimizable);
439
+ cWindow.define_method("minimizable?", is_minimizable);
440
+ cWindow.define_method("resizable=", set_resizable);
441
+ cWindow.define_method("resizable?", is_resizable);
442
+ cWindow.define_method("fullscreen=", set_fullscreen);
443
+ cWindow.define_method("fullscreen?", is_fullscreen);
420
444
  cWindow.define_method("orientations=", set_orientations);
421
445
  cWindow.define_method("orientations", get_orientations);
422
446
  cWindow.define_method("hidden", hidden);
@@ -39,9 +39,11 @@ namespace Reflex
39
39
 
40
40
  FLAG_RESIZABLE = Xot::bit(2),
41
41
 
42
- FLAG_PORTRAIT = Xot::bit(3),
42
+ FLAG_FULLSCREEN = Xot::bit(3),
43
43
 
44
- FLAG_LANDSCAPE = Xot::bit(4),
44
+ FLAG_PORTRAIT = Xot::bit(4),
45
+
46
+ FLAG_LANDSCAPE = Xot::bit(5),
45
47
 
46
48
  FLAG_LAST = FLAG_LANDSCAPE
47
49
 
data/lib/reflex/window.rb CHANGED
@@ -70,7 +70,8 @@ module Reflex
70
70
  universal_accessor :title, :frame,
71
71
  closable: {reader: :closable?},
72
72
  minimizable: {reader: :minimizable?},
73
- resizable: {reader: :resizable?}
73
+ resizable: {reader: :resizable?},
74
+ fullscreen: {reader: :fullscreen?}
74
75
 
75
76
  def initialize(options = nil, &block)
76
77
  super()
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.41'
29
- s.add_runtime_dependency 'rucy', '~> 0.1.43'
30
- s.add_runtime_dependency 'beeps', '~> 0.1.45'
31
- s.add_runtime_dependency 'rays', '~> 0.1.48'
28
+ s.add_runtime_dependency 'xot', '~> 0.1.42'
29
+ s.add_runtime_dependency 'rucy', '~> 0.1.44'
30
+ s.add_runtime_dependency 'beeps', '~> 0.1.46'
31
+ s.add_runtime_dependency 'rays', '~> 0.1.49'
32
32
 
33
33
  s.files = `git ls-files`.split $/
34
34
  s.executables = s.files.grep(%r{^bin/}) {|f| File.basename f}
@@ -6,6 +6,8 @@
6
6
 
7
7
  - (void) draw;
8
8
 
9
+ - (BOOL) hasFullScreenFlag;
10
+
9
11
  + (NSRect) frameRectForContentRect: (NSRect) contentRect;
10
12
 
11
13
  @end// NativeWindow
@@ -42,6 +42,17 @@ update_pixel_density (Reflex::Window* window)
42
42
  }
43
43
  }
44
44
 
45
+ static void
46
+ move_to_main_screen_origin (NativeWindow* window)
47
+ {
48
+ NSRect frame = window.frame;
49
+ NSRect screen = NSScreen.mainScreen.visibleFrame;
50
+ frame.origin.x = screen.origin.x;
51
+ frame.origin.y = screen.origin.y + screen.size.height;
52
+
53
+ [window setFrame: frame display: NO animate: NO];
54
+ }
55
+
45
56
 
46
57
  @implementation NativeWindow
47
58
 
@@ -88,6 +99,8 @@ update_pixel_density (Reflex::Window* window)
88
99
 
89
100
  - (void) bind: (Reflex::Window*) window
90
101
  {
102
+ move_to_main_screen_origin(self);
103
+
91
104
  if (!window)
92
105
  Reflex::argument_error(__FILE__, __LINE__);
93
106
 
@@ -221,6 +234,11 @@ update_pixel_density (Reflex::Window* window)
221
234
  Window_call_draw_event(win, &e);
222
235
  }
223
236
 
237
+ - (BOOL) hasFullScreenFlag
238
+ {
239
+ return self.styleMask & NSWindowStyleMaskFullScreen;
240
+ }
241
+
224
242
  - (BOOL) windowShouldClose: (id) sender
225
243
  {
226
244
  Reflex::Window* win = self.window;
@@ -299,6 +317,41 @@ update_pixel_density (Reflex::Window* window)
299
317
  }
300
318
  }
301
319
 
320
+ - (void) windowWillEnterFullScreen: (NSNotification*) notification
321
+ {
322
+ [self updateFullScreenFlag];
323
+ }
324
+
325
+ - (void) windowDidEnterFullScreen: (NSNotification*) notification
326
+ {
327
+ [self updateFullScreenFlag];
328
+ }
329
+
330
+ - (void) windowWillExitFullScreen: (NSNotification*) notification
331
+ {
332
+ [self updateFullScreenFlag];
333
+ }
334
+
335
+ - (void) windowDidExitFullScreen: (NSNotification*) notification
336
+ {
337
+ [self updateFullScreenFlag];
338
+ }
339
+
340
+ - (void) updateFullScreenFlag
341
+ {
342
+ Reflex::Window* win = self.window;
343
+ if (!win) return;
344
+
345
+ bool fullscreen = self.hasFullScreenFlag;
346
+ if (fullscreen == win->has_flag(Reflex::Window::FLAG_FULLSCREEN))
347
+ return;
348
+
349
+ if (fullscreen)
350
+ win->add_flag(Reflex::Window::FLAG_FULLSCREEN);
351
+ else
352
+ win->remove_flag(Reflex::Window::FLAG_FULLSCREEN);
353
+ }
354
+
302
355
  - (void) windowDidBecomeKey: (NSNotification*) notification
303
356
  {
304
357
  Window_call_activate_event(self.window);
data/src/osx/screen.h CHANGED
@@ -12,6 +12,9 @@ namespace Reflex
12
12
  {
13
13
 
14
14
 
15
+ CGFloat primary_screen_height ();
16
+
17
+
15
18
  void Screen_initialize (Screen* pthis, NSScreen* screen);
16
19
 
17
20
 
data/src/osx/screen.mm CHANGED
@@ -22,6 +22,12 @@ namespace Reflex
22
22
  };// Screen::Data
23
23
 
24
24
 
25
+ CGFloat
26
+ primary_screen_height ()
27
+ {
28
+ return NSScreen.screens.firstObject.frame.size.height;
29
+ }
30
+
25
31
  void
26
32
  Screen_initialize (Screen* pthis, NSScreen* screen)
27
33
  {
@@ -44,7 +50,11 @@ namespace Reflex
44
50
  invalid_state_error(__FILE__, __LINE__);
45
51
 
46
52
  NSRect f = self->screen.frame;
47
- return Bounds(f.origin.x, f.origin.y, f.size.width, f.size.height);
53
+ return Bounds(
54
+ f.origin.x,
55
+ primary_screen_height() - (f.origin.y + f.size.height),
56
+ f.size.width,
57
+ f.size.height);
48
58
  }
49
59
 
50
60
  Screen::operator bool () const
data/src/osx/window.mm CHANGED
@@ -124,19 +124,23 @@ namespace Reflex
124
124
  }
125
125
 
126
126
  void
127
- Window_set_frame (Window* window, coord x, coord y, coord width, coord height)
127
+ Window_set_frame (Window* window, coord x, coord y, coord w, coord h)
128
128
  {
129
- NSRect frame =
130
- [NativeWindow frameRectForContentRect: NSMakeRect(x, y, width, height)];
131
- [get_native(window) setFrame: frame display: NO animate: NO];
129
+ NSRect f = [NativeWindow frameRectForContentRect: NSMakeRect(x, y, w, h)];
130
+ f.origin.y = primary_screen_height() - (f.origin.y + h);
131
+
132
+ [get_native(window) setFrame: f display: NO animate: NO];
132
133
  }
133
134
 
134
135
  Bounds
135
136
  Window_get_frame (const Window& window)
136
137
  {
137
138
  NativeWindow* native = get_native(&window);
138
- NSRect r = [native contentRectForFrameRect: [native frame]];
139
- return Bounds(r.origin.x, r.origin.y, r.size.width, r.size.height);
139
+
140
+ NSRect f = [native contentRectForFrameRect: native.frame];
141
+ f.origin.y = primary_screen_height() - (f.origin.y + f.size.height);
142
+
143
+ return Bounds(f.origin.x, f.origin.y, f.size.width, f.size.height);
140
144
  }
141
145
 
142
146
  void
@@ -154,6 +158,9 @@ namespace Reflex
154
158
 
155
159
  if (styleMask != native.styleMask)
156
160
  native.styleMask = styleMask;
161
+
162
+ if (native.hasFullScreenFlag != Xot::has_flag(flags, Window::FLAG_FULLSCREEN))
163
+ [native toggleFullScreen: native];
157
164
  }
158
165
 
159
166
  Screen
data/test/test_window.rb CHANGED
@@ -121,6 +121,23 @@ class TestWindow < Test::Unit::TestCase
121
121
  assert_true w.resizable?
122
122
  end
123
123
 
124
+ def test_fullscreen?()
125
+ w = win
126
+ assert_false w.fullscreen?
127
+
128
+ w.fullscreen = true
129
+ assert_true w.fullscreen?
130
+
131
+ w.fullscreen = false
132
+ assert_false w.fullscreen?
133
+
134
+ w.fullscreen true
135
+ assert_true w.fullscreen?
136
+
137
+ w.fullscreen false
138
+ assert_false w.fullscreen?
139
+ end
140
+
124
141
  def test_orientations()
125
142
  w = win
126
143
  assert_equal [], w.orientations
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.56
4
+ version: 0.1.57
5
5
  platform: ruby
6
6
  authors:
7
7
  - xordog
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-01-07 00:00:00.000000000 Z
11
+ date: 2024-02-06 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.41
19
+ version: 0.1.42
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.41
26
+ version: 0.1.42
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.43
33
+ version: 0.1.44
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.43
40
+ version: 0.1.44
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.45
47
+ version: 0.1.46
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.45
54
+ version: 0.1.46
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.48
61
+ version: 0.1.49
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.48
68
+ version: 0.1.49
69
69
  description: This library helps you to develop interactive graphical user interface.
70
70
  email: xordog@gmail.com
71
71
  executables: []
@@ -425,7 +425,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
425
425
  - !ruby/object:Gem::Version
426
426
  version: '0'
427
427
  requirements: []
428
- rubygems_version: 3.4.10
428
+ rubygems_version: 3.4.19
429
429
  signing_key:
430
430
  specification_version: 4
431
431
  summary: A Graphical User Interface Tool Kit.