reflexion 0.1.42 → 0.1.43

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fa7ec97efd9d68e5053ddc3bf852f718a66ff883a5bb8693f605dcf45e962732
4
- data.tar.gz: f2fd1319de6f1032802ce96c6657e9ac7dc0327a10c9ef9b1ba2f910c117c57a
3
+ metadata.gz: c10c73adab35ef74f8426582c0343a84873fbe71b116fd669e656b42edfee613
4
+ data.tar.gz: ffcf1e0fb5a0b26d3bd0dbc3a5e1627bc25ae7addbbd5dd213332f21b661e5d6
5
5
  SHA512:
6
- metadata.gz: 61d0f5a9fc7ec41480642825f071d103d211035a38bcfda25eb90789fb642cf2663dce3f18771cc3702482e0a78d0385c4601ab23b4654f677f946af6000b425
7
- data.tar.gz: abd4d92237cd9d49795ce5010b38565d7f3a4abd0b73ae4b18ca1989e748e911144ac3b11bdc6869400599c8eac6f120f751f75484c821a483b7475aefcec78a
6
+ metadata.gz: 7761664e1ba50fa8b10ef92c14dbeac9bfca2e4820bbe67d7f01cd44f6b7b235d06657796d567d9d3ff55bdf7e33eb911ab7dd2ea9f83dc77488c3f12771bada
7
+ data.tar.gz: 50ec935dcb2f5b692cab1ae3549aea533a8a2b7b4c4f89944ee92b39ca849feb7ac8f799dcf82cd8a4f066bdd2986d21489c56761f3e38acbda079e930fe677d
@@ -194,6 +194,20 @@ VALUE get_painter(VALUE self)
194
194
  return value(THIS->painter());
195
195
  }
196
196
 
197
+ static
198
+ VALUE on_activate(VALUE self, VALUE event)
199
+ {
200
+ CHECK;
201
+ CALL(on_activate(to<Reflex::Event*>(event)));
202
+ }
203
+
204
+ static
205
+ VALUE on_deactivate(VALUE self, VALUE event)
206
+ {
207
+ CHECK;
208
+ CALL(on_deactivate(to<Reflex::Event*>(event)));
209
+ }
210
+
197
211
  static
198
212
  VALUE on_show(VALUE self, VALUE event)
199
213
  {
@@ -341,6 +355,8 @@ Init_reflex_window ()
341
355
  rb_define_method(cWindow, "root", RUBY_METHOD_FUNC(get_root), 0);
342
356
  rb_define_method(cWindow, "focus", RUBY_METHOD_FUNC(get_focus), 0);
343
357
  rb_define_method(cWindow, "painter", RUBY_METHOD_FUNC(get_painter), 0);
358
+ rb_define_method(cWindow, "on_activate", RUBY_METHOD_FUNC(on_activate), 1);
359
+ rb_define_method(cWindow, "on_deactivate", RUBY_METHOD_FUNC(on_deactivate), 1);
344
360
  rb_define_method(cWindow, "on_show", RUBY_METHOD_FUNC(on_show), 1);
345
361
  rb_define_method(cWindow, "on_hide", RUBY_METHOD_FUNC(on_hide), 1);
346
362
  rb_define_method(cWindow, "on_close", RUBY_METHOD_FUNC(on_close), 1);
data/ChangeLog.md CHANGED
@@ -1,6 +1,11 @@
1
1
  # reflex ChangeLog
2
2
 
3
3
 
4
+ ## [v0.1.43] - 2023-06-07
5
+
6
+ - Add on_activate() and on_deactivate() to Window class
7
+
8
+
4
9
  ## [v0.1.42] - 2023-06-02
5
10
 
6
11
  - Implement the Screen class for iOS
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.42
1
+ 0.1.43
@@ -216,6 +216,22 @@ RUCY_DEF0(get_painter)
216
216
  }
217
217
  RUCY_END
218
218
 
219
+ static
220
+ RUCY_DEF1(on_activate, event)
221
+ {
222
+ CHECK;
223
+ CALL(on_activate(to<Reflex::Event*>(event)));
224
+ }
225
+ RUCY_END
226
+
227
+ static
228
+ RUCY_DEF1(on_deactivate, event)
229
+ {
230
+ CHECK;
231
+ CALL(on_deactivate(to<Reflex::Event*>(event)));
232
+ }
233
+ RUCY_END
234
+
219
235
  static
220
236
  RUCY_DEF1(on_show, event)
221
237
  {
@@ -379,6 +395,8 @@ Init_reflex_window ()
379
395
  cWindow.define_method("root", get_root);
380
396
  cWindow.define_method("focus", get_focus);
381
397
  cWindow.define_method("painter", get_painter);
398
+ cWindow.define_method("on_activate", on_activate);
399
+ cWindow.define_method("on_deactivate", on_deactivate);
382
400
  cWindow.define_method("on_show", on_show);
383
401
  cWindow.define_method("on_hide", on_hide);
384
402
  cWindow.define_method("on_close", on_close);
@@ -29,6 +29,24 @@ namespace Reflex
29
29
 
30
30
  public:
31
31
 
32
+ virtual void on_activate (Event* e)
33
+ {
34
+ RUCY_SYM(on_activate);
35
+ if (this->is_overridable())
36
+ this->value.call(on_activate, Rucy::value(e));
37
+ else
38
+ return Super::on_activate(e);
39
+ }
40
+
41
+ virtual void on_deactivate (Event* e)
42
+ {
43
+ RUCY_SYM(on_deactivate);
44
+ if (this->is_overridable())
45
+ this->value.call(on_deactivate, Rucy::value(e));
46
+ else
47
+ return Super::on_deactivate(e);
48
+ }
49
+
32
50
  virtual void on_show (Event* e)
33
51
  {
34
52
  RUCY_SYM(on_show);
@@ -89,6 +89,10 @@ namespace Reflex
89
89
 
90
90
  virtual const Painter* painter () const;
91
91
 
92
+ virtual void on_activate (Event* e);
93
+
94
+ virtual void on_deactivate (Event* e);
95
+
92
96
  virtual void on_show (Event* e);
93
97
 
94
98
  virtual void on_hide (Event* e);
data/reflex.gemspec CHANGED
@@ -28,7 +28,7 @@ Gem::Specification.new do |s|
28
28
  s.add_runtime_dependency 'xot', '~> 0.1.38'
29
29
  s.add_runtime_dependency 'rucy', '~> 0.1.38'
30
30
  s.add_runtime_dependency 'beeps', '~> 0.1.39'
31
- s.add_runtime_dependency 'rays', '~> 0.1.39'
31
+ s.add_runtime_dependency 'rays', '~> 0.1.40'
32
32
 
33
33
  s.add_development_dependency 'rake'
34
34
  s.add_development_dependency 'test-unit'
@@ -285,14 +285,48 @@ ReflexViewController_get_show_fun ()
285
285
  {
286
286
  [super viewDidAppear: animated];
287
287
  [self startTimer];
288
+
289
+ Window_call_activate_event(self.window);
290
+
291
+ [NSNotificationCenter.defaultCenter
292
+ addObserver: self
293
+ selector: @selector(didBecomeActive)
294
+ name: UIApplicationDidBecomeActiveNotification
295
+ object: nil];
296
+ [NSNotificationCenter.defaultCenter
297
+ addObserver: self
298
+ selector: @selector(willResignActive)
299
+ name: UIApplicationWillResignActiveNotification
300
+ object: nil];
288
301
  }
289
302
 
290
303
  - (void) viewDidDisappear: (BOOL) animated
291
304
  {
305
+ [NSNotificationCenter.defaultCenter
306
+ removeObserver: self
307
+ name: UIApplicationDidBecomeActiveNotification
308
+ object: nil];
309
+ [NSNotificationCenter.defaultCenter
310
+ removeObserver: self
311
+ name: UIApplicationWillResignActiveNotification
312
+ object: nil];
313
+
314
+ Window_ca__deactivate_event(self.window);
315
+
292
316
  [self stopTimer];
293
317
  [super viewDidDisappear: animated];
294
318
  }
295
319
 
320
+ - (void) didBecomeActive
321
+ {
322
+ Window_call_activate_event(self.window);
323
+ }
324
+
325
+ - (void) willResignActive
326
+ {
327
+ Window_call_deactivate_event(self.window);
328
+ }
329
+
296
330
  - (void)viewDidLayoutSubviews
297
331
  {
298
332
  [super viewDidLayoutSubviews];
@@ -242,6 +242,9 @@ update_pixel_density (Reflex::Window* window)
242
242
 
243
243
  - (void) windowWillClose: (NSNotification*) notification
244
244
  {
245
+ if (self.isKeyWindow)
246
+ Window_call_deactivate_event(self.window);
247
+
245
248
  [self stopTimer];
246
249
  [self unbind];
247
250
  [self setDelegate: nil];
@@ -306,6 +309,16 @@ update_pixel_density (Reflex::Window* window)
306
309
  }
307
310
  }
308
311
 
312
+ - (void) windowDidBecomeKey: (NSNotification*) notification
313
+ {
314
+ Window_call_activate_event(self.window);
315
+ }
316
+
317
+ - (void) windowDidResignKey: (NSNotification*) notification
318
+ {
319
+ Window_call_deactivate_event(self.window);
320
+ }
321
+
309
322
  - (void) keyDown: (NSEvent*) event
310
323
  {
311
324
  Reflex::Window* win = self.window;
data/src/window.cpp CHANGED
@@ -134,6 +134,24 @@ namespace Reflex
134
134
  }
135
135
  }
136
136
 
137
+ void
138
+ Window_call_activate_event (Reflex::Window* window)
139
+ {
140
+ if (!window) return;
141
+
142
+ Reflex::Event e;
143
+ window->on_activate(&e);
144
+ }
145
+
146
+ void
147
+ Window_call_deactivate_event (Reflex::Window* window)
148
+ {
149
+ if (!window) return;
150
+
151
+ Reflex::Event e;
152
+ window->on_deactivate(&e);
153
+ }
154
+
137
155
  void
138
156
  Window_call_draw_event (Window* window, DrawEvent* event)
139
157
  {
@@ -598,6 +616,16 @@ namespace Reflex
598
616
  return const_cast<Window*>(this)->painter();
599
617
  }
600
618
 
619
+ void
620
+ Window::on_activate (Event* e)
621
+ {
622
+ }
623
+
624
+ void
625
+ Window::on_deactivate (Event* e)
626
+ {
627
+ }
628
+
601
629
  void
602
630
  Window::on_show (Event* e)
603
631
  {
data/src/window.h CHANGED
@@ -105,13 +105,17 @@ namespace Reflex
105
105
  void Window_unregister_capture (
106
106
  Window* window, View* view, Pointer::ID target);
107
107
 
108
- void Window_call_draw_event (Window* window, DrawEvent* event);
108
+ void Window_call_activate_event (Window* window);
109
109
 
110
- void Window_call_key_event (Window* window, KeyEvent* event);
110
+ void Window_call_deactivate_event (Window* window);
111
111
 
112
- void Window_call_pointer_event (Window* window, PointerEvent* event);
112
+ void Window_call_draw_event (Window* window, DrawEvent* event);
113
113
 
114
- void Window_call_wheel_event (Window* window, WheelEvent* event);
114
+ void Window_call_key_event (Window* window, KeyEvent* event);
115
+
116
+ void Window_call_pointer_event (Window* window, PointerEvent* event);
117
+
118
+ void Window_call_wheel_event (Window* window, WheelEvent* event);
115
119
 
116
120
  float Window_get_pixel_density (const Window& window);
117
121
 
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.42
4
+ version: 0.1.43
5
5
  platform: ruby
6
6
  authors:
7
7
  - xordog
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-06-02 00:00:00.000000000 Z
11
+ date: 2023-06-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: xot
@@ -58,14 +58,14 @@ dependencies:
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: 0.1.39
61
+ version: 0.1.40
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.39
68
+ version: 0.1.40
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rake
71
71
  requirement: !ruby/object:Gem::Requirement