reflexion 0.1.40 → 0.1.41

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: 1ea18222490d3f1689a552d31ee11f0e0c2386998c88420a117aca12175436ce
4
- data.tar.gz: 5105528ff4c1f233d25d79a9aa8aef72239cf4256db5c1cb5c126a7359e7c31a
3
+ metadata.gz: b412c2e913baaeacdd4afff628c339c01a6ce7359572901d6193fc97d772a426
4
+ data.tar.gz: f8cba434ac873919a9bd75ea5c5e08d0436eb672313e60541d5634b210b81b76
5
5
  SHA512:
6
- metadata.gz: 2be5d8353933e987684d2f5f81cb4cf7a52cc1db615c31c4ec6ed70998d783c4d5d631c25c4ab9b02258b8c5d70c4988abe47ec8fa7e6b807dfd12acba66e5de
7
- data.tar.gz: 91263b61d34e37ea8900ff626edc2a6fb0c302a49e2cfe531ec1c502a47c3409e8f7d7caf049e67fb9bc56efc3132e5d8d1f2290746498eba5d301305bfa6298
6
+ metadata.gz: 7b6f7fd46e08e459010a98facf5c8e800c326f93d0482b0649c4f20a6bc54537947e5e3316285db7e759870c7739c68ab5284fba8f4640fb88e5dc02c106b598
7
+ data.tar.gz: a30e5f7bde2f8f9b09ff0e76847d2bbbfefe9187e3888224409ebfe04a72c05e36387ab4a976f0dd385f1ead5aa749d1ba8478182030e73058879792b0ca051e
@@ -32,6 +32,7 @@ void Init_reflex_rect_shape ();
32
32
  void Init_reflex_ellipse_shape ();
33
33
 
34
34
  void Init_reflex_application ();
35
+ void Init_reflex_screen ();
35
36
  void Init_reflex_window ();
36
37
  void Init_reflex_view ();
37
38
 
@@ -80,6 +81,7 @@ extern "C" void
80
81
  Init_reflex_ellipse_shape();
81
82
 
82
83
  Init_reflex_application();
84
+ Init_reflex_screen();
83
85
  Init_reflex_window();
84
86
  Init_reflex_view();
85
87
 
@@ -0,0 +1,53 @@
1
+ #include "reflex/ruby/screen.h"
2
+
3
+
4
+ #include <rays/ruby/bounds.h>
5
+ #include "defs.h"
6
+
7
+
8
+ RUCY_DEFINE_VALUE_FROM_TO(Reflex::Screen)
9
+
10
+ #define THIS to<Reflex::Screen*>(self)
11
+
12
+ #define CHECK RUCY_CHECK_OBJECT(Reflex::Screen, self)
13
+
14
+
15
+ static
16
+ VALUE alloc(VALUE klass)
17
+ {
18
+ Reflex::reflex_error(__FILE__, __LINE__, "can not instantiate Screen class.");
19
+ }
20
+
21
+ static
22
+ VALUE get_frame(VALUE self)
23
+ {
24
+ CHECK;
25
+ return value(THIS->frame());
26
+ }
27
+
28
+
29
+ static Class cScreen;
30
+
31
+ void
32
+ Init_reflex_screen ()
33
+ {
34
+ Module mReflex = rb_define_module("Reflex");
35
+
36
+ cScreen = rb_define_class_under(mReflex, "Screen", rb_cObject);
37
+ rb_define_alloc_func(cScreen, alloc);
38
+ rb_define_method(cScreen, "frame", RUBY_METHOD_FUNC(get_frame), 0);
39
+ }
40
+
41
+
42
+ namespace Reflex
43
+ {
44
+
45
+
46
+ Class
47
+ screen_class ()
48
+ {
49
+ return cScreen;
50
+ }
51
+
52
+
53
+ }// Reflex
@@ -3,6 +3,7 @@
3
3
 
4
4
  #include <rays/ruby/bounds.h>
5
5
  #include <rays/ruby/painter.h>
6
+ #include "reflex/ruby/screen.h"
6
7
  #include "reflex/ruby/view.h"
7
8
  #include "defs.h"
8
9
 
@@ -38,6 +39,13 @@ VALUE hide(VALUE self)
38
39
  return self;
39
40
  }
40
41
 
42
+ static
43
+ VALUE hidden(VALUE self)
44
+ {
45
+ CHECK;
46
+ return value(THIS->hidden());
47
+ }
48
+
41
49
  static
42
50
  VALUE close(VALUE self)
43
51
  {
@@ -98,44 +106,89 @@ VALUE get_frame(VALUE self)
98
106
  return value(THIS->frame());
99
107
  }
100
108
 
109
+ static
110
+ VALUE set_closable(VALUE self, VALUE state)
111
+ {
112
+ CHECK;
113
+
114
+ if (state)
115
+ THIS-> add_flag(Reflex::Window::FLAG_CLOSABLE);
116
+ else
117
+ THIS->remove_flag(Reflex::Window::FLAG_CLOSABLE);
118
+
119
+ return state;
120
+ }
121
+
122
+ static
123
+ VALUE is_closable(VALUE self)
124
+ {
125
+ CHECK;
126
+ return value(THIS->has_flag(Reflex::Window::FLAG_CLOSABLE));
127
+ }
128
+
129
+ static
130
+ VALUE set_minimizable(VALUE self, VALUE state)
131
+ {
132
+ CHECK;
133
+
134
+ if (state)
135
+ THIS-> add_flag(Reflex::Window::FLAG_MINIMIZABLE);
136
+ else
137
+ THIS->remove_flag(Reflex::Window::FLAG_MINIMIZABLE);
138
+
139
+ return state;
140
+ }
141
+
142
+ static
143
+ VALUE is_minimizable(VALUE self)
144
+ {
145
+ CHECK;
146
+ return value(THIS->has_flag(Reflex::Window::FLAG_MINIMIZABLE));
147
+ }
148
+
101
149
  static
102
150
  VALUE set_resizable(VALUE self, VALUE state)
103
151
  {
104
152
  CHECK;
105
- THIS->set_resizable(to<bool>(state));
106
- return value(THIS->is_resizable());
153
+
154
+ if (state)
155
+ THIS-> add_flag(Reflex::Window::FLAG_RESIZABLE);
156
+ else
157
+ THIS->remove_flag(Reflex::Window::FLAG_RESIZABLE);
158
+
159
+ return state;
107
160
  }
108
161
 
109
162
  static
110
163
  VALUE is_resizable(VALUE self)
111
164
  {
112
165
  CHECK;
113
- return value(THIS->is_resizable());
166
+ return value(THIS->has_flag(Reflex::Window::FLAG_RESIZABLE));
114
167
  }
115
168
 
116
169
  static
117
- VALUE hidden(VALUE self)
170
+ VALUE get_screen(VALUE self)
118
171
  {
119
172
  CHECK;
120
- return value(THIS->hidden());
173
+ return value(THIS->screen());
121
174
  }
122
175
 
123
176
  static
124
- VALUE root(VALUE self)
177
+ VALUE get_root(VALUE self)
125
178
  {
126
179
  CHECK;
127
180
  return value(THIS->root());
128
181
  }
129
182
 
130
183
  static
131
- VALUE focus(VALUE self)
184
+ VALUE get_focus(VALUE self)
132
185
  {
133
186
  CHECK;
134
187
  return value(THIS->focus());
135
188
  }
136
189
 
137
190
  static
138
- VALUE painter(VALUE self)
191
+ VALUE get_painter(VALUE self)
139
192
  {
140
193
  CHECK;
141
194
  return value(THIS->painter());
@@ -277,12 +330,17 @@ Init_reflex_window ()
277
330
  rb_define_method(cWindow, "title", RUBY_METHOD_FUNC(get_title), 0);
278
331
  rb_define_method(cWindow, "frame=", RUBY_METHOD_FUNC(set_frame), -1);
279
332
  rb_define_method(cWindow, "frame", RUBY_METHOD_FUNC(get_frame), 0);
333
+ rb_define_method(cWindow, "closable=", RUBY_METHOD_FUNC(set_closable), 1);
334
+ cWindow.define_method("closable?", is_closable);
335
+ rb_define_method(cWindow, "minimizable=", RUBY_METHOD_FUNC(set_minimizable), 1);
336
+ cWindow.define_method("minimizable?", is_minimizable);
280
337
  rb_define_method(cWindow, "resizable=", RUBY_METHOD_FUNC(set_resizable), 1);
281
- cWindow.define_method("resizable?", is_resizable);
338
+ cWindow.define_method("resizable?", is_resizable);
282
339
  rb_define_method(cWindow, "hidden", RUBY_METHOD_FUNC(hidden), 0);
283
- rb_define_method(cWindow, "root", RUBY_METHOD_FUNC(root), 0);
284
- rb_define_method(cWindow, "focus", RUBY_METHOD_FUNC(focus), 0);
285
- rb_define_method(cWindow, "painter", RUBY_METHOD_FUNC(painter), 0);
340
+ rb_define_method(cWindow, "screen", RUBY_METHOD_FUNC(get_screen), 0);
341
+ rb_define_method(cWindow, "root", RUBY_METHOD_FUNC(get_root), 0);
342
+ rb_define_method(cWindow, "focus", RUBY_METHOD_FUNC(get_focus), 0);
343
+ rb_define_method(cWindow, "painter", RUBY_METHOD_FUNC(get_painter), 0);
286
344
  rb_define_method(cWindow, "on_show", RUBY_METHOD_FUNC(on_show), 1);
287
345
  rb_define_method(cWindow, "on_hide", RUBY_METHOD_FUNC(on_hide), 1);
288
346
  rb_define_method(cWindow, "on_close", RUBY_METHOD_FUNC(on_close), 1);
data/ChangeLog.md CHANGED
@@ -1,6 +1,13 @@
1
1
  # reflex ChangeLog
2
2
 
3
3
 
4
+ ## [v0.1.41] - 2023-05-29
5
+
6
+ - Add Reflex::Screen class
7
+ - Add Window#closable and Window#minimizable accessors
8
+ - Fix that non-closable, non-minimizable, or non-resizable buttons raise error on clicking them
9
+
10
+
4
11
  ## [v0.1.40] - 2023-05-27
5
12
 
6
13
  - required_ruby_version >= 3.0.0
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.40
1
+ 0.1.41
@@ -32,6 +32,7 @@ void Init_reflex_rect_shape ();
32
32
  void Init_reflex_ellipse_shape ();
33
33
 
34
34
  void Init_reflex_application ();
35
+ void Init_reflex_screen ();
35
36
  void Init_reflex_window ();
36
37
  void Init_reflex_view ();
37
38
 
@@ -80,6 +81,7 @@ extern "C" void
80
81
  Init_reflex_ellipse_shape();
81
82
 
82
83
  Init_reflex_application();
84
+ Init_reflex_screen();
83
85
  Init_reflex_window();
84
86
  Init_reflex_view();
85
87
 
@@ -0,0 +1,55 @@
1
+ #include "reflex/ruby/screen.h"
2
+
3
+
4
+ #include <rays/ruby/bounds.h>
5
+ #include "defs.h"
6
+
7
+
8
+ RUCY_DEFINE_VALUE_FROM_TO(Reflex::Screen)
9
+
10
+ #define THIS to<Reflex::Screen*>(self)
11
+
12
+ #define CHECK RUCY_CHECK_OBJECT(Reflex::Screen, self)
13
+
14
+
15
+ static
16
+ RUCY_DEF_ALLOC(alloc, klass)
17
+ {
18
+ Reflex::reflex_error(__FILE__, __LINE__, "can not instantiate Screen class.");
19
+ }
20
+ RUCY_END
21
+
22
+ static
23
+ RUCY_DEF0(get_frame)
24
+ {
25
+ CHECK;
26
+ return value(THIS->frame());
27
+ }
28
+ RUCY_END
29
+
30
+
31
+ static Class cScreen;
32
+
33
+ void
34
+ Init_reflex_screen ()
35
+ {
36
+ Module mReflex = define_module("Reflex");
37
+
38
+ cScreen = mReflex.define_class("Screen");
39
+ cScreen.define_alloc_func(alloc);
40
+ cScreen.define_method("frame", get_frame);
41
+ }
42
+
43
+
44
+ namespace Reflex
45
+ {
46
+
47
+
48
+ Class
49
+ screen_class ()
50
+ {
51
+ return cScreen;
52
+ }
53
+
54
+
55
+ }// Reflex
@@ -3,6 +3,7 @@
3
3
 
4
4
  #include <rays/ruby/bounds.h>
5
5
  #include <rays/ruby/painter.h>
6
+ #include "reflex/ruby/screen.h"
6
7
  #include "reflex/ruby/view.h"
7
8
  #include "defs.h"
8
9
 
@@ -41,6 +42,14 @@ RUCY_DEF0(hide)
41
42
  }
42
43
  RUCY_END
43
44
 
45
+ static
46
+ RUCY_DEF0(hidden)
47
+ {
48
+ CHECK;
49
+ return value(THIS->hidden());
50
+ }
51
+ RUCY_END
52
+
44
53
  static
45
54
  RUCY_DEF0(close)
46
55
  {
@@ -109,12 +118,61 @@ RUCY_DEF0(get_frame)
109
118
  }
110
119
  RUCY_END
111
120
 
121
+ static
122
+ RUCY_DEF1(set_closable, state)
123
+ {
124
+ CHECK;
125
+
126
+ if (state)
127
+ THIS-> add_flag(Reflex::Window::FLAG_CLOSABLE);
128
+ else
129
+ THIS->remove_flag(Reflex::Window::FLAG_CLOSABLE);
130
+
131
+ return state;
132
+ }
133
+ RUCY_END
134
+
135
+ static
136
+ RUCY_DEF0(is_closable)
137
+ {
138
+ CHECK;
139
+ return value(THIS->has_flag(Reflex::Window::FLAG_CLOSABLE));
140
+ }
141
+ RUCY_END
142
+
143
+ static
144
+ RUCY_DEF1(set_minimizable, state)
145
+ {
146
+ CHECK;
147
+
148
+ if (state)
149
+ THIS-> add_flag(Reflex::Window::FLAG_MINIMIZABLE);
150
+ else
151
+ THIS->remove_flag(Reflex::Window::FLAG_MINIMIZABLE);
152
+
153
+ return state;
154
+ }
155
+ RUCY_END
156
+
157
+ static
158
+ RUCY_DEF0(is_minimizable)
159
+ {
160
+ CHECK;
161
+ return value(THIS->has_flag(Reflex::Window::FLAG_MINIMIZABLE));
162
+ }
163
+ RUCY_END
164
+
112
165
  static
113
166
  RUCY_DEF1(set_resizable, state)
114
167
  {
115
168
  CHECK;
116
- THIS->set_resizable(to<bool>(state));
117
- return value(THIS->is_resizable());
169
+
170
+ if (state)
171
+ THIS-> add_flag(Reflex::Window::FLAG_RESIZABLE);
172
+ else
173
+ THIS->remove_flag(Reflex::Window::FLAG_RESIZABLE);
174
+
175
+ return state;
118
176
  }
119
177
  RUCY_END
120
178
 
@@ -122,20 +180,20 @@ static
122
180
  RUCY_DEF0(is_resizable)
123
181
  {
124
182
  CHECK;
125
- return value(THIS->is_resizable());
183
+ return value(THIS->has_flag(Reflex::Window::FLAG_RESIZABLE));
126
184
  }
127
185
  RUCY_END
128
186
 
129
187
  static
130
- RUCY_DEF0(hidden)
188
+ RUCY_DEF0(get_screen)
131
189
  {
132
190
  CHECK;
133
- return value(THIS->hidden());
191
+ return value(THIS->screen());
134
192
  }
135
193
  RUCY_END
136
194
 
137
195
  static
138
- RUCY_DEF0(root)
196
+ RUCY_DEF0(get_root)
139
197
  {
140
198
  CHECK;
141
199
  return value(THIS->root());
@@ -143,7 +201,7 @@ RUCY_DEF0(root)
143
201
  RUCY_END
144
202
 
145
203
  static
146
- RUCY_DEF0(focus)
204
+ RUCY_DEF0(get_focus)
147
205
  {
148
206
  CHECK;
149
207
  return value(THIS->focus());
@@ -151,7 +209,7 @@ RUCY_DEF0(focus)
151
209
  RUCY_END
152
210
 
153
211
  static
154
- RUCY_DEF0(painter)
212
+ RUCY_DEF0(get_painter)
155
213
  {
156
214
  CHECK;
157
215
  return value(THIS->painter());
@@ -310,12 +368,17 @@ Init_reflex_window ()
310
368
  cWindow.define_method("title", get_title);
311
369
  cWindow.define_method("frame=", set_frame);
312
370
  cWindow.define_method("frame", get_frame);
313
- cWindow.define_method("resizable=", set_resizable);
314
- cWindow.define_method("resizable?", is_resizable);
371
+ cWindow.define_method("closable=", set_closable);
372
+ cWindow.define_method("closable?", is_closable);
373
+ cWindow.define_method("minimizable=", set_minimizable);
374
+ cWindow.define_method("minimizable?", is_minimizable);
375
+ cWindow.define_method("resizable=", set_resizable);
376
+ cWindow.define_method("resizable?", is_resizable);
315
377
  cWindow.define_method("hidden", hidden);
316
- cWindow.define_method("root", root);
317
- cWindow.define_method("focus", focus);
318
- cWindow.define_method("painter", painter);
378
+ cWindow.define_method("screen", get_screen);
379
+ cWindow.define_method("root", get_root);
380
+ cWindow.define_method("focus", get_focus);
381
+ cWindow.define_method("painter", get_painter);
319
382
  cWindow.define_method("on_show", on_show);
320
383
  cWindow.define_method("on_hide", on_hide);
321
384
  cWindow.define_method("on_close", on_close);
@@ -0,0 +1,40 @@
1
+ // -*- c++ -*-
2
+ #pragma once
3
+ #ifndef __REFLEX_RUBY_SCREEN_H__
4
+ #define __REFLEX_RUBY_SCREEN_H__
5
+
6
+
7
+ #include <rucy/class.h>
8
+ #include <rucy/extension.h>
9
+ #include <reflex/screen.h>
10
+
11
+
12
+ RUCY_DECLARE_VALUE_FROM_TO(Reflex::Screen)
13
+
14
+
15
+ namespace Reflex
16
+ {
17
+
18
+
19
+ Rucy::Class screen_class ();
20
+ // class Reflex::Screen
21
+
22
+
23
+ }// Reflex
24
+
25
+
26
+ namespace Rucy
27
+ {
28
+
29
+
30
+ template <> inline Class
31
+ get_ruby_class<Reflex::Screen> ()
32
+ {
33
+ return Reflex::screen_class();
34
+ }
35
+
36
+
37
+ }// Rucy
38
+
39
+
40
+ #endif//EOH
@@ -0,0 +1,43 @@
1
+ // -*- c++ -*-
2
+ #pragma once
3
+ #ifndef __REFLEX_SCREEN_H__
4
+ #define __REFLEX_SCREEN_H__
5
+
6
+
7
+ #include <xot/pimpl.h>
8
+ #include <rays/bounds.h>
9
+ #include <reflex/defs.h>
10
+
11
+
12
+ namespace Reflex
13
+ {
14
+
15
+
16
+ class Screen
17
+ {
18
+
19
+ typedef Screen This;
20
+
21
+ public:
22
+
23
+ Screen ();
24
+
25
+ virtual ~Screen ();
26
+
27
+ virtual Bounds frame () const;
28
+
29
+ operator bool () const;
30
+
31
+ bool operator ! () const;
32
+
33
+ struct Data;
34
+
35
+ Xot::PSharedImpl<Data> self;
36
+
37
+ };// Screen
38
+
39
+
40
+ }// Reflex
41
+
42
+
43
+ #endif//EOH
@@ -11,6 +11,7 @@
11
11
  #include <rays/painter.h>
12
12
  #include <reflex/defs.h>
13
13
  #include <reflex/event.h>
14
+ #include <reflex/screen.h>
14
15
 
15
16
 
16
17
  namespace Reflex
@@ -29,12 +30,27 @@ namespace Reflex
29
30
 
30
31
  typedef Xot::Ref<This> Ref;
31
32
 
33
+ enum Flag
34
+ {
35
+
36
+ FLAG_CLOSABLE = Xot::bit(0),
37
+
38
+ FLAG_MINIMIZABLE = Xot::bit(1),
39
+
40
+ FLAG_RESIZABLE = Xot::bit(2),
41
+
42
+ FLAG_LAST = FLAG_RESIZABLE
43
+
44
+ };// Flag
45
+
32
46
  Window ();
33
47
 
34
48
  virtual void show ();
35
49
 
36
50
  virtual void hide ();
37
51
 
52
+ virtual bool hidden () const;
53
+
38
54
  virtual void close (bool force = false);
39
55
 
40
56
  virtual void redraw ();
@@ -53,11 +69,13 @@ namespace Reflex
53
69
 
54
70
  virtual Bounds frame () const;
55
71
 
56
- virtual void set_resizable (bool state = true);
72
+ virtual void add_flag (uint flags);
57
73
 
58
- virtual bool is_resizable () const;
74
+ virtual void remove_flag (uint flags);
59
75
 
60
- virtual bool hidden () const;
76
+ virtual bool has_flag (uint flags) const;
77
+
78
+ virtual Screen screen () const;
61
79
 
62
80
  virtual View* root ();
63
81
 
@@ -0,0 +1,21 @@
1
+ require 'forwardable'
2
+
3
+
4
+ module Reflex
5
+
6
+
7
+ class Screen
8
+
9
+ extend Forwardable
10
+
11
+ def_delegators :frame,
12
+ :x, :y, :z, :w, :h, :d, :width, :height, :depth,
13
+ :left, :top, :back, :right, :bottom, :front,
14
+ :left_top, :right_top, :left_bottom, :right_bottom,
15
+ :lt, :lr, :lb, :rb,
16
+ :position, :pos, :size, :center
17
+
18
+ end# Screen
19
+
20
+
21
+ end# Reflex
data/lib/reflex/window.rb CHANGED
@@ -62,7 +62,9 @@ module Reflex
62
62
  :restitution=, :restitution
63
63
 
64
64
  universal_accessor :title, :frame,
65
- resizable: {reader: :resizable?}
65
+ closable: {reader: :closable?},
66
+ minimizable: {reader: :minimizable?},
67
+ resizable: {reader: :resizable?}
66
68
 
67
69
  def initialize(options = nil, &block)
68
70
  super()
data/lib/reflex.rb CHANGED
@@ -47,6 +47,7 @@ require 'reflex/model'
47
47
  require 'reflex/model_owner'
48
48
 
49
49
  require 'reflex/application'
50
+ require 'reflex/screen'
50
51
  require 'reflex/window'
51
52
  require 'reflex/view'
52
53
 
data/reflex.gemspec CHANGED
@@ -1,10 +1,7 @@
1
1
  # -*- mode: ruby -*-
2
2
 
3
3
 
4
- File.expand_path('lib', __dir__)
5
- .tap {|s| $:.unshift s if !$:.include?(s) && File.directory?(s)}
6
-
7
- require 'reflex/extension'
4
+ require_relative 'lib/reflex/extension'
8
5
 
9
6
 
10
7
  Gem::Specification.new do |s|
@@ -28,10 +25,10 @@ Gem::Specification.new do |s|
28
25
  s.platform = Gem::Platform::RUBY
29
26
  s.required_ruby_version = '>= 3.0.0'
30
27
 
31
- s.add_runtime_dependency 'xot', '~> 0.1.37'
32
- s.add_runtime_dependency 'rucy', '~> 0.1.37'
33
- s.add_runtime_dependency 'beeps', '~> 0.1.38'
34
- s.add_runtime_dependency 'rays', '~> 0.1.38'
28
+ s.add_runtime_dependency 'xot', '~> 0.1.38'
29
+ s.add_runtime_dependency 'rucy', '~> 0.1.38'
30
+ s.add_runtime_dependency 'beeps', '~> 0.1.39'
31
+ s.add_runtime_dependency 'rays', '~> 0.1.39'
35
32
 
36
33
  s.add_development_dependency 'rake'
37
34
  s.add_development_dependency 'test-unit'
@@ -12,13 +12,13 @@
12
12
  #import "opengl_view.h"
13
13
 
14
14
 
15
- static const NSUInteger WINDOW_STYLE_MASK =
16
- NSTitledWindowMask |
17
- NSClosableWindowMask |
18
- NSMiniaturizableWindowMask |
19
- NSResizableWindowMask |
20
- 0;//NSTexturedBackgroundWindowMask
21
-
15
+ static NSWindowStyleMask
16
+ default_style_mask ()
17
+ {
18
+ return Window_make_style_mask(
19
+ Reflex::Window::Data::FLAG_DEFAULT,
20
+ NSTitledWindowMask | NSTexturedBackgroundWindowMask);
21
+ }
22
22
 
23
23
  static int
24
24
  count_mouse_buttons (const Reflex::PointerEvent& e)
@@ -67,7 +67,7 @@ update_pixel_density (Reflex::Window* window)
67
67
  {
68
68
  self = [super
69
69
  initWithContentRect: NSMakeRect(0, 0, 0, 0)
70
- styleMask: WINDOW_STYLE_MASK
70
+ styleMask: default_style_mask()
71
71
  backing: NSBackingStoreBuffered
72
72
  defer: NO];
73
73
  if (!self) return nil;
@@ -368,7 +368,7 @@ update_pixel_density (Reflex::Window* window)
368
368
  if (clicking_count == 0)
369
369
  ++pointer_id;
370
370
  else if (clicking_count < 0)
371
- Reflex::invalid_state_error(__FILE__, __LINE__);
371
+ return;//Reflex::invalid_state_error(__FILE__, __LINE__);
372
372
 
373
373
  Window_call_pointer_event(win, &e);
374
374
  }
@@ -420,7 +420,7 @@ update_pixel_density (Reflex::Window* window)
420
420
  {
421
421
  return [NSWindow
422
422
  frameRectForContentRect: contentRect
423
- styleMask: WINDOW_STYLE_MASK];
423
+ styleMask: default_style_mask()];
424
424
  }
425
425
 
426
426
  @end// NativeWindow
data/src/osx/screen.h ADDED
@@ -0,0 +1,21 @@
1
+ // -*- c++ -*-
2
+ #pragma once
3
+ #ifndef __REFLEX_SRC_OSX_SCREEN_H__
4
+ #define __REFLEX_SRC_OSX_SCREEN_H__
5
+
6
+
7
+ #import <AppKit/NSScreen.h>
8
+ #include "reflex/screen.h"
9
+
10
+
11
+ namespace Reflex
12
+ {
13
+
14
+
15
+ void Screen_initialize (Screen* pthis, NSScreen* screen);
16
+
17
+
18
+ }// Reflex
19
+
20
+
21
+ #endif//EOH
data/src/osx/screen.mm ADDED
@@ -0,0 +1,58 @@
1
+ // -*- mode: objc -*-
2
+ #include "screen.h"
3
+
4
+
5
+ namespace Reflex
6
+ {
7
+
8
+
9
+ struct Screen::Data
10
+ {
11
+
12
+ NSScreen* screen = nil;
13
+
14
+ ~Data ()
15
+ {
16
+ if (screen) [screen release];
17
+ }
18
+
19
+ };// Screen::Data
20
+
21
+
22
+ void
23
+ Screen_initialize (Screen* pthis, NSScreen* screen)
24
+ {
25
+ pthis->self->screen = [screen retain];
26
+ }
27
+
28
+
29
+ Screen::Screen ()
30
+ {
31
+ }
32
+
33
+ Screen::~Screen ()
34
+ {
35
+ }
36
+
37
+ Bounds
38
+ Screen::frame () const
39
+ {
40
+ NSRect frame = self->screen.frame;
41
+ return Bounds(
42
+ frame.origin.x, frame.origin.y,
43
+ frame.size.width, frame.size.height);
44
+ }
45
+
46
+ Screen::operator bool () const
47
+ {
48
+ return self->screen;
49
+ }
50
+
51
+ bool
52
+ Screen::operator ! () const
53
+ {
54
+ return !operator bool();
55
+ }
56
+
57
+
58
+ }// Reflex
data/src/osx/window.h CHANGED
@@ -4,6 +4,7 @@
4
4
  #define __REFLEX_SRC_OSX_WINDOW_H__
5
5
 
6
6
 
7
+ #import <AppKit/NSWindow.h>
7
8
  #include "../window.h"
8
9
 
9
10
 
@@ -35,6 +36,9 @@ namespace Reflex
35
36
 
36
37
  const WindowData& Window_get_data (const Window* window);
37
38
 
39
+ NSWindowStyleMask Window_make_style_mask (
40
+ uint flags, NSWindowStyleMask styleMask = 0);
41
+
38
42
 
39
43
  }// Reflex
40
44
 
data/src/osx/window.mm CHANGED
@@ -4,6 +4,7 @@
4
4
 
5
5
  #import <Cocoa/Cocoa.h>
6
6
  #include "reflex/exception.h"
7
+ #include "screen.h"
7
8
  #import "native_window.h"
8
9
 
9
10
 
@@ -31,6 +32,27 @@ namespace Reflex
31
32
  return Window_get_data(const_cast<Window*>(window));
32
33
  }
33
34
 
35
+ NSWindowStyleMask
36
+ Window_make_style_mask (uint flags, NSWindowStyleMask styleMask)
37
+ {
38
+ if (Xot::has_flag(flags, Window::FLAG_CLOSABLE))
39
+ styleMask |= NSWindowStyleMaskClosable;
40
+ else
41
+ styleMask &= ~NSWindowStyleMaskClosable;
42
+
43
+ if (Xot::has_flag(flags, Window::FLAG_MINIMIZABLE))
44
+ styleMask |= NSWindowStyleMaskMiniaturizable;
45
+ else
46
+ styleMask &= ~NSWindowStyleMaskMiniaturizable;
47
+
48
+ if (Xot::has_flag(flags, Window::FLAG_RESIZABLE))
49
+ styleMask |= NSWindowStyleMaskResizable;
50
+ else
51
+ styleMask &= ~NSWindowStyleMaskResizable;
52
+
53
+ return styleMask;
54
+ }
55
+
34
56
  static NativeWindow*
35
57
  get_native (const Window* window)
36
58
  {
@@ -113,19 +135,23 @@ namespace Reflex
113
135
  }
114
136
 
115
137
  void
116
- Window_set_resizable (Window* window, bool state)
138
+ Window_set_flags (Window* window, uint flags)
117
139
  {
118
- NativeWindow* native = get_native(window);
119
- if (state)
120
- native.styleMask |= NSResizableWindowMask;
121
- else
122
- native.styleMask &= ~NSResizableWindowMask;
140
+ NativeWindow* native = get_native(window);
141
+ NSWindowStyleMask styleMask =
142
+ Window_make_style_mask(window->self->flags, native.styleMask);
143
+
144
+ if (styleMask != native.styleMask)
145
+ native.styleMask = styleMask;
123
146
  }
124
147
 
125
- bool
126
- Window_is_resizable (const Window& window)
148
+ Screen
149
+ Window_get_screen (const Window& window)
127
150
  {
128
- return get_native(&window).styleMask & NSResizableWindowMask;
151
+ Screen s;
152
+ NativeWindow* native = get_native(&window);
153
+ if (native && native.screen) Screen_initialize(&s, native.screen);
154
+ return s;
129
155
  }
130
156
 
131
157
  float
data/src/window.cpp CHANGED
@@ -450,6 +450,12 @@ namespace Reflex
450
450
  self->hide_count = new_count;
451
451
  }
452
452
 
453
+ bool
454
+ Window::hidden () const
455
+ {
456
+ return self->hide_count > 0;
457
+ }
458
+
453
459
  void
454
460
  Window::close (bool force)
455
461
  {
@@ -512,21 +518,31 @@ namespace Reflex
512
518
  }
513
519
 
514
520
  void
515
- Window::set_resizable (bool state)
521
+ Window::add_flag (uint flags)
516
522
  {
517
- Window_set_resizable(this, state);
523
+ Xot::add_flag(&self->flags, flags);
524
+
525
+ Window_set_flags(this, self->flags);
518
526
  }
519
527
 
520
- bool
521
- Window::is_resizable () const
528
+ void
529
+ Window::remove_flag (uint flags)
522
530
  {
523
- return Window_is_resizable(*this);
531
+ Xot::remove_flag(&self->flags, flags);
532
+
533
+ Window_set_flags(this, self->flags);
524
534
  }
525
535
 
526
536
  bool
527
- Window::hidden () const
537
+ Window::has_flag (uint flags) const
528
538
  {
529
- return self->hide_count > 0;
539
+ return Xot::has_flag(self->flags, flags);
540
+ }
541
+
542
+ Screen
543
+ Window::screen () const
544
+ {
545
+ return Window_get_screen(*this);
530
546
  }
531
547
 
532
548
  View*
data/src/window.h CHANGED
@@ -37,6 +37,8 @@ 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
+
40
42
  int hide_count = 1;
41
43
 
42
44
  bool redraw = true;
@@ -51,6 +53,8 @@ namespace Reflex
51
53
 
52
54
  CaptureMap captures;
53
55
 
56
+ uint flags = FLAG_DEFAULT;
57
+
54
58
  Data ()
55
59
  {
56
60
  prev_time_update = prev_time_draw = Xot::time();
@@ -94,9 +98,9 @@ namespace Reflex
94
98
 
95
99
  Bounds Window_get_frame (const Window& window);
96
100
 
97
- void Window_set_resizable (Window* window, bool state);
101
+ Screen Window_get_screen (const Window& window);
98
102
 
99
- bool Window_is_resizable (const Window& window);
103
+ void Window_set_flags (Window* window, uint flags);
100
104
 
101
105
  void Window_set_focus (Window* window, View* view);
102
106
 
data/test/test_event.rb CHANGED
@@ -7,6 +7,10 @@ class TestEvent < Test::Unit::TestCase
7
7
  Reflex::UpdateEvent.new 0, 0
8
8
  end
9
9
 
10
+ def test_initialize()
11
+ assert_raise(Reflex::ReflexError) {Reflex::Event.new}
12
+ end
13
+
10
14
  def test_dup()
11
15
  e1 = event
12
16
  e2 = e1.dup
@@ -0,0 +1,18 @@
1
+ require_relative 'helper'
2
+
3
+
4
+ class TestScreen < Test::Unit::TestCase
5
+
6
+ def screen()
7
+ Reflex::Window.new.screen
8
+ end
9
+
10
+ def test_initialize()
11
+ assert_raise(Reflex::ReflexError) {Reflex::Screen.new}
12
+ end
13
+
14
+ def test_frame()
15
+ assert_raise(Rucy::InvalidObjectError) {screen.frame}
16
+ end
17
+
18
+ end# TestScreen
data/test/test_view.rb CHANGED
@@ -28,21 +28,21 @@ class TestView < Test::Unit::TestCase
28
28
 
29
29
  def test_show_hide_hidden()
30
30
  v = view
31
- assert_equal false, v.hidden?
31
+ assert_false v.hidden?
32
32
  v.hide
33
- assert_equal true, v.hidden?
33
+ assert_true v.hidden?
34
34
  v.show
35
- assert_equal false, v.hidden?
35
+ assert_false v.hidden?
36
36
  end
37
37
 
38
38
  def test_hidden_count()
39
39
  v = view
40
40
  v.show
41
- assert_equal false, v.hidden?
41
+ assert_false v.hidden?
42
42
  v.hide
43
- assert_equal false, v.hidden?
43
+ assert_false v.hidden?
44
44
  v.hide
45
- assert_equal true, v.hidden?
45
+ assert_true v.hidden?
46
46
  end
47
47
 
48
48
  def test_coord_conversion()
data/test/test_window.rb CHANGED
@@ -12,17 +12,21 @@ class TestWindow < Test::Unit::TestCase
12
12
 
13
13
  def test_show_hide_hidden()
14
14
  w = win
15
- assert_equal true, w.hidden
15
+ assert_true w.hidden
16
16
  w.show
17
- assert_equal false, w.hidden
17
+ assert_false w.hidden
18
18
  w.hide
19
- assert_equal true, w.hidden
19
+ assert_true w.hidden
20
+ end
21
+
22
+ def test_hidden_count()
23
+ w = win
20
24
  w.hide
21
- assert_equal true, w.hidden
25
+ assert_true w.hidden
22
26
  w.show
23
- assert_equal true, w.hidden
27
+ assert_true w.hidden
24
28
  w.show
25
- assert_equal false, w.hidden
29
+ assert_false w.hidden
26
30
  end
27
31
 
28
32
  def test_coord_conversion()
@@ -66,6 +70,40 @@ class TestWindow < Test::Unit::TestCase
66
70
  w.frame = [bounds(1, 2, 3, 4, 5, 6)]; assert_equal [1, 2, 0, 4, 5, 0], w.frame.to_a(3)
67
71
  end
68
72
 
73
+ def test_closable?()
74
+ w = win
75
+ assert_true w.closable?
76
+
77
+ w.closable = false
78
+ assert_false w.closable?
79
+
80
+ w.closable = true
81
+ assert_true w.closable?
82
+
83
+ w.closable false
84
+ assert_false w.closable?
85
+
86
+ w.closable true
87
+ assert_true w.closable?
88
+ end
89
+
90
+ def test_minimizable?()
91
+ w = win
92
+ assert_true w.minimizable?
93
+
94
+ w.minimizable = false
95
+ assert_false w.minimizable?
96
+
97
+ w.minimizable = true
98
+ assert_true w.minimizable?
99
+
100
+ w.minimizable false
101
+ assert_false w.minimizable?
102
+
103
+ w.minimizable true
104
+ assert_true w.minimizable?
105
+ end
106
+
69
107
  def test_resizable?()
70
108
  w = win
71
109
  assert_true w.resizable?
@@ -83,6 +121,10 @@ class TestWindow < Test::Unit::TestCase
83
121
  assert_true w.resizable?
84
122
  end
85
123
 
124
+ def test_screen()
125
+ assert_not_nil win.screen
126
+ end
127
+
86
128
  def test_root()
87
129
  w = win
88
130
  assert_not_nil w.root
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.40
4
+ version: 0.1.41
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-27 00:00:00.000000000 Z
11
+ date: 2023-05-29 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.37
19
+ version: 0.1.38
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.37
26
+ version: 0.1.38
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.37
33
+ version: 0.1.38
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.37
40
+ version: 0.1.38
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.38
47
+ version: 0.1.39
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.38
54
+ version: 0.1.39
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.38
61
+ version: 0.1.39
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.38
68
+ version: 0.1.39
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rake
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -120,6 +120,7 @@ extra_rdoc_files:
120
120
  - ".doc/ext/reflex/polygon_shape.cpp"
121
121
  - ".doc/ext/reflex/rect_shape.cpp"
122
122
  - ".doc/ext/reflex/reflex.cpp"
123
+ - ".doc/ext/reflex/screen.cpp"
123
124
  - ".doc/ext/reflex/scroll_event.cpp"
124
125
  - ".doc/ext/reflex/selector.cpp"
125
126
  - ".doc/ext/reflex/shape.cpp"
@@ -152,6 +153,7 @@ files:
152
153
  - ".doc/ext/reflex/polygon_shape.cpp"
153
154
  - ".doc/ext/reflex/rect_shape.cpp"
154
155
  - ".doc/ext/reflex/reflex.cpp"
156
+ - ".doc/ext/reflex/screen.cpp"
155
157
  - ".doc/ext/reflex/scroll_event.cpp"
156
158
  - ".doc/ext/reflex/selector.cpp"
157
159
  - ".doc/ext/reflex/shape.cpp"
@@ -194,6 +196,7 @@ files:
194
196
  - ext/reflex/polygon_shape.cpp
195
197
  - ext/reflex/rect_shape.cpp
196
198
  - ext/reflex/reflex.cpp
199
+ - ext/reflex/screen.cpp
197
200
  - ext/reflex/scroll_event.cpp
198
201
  - ext/reflex/selector.cpp
199
202
  - ext/reflex/selector.h
@@ -225,12 +228,14 @@ files:
225
228
  - include/reflex/ruby/image_view.h
226
229
  - include/reflex/ruby/pointer.h
227
230
  - include/reflex/ruby/reflex.h
231
+ - include/reflex/ruby/screen.h
228
232
  - include/reflex/ruby/selector.h
229
233
  - include/reflex/ruby/shape.h
230
234
  - include/reflex/ruby/style.h
231
235
  - include/reflex/ruby/timer.h
232
236
  - include/reflex/ruby/view.h
233
237
  - include/reflex/ruby/window.h
238
+ - include/reflex/screen.h
234
239
  - include/reflex/selector.h
235
240
  - include/reflex/shape.h
236
241
  - include/reflex/style.h
@@ -276,6 +281,7 @@ files:
276
281
  - lib/reflex/polyline.rb
277
282
  - lib/reflex/rect_shape.rb
278
283
  - lib/reflex/reflex.rb
284
+ - lib/reflex/screen.rb
279
285
  - lib/reflex/scroll_event.rb
280
286
  - lib/reflex/selector.rb
281
287
  - lib/reflex/shader.rb
@@ -364,6 +370,8 @@ files:
364
370
  - src/osx/opengl_view.h
365
371
  - src/osx/opengl_view.mm
366
372
  - src/osx/reflex.mm
373
+ - src/osx/screen.h
374
+ - src/osx/screen.mm
367
375
  - src/osx/window.h
368
376
  - src/osx/window.mm
369
377
  - src/pointer.cpp
@@ -404,6 +412,7 @@ files:
404
412
  - test/test_pointer.rb
405
413
  - test/test_pointer_event.rb
406
414
  - test/test_reflex_init.rb
415
+ - test/test_screen.rb
407
416
  - test/test_scroll_event.rb
408
417
  - test/test_selector.rb
409
418
  - test/test_shape.rb
@@ -453,6 +462,7 @@ test_files:
453
462
  - test/test_pointer.rb
454
463
  - test/test_pointer_event.rb
455
464
  - test/test_reflex_init.rb
465
+ - test/test_screen.rb
456
466
  - test/test_scroll_event.rb
457
467
  - test/test_selector.rb
458
468
  - test/test_shape.rb