reflexion 0.3.2 → 0.3.3

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: 44f9d83e30bdfb674c6f01ebed7a5446926fb746e32ddb235000afb58362abd1
4
- data.tar.gz: 7f42b610bfa4aa457ebb1a41df20141502ed79f6fc8da03348d8625e64b2184e
3
+ metadata.gz: fecd1db4ed537d71ce28cfcfd6d6556e2a7d39c108db0bfff677155bdb399fb6
4
+ data.tar.gz: 22ea1366244b563a0ea67db01b8b18c89a25e273f781c78f11bab186761f3b90
5
5
  SHA512:
6
- metadata.gz: ce08093b3c3ab8d774202e3a939ba9b0b6bb8e993750bd011ebef460d387edb8cfbd15aa659682005fd03b0a7046114a57c620b1c823dcf34e4d81a796cc5306
7
- data.tar.gz: f2d44deeb7570bd7533e4e29f169bd9967171cca102461c0a14a6966ced31cf33e4848185d872cf4ec8aa386dda41dc335f7f92235287ee5cdf002e00724c0d2
6
+ metadata.gz: 8d01aa555b6a680c53b4c88ac0a8eabca0beec42fe0db6a173e45d4d405f4baa4fa4c43e44ce57fdc24a86bb85dfedd7f103c5a5a250377e5a71992817b49060
7
+ data.tar.gz: 706935d574fd567b9a597643f4797e93718baf1e8f8ef1fca2ae183982e6b6e50c9936dbe2ef5d7ca274f9221fc83e4814a9fa071f00413b1cc26b545c0bd971
@@ -1,6 +1,7 @@
1
1
  #include "reflex/ruby/application.h"
2
2
 
3
3
 
4
+ #include "reflex/ruby/window.h"
4
5
  #include "defs.h"
5
6
 
6
7
 
@@ -51,6 +52,17 @@ VALUE get_name(VALUE self)
51
52
  return value(THIS->name());
52
53
  }
53
54
 
55
+ static
56
+ VALUE each_window(VALUE self)
57
+ {
58
+ CHECK;
59
+
60
+ Value ret;
61
+ for (auto it = THIS->window_begin(), end = THIS->window_end(); it != end; ++it)
62
+ ret = rb_yield(value(it->get()));
63
+ return ret;
64
+ }
65
+
54
66
  static
55
67
  VALUE on_start(VALUE self, VALUE event)
56
68
  {
@@ -110,6 +122,7 @@ Init_reflex_application ()
110
122
  rb_define_method(cApplication, "quit", RUBY_METHOD_FUNC(quit), 0);
111
123
  rb_define_method(cApplication, "name=", RUBY_METHOD_FUNC(set_name), 1);
112
124
  rb_define_method(cApplication, "name", RUBY_METHOD_FUNC(get_name), 0);
125
+ rb_define_method(cApplication, "each_window", RUBY_METHOD_FUNC(each_window), 0);
113
126
  rb_define_method(cApplication, "on_start", RUBY_METHOD_FUNC(on_start), 1);
114
127
  rb_define_method(cApplication, "on_quit", RUBY_METHOD_FUNC(on_quit), 1);
115
128
  rb_define_method(cApplication, "on_motion", RUBY_METHOD_FUNC(on_motion), 1);
data/ChangeLog.md CHANGED
@@ -1,6 +1,14 @@
1
1
  # reflex ChangeLog
2
2
 
3
3
 
4
+ ## [v0.3.3] - 2025-01-23
5
+
6
+ - Remove dependence on the beeps library
7
+ - Add Application#windows
8
+
9
+ - Fix frame rate limitation on Windows
10
+
11
+
4
12
  ## [v0.3.2] - 2025-01-14
5
13
 
6
14
  - Update workflow files
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.2
1
+ 0.3.3
@@ -1,6 +1,7 @@
1
1
  #include "reflex/ruby/application.h"
2
2
 
3
3
 
4
+ #include "reflex/ruby/window.h"
4
5
  #include "defs.h"
5
6
 
6
7
 
@@ -56,6 +57,18 @@ RUCY_DEF0(get_name)
56
57
  }
57
58
  RUCY_END
58
59
 
60
+ static
61
+ RUCY_DEF0(each_window)
62
+ {
63
+ CHECK;
64
+
65
+ Value ret;
66
+ for (auto it = THIS->window_begin(), end = THIS->window_end(); it != end; ++it)
67
+ ret = rb_yield(value(it->get()));
68
+ return ret;
69
+ }
70
+ RUCY_END
71
+
59
72
  static
60
73
  RUCY_DEF1(on_start, event)
61
74
  {
@@ -121,6 +134,7 @@ Init_reflex_application ()
121
134
  cApplication.define_method("quit", quit);
122
135
  cApplication.define_method("name=", set_name);
123
136
  cApplication.define_method("name", get_name);
137
+ cApplication.define_method("each_window", each_window);
124
138
  cApplication.define_method("on_start", on_start);
125
139
  cApplication.define_method("on_quit", on_quit);
126
140
  cApplication.define_method("on_motion", on_motion);
@@ -13,9 +13,9 @@ require 'reflex/extension'
13
13
  Xot::ExtConf.new Xot, Rucy, Rays, Reflex do
14
14
  setup do
15
15
  headers << 'ruby.h'
16
- libs.unshift 'gdi32', 'opengl32', 'glew32' if win32?
17
- frameworks << 'Cocoa' if osx?
18
- $LDFLAGS << ' -Wl,--out-implib=native.dll.a' if mingw? || cygwin?
16
+ libs.unshift 'gdi32', 'winmm', 'opengl32', 'glew32' if win32?
17
+ frameworks << 'Cocoa' if osx?
18
+ $LDFLAGS << ' -Wl,--out-implib=native.dll.a' if mingw? || cygwin?
19
19
 
20
20
  unless osx?
21
21
  lib_dirs << Rays::Extension.ext_dir
@@ -4,9 +4,11 @@
4
4
  #define __REFLEX_APPLICATION_H__
5
5
 
6
6
 
7
+ #include <vector>
7
8
  #include <xot/ref.h>
8
9
  #include <xot/pimpl.h>
9
10
  #include <reflex/defs.h>
11
+ #include <reflex/window.h>
10
12
  #include <reflex/event.h>
11
13
 
12
14
 
@@ -23,6 +25,12 @@ namespace Reflex
23
25
 
24
26
  typedef Xot::Ref<This> Ref;
25
27
 
28
+ typedef std::vector<Window::Ref> WindowList;
29
+
30
+ typedef WindowList:: iterator window_iterator;
31
+
32
+ typedef WindowList::const_iterator const_window_iterator;
33
+
26
34
  Application ();
27
35
 
28
36
  virtual void start ();
@@ -33,6 +41,14 @@ namespace Reflex
33
41
 
34
42
  virtual const char* name () const;
35
43
 
44
+ virtual window_iterator window_begin ();
45
+
46
+ virtual const_window_iterator window_begin () const;
47
+
48
+ virtual window_iterator window_end ();
49
+
50
+ virtual const_window_iterator window_end () const;
51
+
36
52
  virtual void on_start (Event* e);
37
53
 
38
54
  virtual void on_quit (Event* e);
@@ -23,6 +23,10 @@ module Reflex
23
23
  @start_block = block if block
24
24
  end
25
25
 
26
+ def windows()
27
+ to_enum :each_window
28
+ end
29
+
26
30
  def self.start(*args, &block)
27
31
  new(*args, &block).start
28
32
  end
data/lib/reflexion.rb CHANGED
@@ -1,4 +1,3 @@
1
- require 'beeps'
2
1
  require 'rays'
3
2
  require 'reflex'
4
3
 
@@ -6,7 +5,7 @@ require 'reflex'
6
5
  module Reflexion
7
6
 
8
7
 
9
- include Beeps, Rays, Reflex
8
+ include Rays, Reflex
10
9
 
11
10
 
12
11
  DEFAULTS = {
data/reflex.gemspec CHANGED
@@ -25,10 +25,9 @@ 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_dependency 'xot', '~> 0.3.2', '>= 0.3.2'
29
- s.add_dependency 'rucy', '~> 0.3.2', '>= 0.3.2'
30
- s.add_dependency 'beeps', '~> 0.3.2', '>= 0.3.2'
31
- s.add_dependency 'rays', '~> 0.3.2', '>= 0.3.2'
28
+ s.add_dependency 'xot', '~> 0.3.3', '>= 0.3.3'
29
+ s.add_dependency 'rucy', '~> 0.3.3', '>= 0.3.3'
30
+ s.add_dependency 'rays', '~> 0.3.3', '>= 0.3.3'
32
31
 
33
32
  s.files = `git ls-files`.split $/
34
33
  s.executables = s.files.grep(%r{^bin/}) {|f| File.basename f}
@@ -0,0 +1,88 @@
1
+ #include "application.h"
2
+
3
+
4
+ #include "reflex/exception.h"
5
+ #include "reflex/debug.h"
6
+ #include "window.h"
7
+
8
+
9
+ namespace Reflex
10
+ {
11
+
12
+
13
+ namespace global
14
+ {
15
+
16
+ static Application* instance = NULL;
17
+
18
+ }// global
19
+
20
+
21
+ Application*
22
+ app ()
23
+ {
24
+ return global::instance;
25
+ }
26
+
27
+
28
+ Application::Application ()
29
+ : self(Application_create_data())
30
+ {
31
+ if (global::instance)
32
+ reflex_error(__FILE__, __LINE__, "multiple application instances.");
33
+
34
+ global::instance = this;
35
+ }
36
+
37
+ Application::~Application ()
38
+ {
39
+ global::instance = NULL;
40
+ }
41
+
42
+ void
43
+ Application::set_name (const char* name)
44
+ {
45
+ if (!name)
46
+ argument_error(__FILE__, __LINE__);
47
+
48
+ self->name = name;
49
+ }
50
+
51
+ const char*
52
+ Application::name () const
53
+ {
54
+ return self->name.c_str();
55
+ }
56
+
57
+ Application::window_iterator
58
+ Application::window_begin ()
59
+ {
60
+ return Window_all().begin();
61
+ }
62
+
63
+ Application::const_window_iterator
64
+ Application::window_begin () const
65
+ {
66
+ return Window_all().begin();
67
+ }
68
+
69
+ Application::window_iterator
70
+ Application::window_end ()
71
+ {
72
+ return Window_all().end();
73
+ }
74
+
75
+ Application::const_window_iterator
76
+ Application::window_end () const
77
+ {
78
+ return Window_all().end();
79
+ }
80
+
81
+ bool
82
+ Application::operator ! () const
83
+ {
84
+ return !operator bool();
85
+ }
86
+
87
+
88
+ }// Reflex
data/src/application.h ADDED
@@ -0,0 +1,28 @@
1
+ // -*- c++ -*-
2
+ #pragma once
3
+ #ifndef __REFLEX_SRC_APPLICATION_H__
4
+ #define __REFLEX_SRC_APPLICATION_H__
5
+
6
+
7
+ #include "reflex/application.h"
8
+
9
+
10
+ namespace Reflex
11
+ {
12
+
13
+
14
+ struct Application::Data
15
+ {
16
+
17
+ String name;
18
+
19
+ };// Application::Data
20
+
21
+
22
+ Application::Data* Application_create_data ();
23
+
24
+
25
+ }// Reflex
26
+
27
+
28
+ #endif//EOH
@@ -45,10 +45,11 @@
45
45
  if (!app)
46
46
  Reflex::argument_error(__FILE__, __LINE__);
47
47
 
48
- if (app->self->delegate)
48
+ Reflex::ApplicationData& data = Reflex::Application_get_data(app);
49
+ if (data.delegate)
49
50
  Reflex::invalid_state_error(__FILE__, __LINE__);
50
51
 
51
- app->self->delegate = [self retain];
52
+ data.delegate = [self retain];
52
53
  app->retain();
53
54
 
54
55
  application = app;
@@ -58,10 +59,11 @@
58
59
  {
59
60
  if (!application) return;
60
61
 
61
- if (application->self->delegate)
62
+ Reflex::ApplicationData& data = Reflex::Application_get_data(application);
63
+ if (data.delegate)
62
64
  {
63
- [application->self->delegate release];
64
- application->self->delegate = nil;
65
+ [data.delegate release];
66
+ data.delegate = nil;
65
67
  }
66
68
 
67
69
  application->release();
@@ -4,7 +4,7 @@
4
4
  #define __REFLEX_SRC_IOS_APPLICATION_H__
5
5
 
6
6
 
7
- #include "reflex/application.h"
7
+ #include "../application.h"
8
8
 
9
9
 
10
10
  @class ReflexAppDelegate;
@@ -14,16 +14,19 @@ namespace Reflex
14
14
  {
15
15
 
16
16
 
17
- struct Application::Data
17
+ struct ApplicationData : public Application::Data
18
18
  {
19
19
 
20
20
  ReflexAppDelegate* delegate;
21
21
 
22
- String name;
22
+ ApplicationData ();
23
23
 
24
- Data ();
24
+ };// ApplicationData
25
25
 
26
- };// Application::Data
26
+
27
+ ApplicationData& Application_get_data ( Application* app);
28
+
29
+ const ApplicationData& Application_get_data (const Application* app);
27
30
 
28
31
 
29
32
  }// Reflex
@@ -22,33 +22,33 @@ namespace Reflex
22
22
  {
23
23
 
24
24
 
25
- namespace global
25
+ Application::Data*
26
+ Application_create_data ()
26
27
  {
28
+ return new ApplicationData();
29
+ }
27
30
 
28
- static Application* instance = NULL;
29
-
30
- }// global
31
+ ApplicationData&
32
+ Application_get_data (Application* app)
33
+ {
34
+ if (!app)
35
+ argument_error(__FILE__, __LINE__);
31
36
 
37
+ return (ApplicationData&) *app->self;
38
+ }
32
39
 
33
- Application*
34
- app ()
40
+ const ApplicationData&
41
+ Application_get_data (const Application* app)
35
42
  {
36
- return global::instance;
43
+ return Application_get_data(const_cast<Application*>(app));
37
44
  }
38
45
 
39
46
 
40
- Application::Application ()
47
+ ApplicationData::ApplicationData ()
48
+ : delegate(nil)
41
49
  {
42
- if (global::instance)
43
- reflex_error(__FILE__, __LINE__, "multiple application instances.");
44
-
45
- global::instance = this;
46
50
  }
47
51
 
48
- Application::~Application ()
49
- {
50
- global::instance = NULL;
51
- }
52
52
 
53
53
  void
54
54
  Application::start ()
@@ -75,21 +75,6 @@ namespace Reflex
75
75
  not_implemented_error(__FILE__, __LINE__);
76
76
  }
77
77
 
78
- void
79
- Application::set_name (const char* name)
80
- {
81
- if (!name)
82
- argument_error(__FILE__, __LINE__);
83
-
84
- self->name = name;
85
- }
86
-
87
- const char*
88
- Application::name () const
89
- {
90
- return self->name.c_str();
91
- }
92
-
93
78
  void
94
79
  Application::on_start (Event* e)
95
80
  {
@@ -120,17 +105,5 @@ namespace Reflex
120
105
  return true;
121
106
  }
122
107
 
123
- bool
124
- Application::operator ! () const
125
- {
126
- return !operator bool();
127
- }
128
-
129
-
130
- Application::Data::Data ()
131
- : delegate(nil)
132
- {
133
- }
134
-
135
108
 
136
109
  }// Reflex
@@ -195,6 +195,8 @@ ReflexViewController_get_show_fun ()
195
195
 
196
196
  ptr_for_rebind->Xot::template RefCountable<>::release();
197
197
  ptr_for_rebind = NULL;
198
+
199
+ Window_register(pwindow);
198
200
  }
199
201
  }
200
202
 
@@ -203,6 +205,8 @@ ReflexViewController_get_show_fun ()
203
205
  [self rebind];
204
206
  if (!pwindow) return;
205
207
 
208
+ Window_unregister(pwindow);
209
+
206
210
  Window_get_data(pwindow).view_controller = nil;
207
211
 
208
212
  pwindow->release();
@@ -38,10 +38,11 @@
38
38
  if (!app)
39
39
  Reflex::argument_error(__FILE__, __LINE__);
40
40
 
41
- if (app->self->delegate)
41
+ Reflex::ApplicationData& data = Reflex::Application_get_data(app);
42
+ if (data.delegate)
42
43
  Reflex::invalid_state_error(__FILE__, __LINE__);
43
44
 
44
- app->self->delegate = [self retain];
45
+ data.delegate = [self retain];
45
46
  app->retain();
46
47
 
47
48
  application = app;
@@ -51,10 +52,11 @@
51
52
  {
52
53
  if (!application) return;
53
54
 
54
- if (application->self->delegate)
55
+ Reflex::ApplicationData& data = Reflex::Application_get_data(application);
56
+ if (data.delegate)
55
57
  {
56
- [application->self->delegate release];
57
- application->self->delegate = nil;
58
+ [data.delegate release];
59
+ data.delegate = nil;
58
60
  }
59
61
 
60
62
  application->release();
@@ -4,7 +4,7 @@
4
4
  #define __REFLEX_SRC_OSX_APPLICATION_H__
5
5
 
6
6
 
7
- #include "reflex/application.h"
7
+ #include "../application.h"
8
8
 
9
9
 
10
10
  @class ReflexAppDelegate;
@@ -14,16 +14,19 @@ namespace Reflex
14
14
  {
15
15
 
16
16
 
17
- struct Application::Data
17
+ struct ApplicationData : public Application::Data
18
18
  {
19
19
 
20
20
  ReflexAppDelegate* delegate;
21
21
 
22
- String name;
22
+ ApplicationData ();
23
23
 
24
- Data ();
24
+ };// ApplicationData
25
25
 
26
- };// Application::Data
26
+
27
+ ApplicationData& Application_get_data ( Application* app);
28
+
29
+ const ApplicationData& Application_get_data (const Application* app);
27
30
 
28
31
 
29
32
  }// Reflex
@@ -12,33 +12,33 @@ namespace Reflex
12
12
  {
13
13
 
14
14
 
15
- namespace global
15
+ Application::Data*
16
+ Application_create_data ()
16
17
  {
18
+ return new ApplicationData();
19
+ }
17
20
 
18
- static Application* instance = NULL;
19
-
20
- }// global
21
+ ApplicationData&
22
+ Application_get_data (Application* app)
23
+ {
24
+ if (!app)
25
+ argument_error(__FILE__, __LINE__);
21
26
 
27
+ return (ApplicationData&) *app->self;
28
+ }
22
29
 
23
- Application*
24
- app ()
30
+ const ApplicationData&
31
+ Application_get_data (const Application* app)
25
32
  {
26
- return global::instance;
33
+ return Application_get_data(const_cast<Application*>(app));
27
34
  }
28
35
 
29
36
 
30
- Application::Application ()
37
+ ApplicationData::ApplicationData ()
38
+ : delegate(nil)
31
39
  {
32
- if (global::instance)
33
- reflex_error(__FILE__, __LINE__, "multiple application instances.");
34
-
35
- global::instance = this;
36
40
  }
37
41
 
38
- Application::~Application ()
39
- {
40
- global::instance = NULL;
41
- }
42
42
 
43
43
  static ReflexAppDelegate*
44
44
  setup_app_delegate (NSApplication* app)
@@ -75,21 +75,6 @@ namespace Reflex
75
75
  [NSApp terminate: nil];
76
76
  }
77
77
 
78
- void
79
- Application::set_name (const char* name)
80
- {
81
- if (!name)
82
- argument_error(__FILE__, __LINE__);
83
-
84
- self->name = name;
85
- }
86
-
87
- const char*
88
- Application::name () const
89
- {
90
- return self->name.c_str();
91
- }
92
-
93
78
  void
94
79
  Application::on_start (Event* e)
95
80
  {
@@ -121,17 +106,5 @@ namespace Reflex
121
106
  return true;
122
107
  }
123
108
 
124
- bool
125
- Application::operator ! () const
126
- {
127
- return !operator bool();
128
- }
129
-
130
-
131
- Application::Data::Data ()
132
- : delegate(nil)
133
- {
134
- }
135
-
136
109
 
137
110
  }// Reflex
@@ -119,6 +119,8 @@ move_to_main_screen_origin (NativeWindow* window)
119
119
 
120
120
  ptr_for_rebind->Xot::template RefCountable<>::release();
121
121
  ptr_for_rebind = NULL;
122
+
123
+ Window_register(pwindow);
122
124
  }
123
125
  }
124
126
 
@@ -127,6 +129,8 @@ move_to_main_screen_origin (NativeWindow* window)
127
129
  [self rebind];
128
130
  if (!pwindow) return;
129
131
 
132
+ Window_unregister(pwindow);
133
+
130
134
  Window_get_data(pwindow).native = nil;
131
135
 
132
136
  pwindow->release();
@@ -1,48 +1,41 @@
1
- #include "reflex/application.h"
1
+ #include "../application.h"
2
2
 
3
3
 
4
4
  #include <xot/windows.h>
5
5
  #include "reflex/exception.h"
6
+ #include "window.h"
6
7
 
7
8
 
8
9
  namespace Reflex
9
10
  {
10
11
 
11
12
 
12
- namespace global
13
+ Application::Data*
14
+ Application_create_data ()
13
15
  {
14
-
15
- static Application* instance = NULL;
16
-
17
- }// global
18
-
19
-
20
- Application*
21
- app ()
22
- {
23
- return global::instance;
16
+ return new Application::Data();
24
17
  }
25
18
 
26
19
 
27
- struct Application::Data
28
- {
29
-
30
- String name;
31
-
32
- };// Application::Data
33
-
34
-
35
- Application::Application ()
20
+ static double
21
+ get_time ()
36
22
  {
37
- if (global::instance)
38
- reflex_error(__FILE__, __LINE__, "multiple application instances.");
23
+ static const double FREQUENCY_INV = []() {
24
+ LARGE_INTEGER freq;
25
+ QueryPerformanceFrequency(&freq);
26
+ return 1.0 / (double) freq.QuadPart;
27
+ }();
39
28
 
40
- global::instance = this;
29
+ LARGE_INTEGER counter;
30
+ QueryPerformanceCounter(&counter);
31
+ return (double) counter.QuadPart * FREQUENCY_INV;
41
32
  }
42
33
 
43
- Application::~Application ()
34
+ static void
35
+ update_all_windows (Application* app)
44
36
  {
45
- global::instance = NULL;
37
+ for (auto it = app->window_begin(), end = app->window_end(); it != end; ++it)
38
+ Window_update(it->get());
46
39
  }
47
40
 
48
41
  void
@@ -51,13 +44,39 @@ namespace Reflex
51
44
  Event e;
52
45
  on_start(&e);
53
46
 
47
+ timeBeginPeriod(1);
48
+
49
+ double prev = get_time();
50
+
54
51
  MSG msg;
55
- while (GetMessage(&msg, NULL, 0, 0))
52
+ while (true)
56
53
  {
57
- TranslateMessage(&msg);
58
- DispatchMessage(&msg);
54
+ if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
55
+ {
56
+ if (msg.message == WM_QUIT) break;
57
+ TranslateMessage(&msg);
58
+ DispatchMessage(&msg);
59
+ }
60
+ else
61
+ {
62
+ static const double INTERVAL = 1.0 / 60.0;
63
+ static const double SLEEPABLE = INTERVAL * 0.9;
64
+
65
+ double now = get_time();
66
+ double dt = now - prev;
67
+ if (dt < INTERVAL)
68
+ {
69
+ if (dt < SLEEPABLE) Sleep(1);
70
+ continue;
71
+ }
72
+
73
+ update_all_windows(this);
74
+ prev = now;
75
+ }
59
76
  }
60
77
 
78
+ timeEndPeriod(1);
79
+
61
80
  if (msg.wParam != 0)
62
81
  reflex_error(__FILE__, __LINE__, "WM_QUIT with wParam %d.", msg.wParam);
63
82
  }
@@ -68,21 +87,6 @@ namespace Reflex
68
87
  PostQuitMessage(0);
69
88
  }
70
89
 
71
- void
72
- Application::set_name (const char* name)
73
- {
74
- if (!name)
75
- argument_error(__FILE__, __LINE__);
76
-
77
- self->name = name;
78
- }
79
-
80
- const char*
81
- Application::name () const
82
- {
83
- return self->name.c_str();
84
- }
85
-
86
90
  void
87
91
  Application::on_start (Event* e)
88
92
  {
@@ -113,11 +117,5 @@ namespace Reflex
113
117
  return true;
114
118
  }
115
119
 
116
- bool
117
- Application::operator ! () const
118
- {
119
- return !operator bool();
120
- }
121
-
122
120
 
123
121
  }// Reflex
data/src/win32/window.cpp CHANGED
@@ -1,4 +1,4 @@
1
- #include "../window.h"
1
+ #include "window.h"
2
2
 
3
3
 
4
4
  #include <assert.h>
@@ -8,7 +8,6 @@
8
8
  #include <xot/windows.h>
9
9
  #include <rays/rays.h>
10
10
  #include "reflex/defs.h"
11
- #include "reflex/application.h"
12
11
  #include "reflex/exception.h"
13
12
  #include "reflex/debug.h"
14
13
  #include "../view.h"
@@ -28,8 +27,6 @@ namespace Reflex
28
27
 
29
28
  static const char* USERDATA_PROP = "Reflex:Window:HWND";
30
29
 
31
- enum {UPDATE_TIMER_ID = 99999};
32
-
33
30
 
34
31
  struct WindowData : public Window::Data
35
32
  {
@@ -152,8 +149,8 @@ namespace Reflex
152
149
  win->release();
153
150
  }
154
151
 
155
- static void
156
- update (Window* win)
152
+ void
153
+ Window_update (Window* win)
157
154
  {
158
155
  WindowData* self = get_data(win);
159
156
 
@@ -435,13 +432,6 @@ namespace Reflex
435
432
  break;
436
433
  }
437
434
 
438
- case WM_TIMER:
439
- {
440
- if (wp == UPDATE_TIMER_ID)
441
- update(win);
442
- return 0;
443
- }
444
-
445
435
  case WM_SYSCOMMAND:
446
436
  {
447
437
  #if 0
@@ -458,8 +448,6 @@ namespace Reflex
458
448
  static LRESULT CALLBACK
459
449
  wndproc (HWND hwnd, UINT msg, WPARAM wp, LPARAM lp)
460
450
  {
461
- static int window_total = 0;
462
-
463
451
  Window* win = NULL;
464
452
  if (msg == WM_NCCREATE)
465
453
  {
@@ -467,7 +455,7 @@ namespace Reflex
467
455
  win = (Window*) cs->lpCreateParams;
468
456
  setup_window(win, hwnd);
469
457
 
470
- ++window_total;
458
+ Window_register(win);
471
459
  }
472
460
 
473
461
  if (!win)
@@ -477,9 +465,11 @@ namespace Reflex
477
465
 
478
466
  if (msg == WM_NCDESTROY)
479
467
  {
468
+ Window_unregister(win);
469
+
480
470
  cleanup_window(win);
481
471
 
482
- if (--window_total == 0)
472
+ if (Window_all().empty())
483
473
  Reflex::app()->quit();
484
474
  }
485
475
 
@@ -556,28 +546,6 @@ namespace Reflex
556
546
  create_window(window);
557
547
  }
558
548
 
559
- static void
560
- start_timer (HWND hwnd, UINT id, UINT interval)
561
- {
562
- if (!hwnd)
563
- argument_error(__FILE__, __LINE__);
564
-
565
- if (!SetTimer(hwnd, id, interval, NULL))
566
- system_error(__FILE__, __LINE__);
567
- }
568
-
569
- static void
570
- stop_timer (HWND hwnd, UINT id)
571
- {
572
- if (!hwnd)
573
- argument_error(__FILE__, __LINE__);
574
-
575
- if (id == 0) return;
576
-
577
- if (!KillTimer(hwnd, id))
578
- system_error(__FILE__, __LINE__);
579
- }
580
-
581
549
  void
582
550
  Window_show (Window* window)
583
551
  {
@@ -590,8 +558,6 @@ namespace Reflex
590
558
  self->hwnd, HWND_TOP, 0, 0, 0, 0,
591
559
  SWP_SHOWWINDOW | SWP_NOMOVE | SWP_NOSIZE);
592
560
  UpdateWindow(self->hwnd);
593
-
594
- start_timer(self->hwnd, UPDATE_TIMER_ID, 1000 / 60);
595
561
  }
596
562
 
597
563
  void
@@ -605,8 +571,6 @@ namespace Reflex
605
571
  SetWindowPos(
606
572
  self->hwnd, NULL, 0, 0, 0, 0,
607
573
  SWP_HIDEWINDOW | SWP_NOMOVE | SWP_NOSIZE);
608
-
609
- stop_timer(self->hwnd, UPDATE_TIMER_ID);
610
574
  }
611
575
 
612
576
  void
@@ -0,0 +1,20 @@
1
+ // -*- c++ -*-
2
+ #pragma once
3
+ #ifndef __REFLEX_SRC_WIN32_WINDOW_H__
4
+ #define __REFLEX_SRC_WIN32_WINDOW_H__
5
+
6
+
7
+ #include "../window.h"
8
+
9
+
10
+ namespace Reflex
11
+ {
12
+
13
+
14
+ void Window_update (Window* win);
15
+
16
+
17
+ }// Reflex
18
+
19
+
20
+ #endif//EOH
data/src/window.cpp CHANGED
@@ -22,6 +22,37 @@ namespace Reflex
22
22
  using CaptureTargetIDList = Window::Data::CaptureTargetIDList;
23
23
 
24
24
 
25
+ void
26
+ Window_register (Window* win)
27
+ {
28
+ auto& all = Window_all();
29
+
30
+ auto it = std::find(all.begin(), all.end(), win);
31
+ if (it != all.end())
32
+ invalid_state_error(__FILE__, __LINE__);
33
+
34
+ all.push_back(win);
35
+ }
36
+
37
+ void
38
+ Window_unregister (Window* win)
39
+ {
40
+ auto& all = Window_all();
41
+
42
+ auto it = std::find(all.begin(), all.end(), win);
43
+ if (it == all.end()) return;
44
+
45
+ all.erase(it);
46
+ }
47
+
48
+ Application::WindowList&
49
+ Window_all ()
50
+ {
51
+ static Application::WindowList windows;
52
+ return windows;
53
+ }
54
+
55
+
25
56
  Window::Data::Data ()
26
57
  : flags(Window_default_flags())
27
58
  {
data/src/window.h CHANGED
@@ -12,6 +12,7 @@
12
12
  #include <rays/painter.h>
13
13
  #include "reflex/window.h"
14
14
  #include "reflex/view.h"
15
+ #include "application.h"
15
16
  #include "pointer.h"
16
17
 
17
18
 
@@ -75,6 +76,13 @@ namespace Reflex
75
76
 
76
77
  Window::Data* Window_create_data ();
77
78
 
79
+ void Window_register (Window* win);
80
+
81
+ void Window_unregister (Window* win);
82
+
83
+ Application::WindowList& Window_all ();
84
+
85
+
78
86
  uint Window_default_flags ();
79
87
 
80
88
  void Window_initialize (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.3.2
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - xordog
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-01-13 00:00:00.000000000 Z
11
+ date: 2025-01-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: xot
@@ -16,80 +16,60 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 0.3.2
19
+ version: 0.3.3
20
20
  - - ">="
21
21
  - !ruby/object:Gem::Version
22
- version: 0.3.2
22
+ version: 0.3.3
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  requirements:
27
27
  - - "~>"
28
28
  - !ruby/object:Gem::Version
29
- version: 0.3.2
29
+ version: 0.3.3
30
30
  - - ">="
31
31
  - !ruby/object:Gem::Version
32
- version: 0.3.2
32
+ version: 0.3.3
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: rucy
35
35
  requirement: !ruby/object:Gem::Requirement
36
36
  requirements:
37
37
  - - "~>"
38
38
  - !ruby/object:Gem::Version
39
- version: 0.3.2
39
+ version: 0.3.3
40
40
  - - ">="
41
41
  - !ruby/object:Gem::Version
42
- version: 0.3.2
42
+ version: 0.3.3
43
43
  type: :runtime
44
44
  prerelease: false
45
45
  version_requirements: !ruby/object:Gem::Requirement
46
46
  requirements:
47
47
  - - "~>"
48
48
  - !ruby/object:Gem::Version
49
- version: 0.3.2
49
+ version: 0.3.3
50
50
  - - ">="
51
51
  - !ruby/object:Gem::Version
52
- version: 0.3.2
53
- - !ruby/object:Gem::Dependency
54
- name: beeps
55
- requirement: !ruby/object:Gem::Requirement
56
- requirements:
57
- - - "~>"
58
- - !ruby/object:Gem::Version
59
- version: 0.3.2
60
- - - ">="
61
- - !ruby/object:Gem::Version
62
- version: 0.3.2
63
- type: :runtime
64
- prerelease: false
65
- version_requirements: !ruby/object:Gem::Requirement
66
- requirements:
67
- - - "~>"
68
- - !ruby/object:Gem::Version
69
- version: 0.3.2
70
- - - ">="
71
- - !ruby/object:Gem::Version
72
- version: 0.3.2
52
+ version: 0.3.3
73
53
  - !ruby/object:Gem::Dependency
74
54
  name: rays
75
55
  requirement: !ruby/object:Gem::Requirement
76
56
  requirements:
77
57
  - - "~>"
78
58
  - !ruby/object:Gem::Version
79
- version: 0.3.2
59
+ version: 0.3.3
80
60
  - - ">="
81
61
  - !ruby/object:Gem::Version
82
- version: 0.3.2
62
+ version: 0.3.3
83
63
  type: :runtime
84
64
  prerelease: false
85
65
  version_requirements: !ruby/object:Gem::Requirement
86
66
  requirements:
87
67
  - - "~>"
88
68
  - !ruby/object:Gem::Version
89
- version: 0.3.2
69
+ version: 0.3.3
90
70
  - - ">="
91
71
  - !ruby/object:Gem::Version
92
- version: 0.3.2
72
+ version: 0.3.3
93
73
  description: This library helps you to develop interactive graphical user interface.
94
74
  email: xordog@gmail.com
95
75
  executables: []
@@ -341,6 +321,8 @@ files:
341
321
  - samples/tree.rb
342
322
  - samples/views.rb
343
323
  - samples/visuals.rb
324
+ - src/application.cpp
325
+ - src/application.h
344
326
  - src/body.cpp
345
327
  - src/body.h
346
328
  - src/event.cpp
@@ -402,6 +384,7 @@ files:
402
384
  - src/win32/screen.cpp
403
385
  - src/win32/screen.h
404
386
  - src/win32/window.cpp
387
+ - src/win32/window.h
405
388
  - src/window.cpp
406
389
  - src/window.h
407
390
  - src/world.cpp