reflexion 0.2.1 → 0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (106) hide show
  1. checksums.yaml +4 -4
  2. data/.doc/ext/reflex/application.cpp +1 -1
  3. data/.doc/ext/reflex/capture_event.cpp +1 -1
  4. data/.doc/ext/reflex/contact_event.cpp +1 -1
  5. data/.doc/ext/reflex/draw_event.cpp +1 -1
  6. data/.doc/ext/reflex/ellipse_shape.cpp +1 -1
  7. data/.doc/ext/reflex/event.cpp +1 -1
  8. data/.doc/ext/reflex/filter.cpp +1 -1
  9. data/.doc/ext/reflex/focus_event.cpp +1 -1
  10. data/.doc/ext/reflex/frame_event.cpp +1 -1
  11. data/.doc/ext/reflex/image_view.cpp +1 -1
  12. data/.doc/ext/reflex/key_event.cpp +74 -69
  13. data/.doc/ext/reflex/line_shape.cpp +1 -1
  14. data/.doc/ext/reflex/motion_event.cpp +1 -1
  15. data/.doc/ext/reflex/pointer.cpp +1 -1
  16. data/.doc/ext/reflex/pointer_event.cpp +1 -1
  17. data/.doc/ext/reflex/polygon_shape.cpp +1 -1
  18. data/.doc/ext/reflex/rect_shape.cpp +1 -1
  19. data/.doc/ext/reflex/reflex.cpp +58 -50
  20. data/.doc/ext/reflex/screen.cpp +1 -1
  21. data/.doc/ext/reflex/scroll_event.cpp +1 -1
  22. data/.doc/ext/reflex/selector.cpp +2 -2
  23. data/.doc/ext/reflex/shape.cpp +1 -1
  24. data/.doc/ext/reflex/style.cpp +1 -1
  25. data/.doc/ext/reflex/style_length.cpp +2 -2
  26. data/.doc/ext/reflex/timer.cpp +1 -1
  27. data/.doc/ext/reflex/timer_event.cpp +1 -1
  28. data/.doc/ext/reflex/update_event.cpp +1 -1
  29. data/.doc/ext/reflex/view.cpp +1 -1
  30. data/.doc/ext/reflex/wheel_event.cpp +1 -1
  31. data/.doc/ext/reflex/window.cpp +1 -1
  32. data/.github/workflows/release-gem.yml +1 -1
  33. data/.github/workflows/test.yml +3 -0
  34. data/ChangeLog.md +5 -0
  35. data/Rakefile +1 -1
  36. data/VERSION +1 -1
  37. data/ext/reflex/application.cpp +1 -1
  38. data/ext/reflex/capture_event.cpp +1 -1
  39. data/ext/reflex/contact_event.cpp +1 -1
  40. data/ext/reflex/defs.h +2 -0
  41. data/ext/reflex/draw_event.cpp +1 -1
  42. data/ext/reflex/ellipse_shape.cpp +1 -1
  43. data/ext/reflex/event.cpp +1 -1
  44. data/ext/reflex/extconf.rb +4 -4
  45. data/ext/reflex/filter.cpp +1 -1
  46. data/ext/reflex/focus_event.cpp +1 -1
  47. data/ext/reflex/frame_event.cpp +1 -1
  48. data/ext/reflex/image_view.cpp +1 -1
  49. data/ext/reflex/key_event.cpp +74 -69
  50. data/ext/reflex/line_shape.cpp +1 -1
  51. data/ext/reflex/motion_event.cpp +1 -1
  52. data/ext/reflex/pointer.cpp +1 -1
  53. data/ext/reflex/pointer_event.cpp +1 -1
  54. data/ext/reflex/polygon_shape.cpp +1 -1
  55. data/ext/reflex/rect_shape.cpp +1 -1
  56. data/ext/reflex/reflex.cpp +58 -50
  57. data/ext/reflex/screen.cpp +1 -1
  58. data/ext/reflex/scroll_event.cpp +1 -1
  59. data/ext/reflex/selector.cpp +2 -2
  60. data/ext/reflex/shape.cpp +1 -1
  61. data/ext/reflex/style.cpp +1 -1
  62. data/ext/reflex/style_length.cpp +2 -2
  63. data/ext/reflex/timer.cpp +1 -1
  64. data/ext/reflex/timer_event.cpp +1 -1
  65. data/ext/reflex/update_event.cpp +1 -1
  66. data/ext/reflex/view.cpp +1 -1
  67. data/ext/reflex/wheel_event.cpp +1 -1
  68. data/ext/reflex/window.cpp +1 -1
  69. data/include/reflex/defs.h +204 -187
  70. data/include/reflex/reflex.h +1 -0
  71. data/include/reflex/ruby/application.h +2 -2
  72. data/include/reflex/ruby/event.h +26 -26
  73. data/include/reflex/ruby/exception.h +3 -3
  74. data/include/reflex/ruby/filter.h +2 -2
  75. data/include/reflex/ruby/image_view.h +2 -2
  76. data/include/reflex/ruby/pointer.h +2 -2
  77. data/include/reflex/ruby/reflex.h +1 -1
  78. data/include/reflex/ruby/screen.h +2 -2
  79. data/include/reflex/ruby/selector.h +2 -2
  80. data/include/reflex/ruby/shape.h +10 -10
  81. data/include/reflex/ruby/style.h +4 -4
  82. data/include/reflex/ruby/timer.h +2 -2
  83. data/include/reflex/ruby/view.h +2 -2
  84. data/include/reflex/ruby/window.h +2 -2
  85. data/lib/reflex/extension.rb +4 -0
  86. data/reflex.gemspec +4 -4
  87. data/src/event.cpp +7 -3
  88. data/src/event.h +2 -0
  89. data/src/ios/event.mm +21 -27
  90. data/src/shape.cpp +2 -2
  91. data/src/view.cpp +1 -0
  92. data/src/win32/application.cpp +48 -35
  93. data/src/win32/device.cpp +18 -0
  94. data/src/win32/event.cpp +221 -0
  95. data/src/win32/event.h +50 -0
  96. data/src/win32/opengl.cpp +54 -27
  97. data/src/win32/opengl.h +15 -13
  98. data/src/win32/reflex.cpp +10 -16
  99. data/src/win32/screen.cpp +61 -0
  100. data/src/win32/screen.h +21 -0
  101. data/src/win32/window.cpp +445 -240
  102. data/src/window.cpp +1 -0
  103. data/test/test_window.rb +24 -21
  104. metadata +14 -11
  105. data/src/win32/defs.cpp +0 -303
  106. data/src/win32/defs.h +0 -34
data/src/win32/event.h ADDED
@@ -0,0 +1,50 @@
1
+ // -*- c++ -*-
2
+ #pragma once
3
+ #ifndef __REFLEX_SRC_WIN32_EVENT_H__
4
+ #define __REFLEX_SRC_WIN32_EVENT_H__
5
+
6
+
7
+ #include <xot/windows.h>
8
+ #include "../event.h"
9
+
10
+
11
+ namespace Reflex
12
+ {
13
+
14
+
15
+ class NativeKeyEvent : public KeyEvent
16
+ {
17
+
18
+ public:
19
+
20
+ NativeKeyEvent (UINT msg, WPARAM wp, LPARAM lp, const char* chars = NULL);
21
+
22
+ };// NativeKeyEvent
23
+
24
+
25
+ class NativePointerEvent : public PointerEvent
26
+ {
27
+
28
+ public:
29
+
30
+ NativePointerEvent (UINT msg, WPARAM wp, LPARAM lp);
31
+
32
+ NativePointerEvent (HWND hwnd, const TOUCHINPUT* touches, size_t size);
33
+
34
+ };// NativePointerEvent
35
+
36
+
37
+ class NativeWheelEvent : public WheelEvent
38
+ {
39
+
40
+ public:
41
+
42
+ NativeWheelEvent (WPARAM wp_x, WPARAM wp_y, LPARAM lp);
43
+
44
+ };// NativeWheelEvent
45
+
46
+
47
+ }// Reflex
48
+
49
+
50
+ #endif//EOH
data/src/win32/opengl.cpp CHANGED
@@ -1,28 +1,35 @@
1
1
  #include "opengl.h"
2
2
 
3
3
 
4
+ #include "reflex/exception.h"
5
+
6
+
4
7
  namespace Reflex
5
8
  {
6
9
 
7
10
 
8
- OpenGL::OpenGL ()
9
- : hwnd(NULL), hdc(NULL), hrc(NULL)
11
+ OpenGLContext::OpenGLContext ()
10
12
  {
11
13
  }
12
14
 
13
- OpenGL::~OpenGL ()
15
+ OpenGLContext::~OpenGLContext ()
14
16
  {
15
17
  fin();
16
18
  }
17
19
 
18
- bool
19
- OpenGL::init (HWND hwnd_)
20
+ void
21
+ OpenGLContext::init (HWND hwnd_)
20
22
  {
21
- if (!hwnd_ || *this) return false;
23
+ if (!hwnd_)
24
+ argument_error(__FILE__, __LINE__);
25
+
26
+ if (*this)
27
+ invalid_state_error(__FILE__, __LINE__);
22
28
 
23
29
  hwnd = hwnd_;
24
30
  hdc = GetDC(hwnd);
25
- if (!hdc) return false;
31
+ if (!hdc)
32
+ system_error(__FILE__, __LINE__);
26
33
 
27
34
  static const PIXELFORMATDESCRIPTOR PFD =
28
35
  {
@@ -33,60 +40,80 @@ namespace Reflex
33
40
  };
34
41
 
35
42
  int pf = ChoosePixelFormat(hdc, &PFD);
36
- if (pf == 0) return false;
43
+ if (pf == 0)
44
+ system_error(__FILE__, __LINE__);
37
45
 
38
46
  if (!SetPixelFormat(hdc, pf, &PFD))
39
- return false;
47
+ system_error(__FILE__, __LINE__);
40
48
 
41
49
  hrc = wglCreateContext(hdc);
42
- if (!hrc) return false;
50
+ if (!hrc)
51
+ system_error(__FILE__, __LINE__);
43
52
 
44
- return make_current();
53
+ make_current();
45
54
  }
46
55
 
47
- bool
48
- OpenGL::fin ()
56
+ void
57
+ OpenGLContext::fin ()
49
58
  {
50
- if (!*this) return false;
59
+ if (!*this) return;
51
60
 
52
61
  if (hrc)
53
62
  {
54
- wglMakeCurrent(NULL, NULL);
55
- wglDeleteContext(hrc);
63
+ if (hrc == wglGetCurrentContext())
64
+ {
65
+ if (!wglMakeCurrent(NULL, NULL))
66
+ system_error(__FILE__, __LINE__);
67
+ }
68
+
69
+ if (!wglDeleteContext(hrc))
70
+ system_error(__FILE__, __LINE__);
71
+
56
72
  hrc = NULL;
57
73
  }
58
74
 
59
75
  if (hdc)
60
76
  {
61
- ReleaseDC(hwnd, hdc);
77
+ if (!ReleaseDC(hwnd, hdc))
78
+ system_error(__FILE__, __LINE__);
79
+
62
80
  hdc = NULL;
63
81
  }
64
82
 
65
83
  hwnd = NULL;
66
- return true;
67
84
  }
68
85
 
69
- bool
70
- OpenGL::make_current ()
86
+ void
87
+ OpenGLContext::make_current ()
71
88
  {
72
- if (!*this) return false;
73
- return wglMakeCurrent(hdc, hrc) != FALSE;
89
+ if (!*this) return;
90
+
91
+ if (!wglMakeCurrent(hdc, hrc))
92
+ system_error(__FILE__, __LINE__);
93
+ }
94
+
95
+ void
96
+ OpenGLContext::swap_buffers ()
97
+ {
98
+ if (!*this) return;
99
+
100
+ if (!SwapBuffers(hdc))
101
+ system_error(__FILE__, __LINE__);
74
102
  }
75
103
 
76
104
  bool
77
- OpenGL::swap_buffers ()
105
+ OpenGLContext::is_active () const
78
106
  {
79
- if (!*this) return false;
80
- return SwapBuffers(hdc) != FALSE;
107
+ return *this && hrc == wglGetCurrentContext();
81
108
  }
82
109
 
83
- OpenGL::operator bool () const
110
+ OpenGLContext::operator bool () const
84
111
  {
85
112
  return hwnd && hdc && hrc;
86
113
  }
87
114
 
88
115
  bool
89
- OpenGL::operator ! () const
116
+ OpenGLContext::operator ! () const
90
117
  {
91
118
  return !operator bool();
92
119
  }
data/src/win32/opengl.h CHANGED
@@ -4,30 +4,32 @@
4
4
  #define __REFLEX_SRC_WIN32_OPENGL_H__
5
5
 
6
6
 
7
- #include <windows.h>
8
- #include <rays/opengl.h>
7
+ #include <GL/glew.h>
8
+ #include <xot/windows.h>
9
9
 
10
10
 
11
11
  namespace Reflex
12
12
  {
13
13
 
14
14
 
15
- class OpenGL
15
+ class OpenGLContext
16
16
  {
17
17
 
18
18
  public:
19
19
 
20
- OpenGL ();
20
+ OpenGLContext ();
21
21
 
22
- ~OpenGL ();
22
+ ~OpenGLContext ();
23
23
 
24
- bool init (HWND hwnd);
24
+ void init (HWND hwnd);
25
25
 
26
- bool fin ();
26
+ void fin ();
27
27
 
28
- bool make_current ();
28
+ void make_current ();
29
29
 
30
- bool swap_buffers ();
30
+ void swap_buffers ();
31
+
32
+ bool is_active () const;
31
33
 
32
34
  operator bool () const;
33
35
 
@@ -35,13 +37,13 @@ namespace Reflex
35
37
 
36
38
  private:
37
39
 
38
- HWND hwnd;
40
+ HWND hwnd = NULL;
39
41
 
40
- HDC hdc;
42
+ HDC hdc = NULL;
41
43
 
42
- HGLRC hrc;
44
+ HGLRC hrc = NULL;
43
45
 
44
- };// OpenGL
46
+ };// OpenGLContext
45
47
 
46
48
 
47
49
  }// Reflex
data/src/win32/reflex.cpp CHANGED
@@ -1,7 +1,7 @@
1
1
  #include "reflex/reflex.h"
2
2
 
3
3
 
4
- #include <windows.h>
4
+ #include "reflex/exception.h"
5
5
 
6
6
 
7
7
  namespace Reflex
@@ -11,33 +11,27 @@ namespace Reflex
11
11
  namespace global
12
12
  {
13
13
 
14
- static bool init = false;
14
+ static bool initialized = false;
15
15
 
16
16
  }// global
17
17
 
18
18
 
19
- bool
20
- initialized ()
21
- {
22
- return global::init;
23
- }
24
-
25
- bool
19
+ void
26
20
  init ()
27
21
  {
28
- if (global::init) return false;
22
+ if (global::initialized)
23
+ reflex_error(__FILE__, __LINE__, "already initialized.");
29
24
 
30
- global::init = true;
31
- return true;
25
+ global::initialized = true;
32
26
  }
33
27
 
34
- bool
28
+ void
35
29
  fin ()
36
30
  {
37
- if (!global::init) return false;
31
+ if (!global::initialized)
32
+ reflex_error(__FILE__, __LINE__, "not initialized.");
38
33
 
39
- global::init = false;
40
- return true;
34
+ global::initialized = false;
41
35
  }
42
36
 
43
37
 
@@ -0,0 +1,61 @@
1
+ #include "screen.h"
2
+
3
+
4
+ #include "reflex/exception.h"
5
+
6
+
7
+ namespace Reflex
8
+ {
9
+
10
+
11
+ struct Screen::Data
12
+ {
13
+
14
+ HMONITOR handle = NULL;
15
+
16
+ };// Screen::Data
17
+
18
+
19
+ void
20
+ Screen_initialize (Screen* pthis, HMONITOR hmonitor)
21
+ {
22
+ pthis->self->handle = hmonitor;
23
+ }
24
+
25
+
26
+ Screen::Screen ()
27
+ {
28
+ }
29
+
30
+ Screen::~Screen ()
31
+ {
32
+ }
33
+
34
+ Bounds
35
+ Screen::frame () const
36
+ {
37
+ if (!*this)
38
+ invalid_state_error(__FILE__, __LINE__);
39
+
40
+ MONITORINFO mi = {0};
41
+ mi.cbSize = sizeof(mi);
42
+ if (!GetMonitorInfo(self->handle, &mi))
43
+ system_error(__FILE__, __LINE__);
44
+
45
+ const auto& r = mi.rcMonitor;
46
+ return Bounds(r.left, r.top, r.right - r.left, r.bottom - r.top);
47
+ }
48
+
49
+ Screen::operator bool () const
50
+ {
51
+ return self->handle;
52
+ }
53
+
54
+ bool
55
+ Screen::operator ! () const
56
+ {
57
+ return !operator bool();
58
+ }
59
+
60
+
61
+ }// Reflex
@@ -0,0 +1,21 @@
1
+ // -*- c++ -*-
2
+ #pragma once
3
+ #ifndef __REFLEX_SRC_WIN32_SCREEN_H__
4
+ #define __REFLEX_SRC_WIN32_SCREEN_H__
5
+
6
+
7
+ #include <xot/windows.h>
8
+ #include "reflex/screen.h"
9
+
10
+
11
+ namespace Reflex
12
+ {
13
+
14
+
15
+ void Screen_initialize (Screen* pthis, HMONITOR hmonitor);
16
+
17
+
18
+ }// Reflex
19
+
20
+
21
+ #endif//EOH