reflexion 0.2.1 → 0.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 +4 -4
- data/.doc/ext/reflex/application.cpp +1 -1
- data/.doc/ext/reflex/capture_event.cpp +1 -1
- data/.doc/ext/reflex/contact_event.cpp +1 -1
- data/.doc/ext/reflex/draw_event.cpp +1 -1
- data/.doc/ext/reflex/ellipse_shape.cpp +1 -1
- data/.doc/ext/reflex/event.cpp +1 -1
- data/.doc/ext/reflex/filter.cpp +1 -1
- data/.doc/ext/reflex/focus_event.cpp +1 -1
- data/.doc/ext/reflex/frame_event.cpp +1 -1
- data/.doc/ext/reflex/image_view.cpp +1 -1
- data/.doc/ext/reflex/key_event.cpp +74 -69
- data/.doc/ext/reflex/line_shape.cpp +1 -1
- data/.doc/ext/reflex/motion_event.cpp +1 -1
- data/.doc/ext/reflex/pointer.cpp +1 -1
- data/.doc/ext/reflex/pointer_event.cpp +1 -1
- data/.doc/ext/reflex/polygon_shape.cpp +1 -1
- data/.doc/ext/reflex/rect_shape.cpp +1 -1
- data/.doc/ext/reflex/reflex.cpp +58 -50
- data/.doc/ext/reflex/screen.cpp +1 -1
- data/.doc/ext/reflex/scroll_event.cpp +1 -1
- data/.doc/ext/reflex/selector.cpp +2 -2
- data/.doc/ext/reflex/shape.cpp +1 -1
- data/.doc/ext/reflex/style.cpp +1 -1
- data/.doc/ext/reflex/style_length.cpp +2 -2
- data/.doc/ext/reflex/timer.cpp +1 -1
- data/.doc/ext/reflex/timer_event.cpp +1 -1
- data/.doc/ext/reflex/update_event.cpp +1 -1
- data/.doc/ext/reflex/view.cpp +1 -1
- data/.doc/ext/reflex/wheel_event.cpp +1 -1
- data/.doc/ext/reflex/window.cpp +1 -1
- data/.github/workflows/release-gem.yml +1 -1
- data/.github/workflows/test.yml +3 -0
- data/ChangeLog.md +5 -0
- data/Rakefile +1 -1
- data/VERSION +1 -1
- data/ext/reflex/application.cpp +1 -1
- data/ext/reflex/capture_event.cpp +1 -1
- data/ext/reflex/contact_event.cpp +1 -1
- data/ext/reflex/defs.h +2 -0
- data/ext/reflex/draw_event.cpp +1 -1
- data/ext/reflex/ellipse_shape.cpp +1 -1
- data/ext/reflex/event.cpp +1 -1
- data/ext/reflex/extconf.rb +4 -4
- data/ext/reflex/filter.cpp +1 -1
- data/ext/reflex/focus_event.cpp +1 -1
- data/ext/reflex/frame_event.cpp +1 -1
- data/ext/reflex/image_view.cpp +1 -1
- data/ext/reflex/key_event.cpp +74 -69
- data/ext/reflex/line_shape.cpp +1 -1
- data/ext/reflex/motion_event.cpp +1 -1
- data/ext/reflex/pointer.cpp +1 -1
- data/ext/reflex/pointer_event.cpp +1 -1
- data/ext/reflex/polygon_shape.cpp +1 -1
- data/ext/reflex/rect_shape.cpp +1 -1
- data/ext/reflex/reflex.cpp +58 -50
- data/ext/reflex/screen.cpp +1 -1
- data/ext/reflex/scroll_event.cpp +1 -1
- data/ext/reflex/selector.cpp +2 -2
- data/ext/reflex/shape.cpp +1 -1
- data/ext/reflex/style.cpp +1 -1
- data/ext/reflex/style_length.cpp +2 -2
- data/ext/reflex/timer.cpp +1 -1
- data/ext/reflex/timer_event.cpp +1 -1
- data/ext/reflex/update_event.cpp +1 -1
- data/ext/reflex/view.cpp +1 -1
- data/ext/reflex/wheel_event.cpp +1 -1
- data/ext/reflex/window.cpp +1 -1
- data/include/reflex/defs.h +204 -187
- data/include/reflex/reflex.h +1 -0
- data/include/reflex/ruby/application.h +2 -2
- data/include/reflex/ruby/event.h +26 -26
- data/include/reflex/ruby/exception.h +3 -3
- data/include/reflex/ruby/filter.h +2 -2
- data/include/reflex/ruby/image_view.h +2 -2
- data/include/reflex/ruby/pointer.h +2 -2
- data/include/reflex/ruby/reflex.h +1 -1
- data/include/reflex/ruby/screen.h +2 -2
- data/include/reflex/ruby/selector.h +2 -2
- data/include/reflex/ruby/shape.h +10 -10
- data/include/reflex/ruby/style.h +4 -4
- data/include/reflex/ruby/timer.h +2 -2
- data/include/reflex/ruby/view.h +2 -2
- data/include/reflex/ruby/window.h +2 -2
- data/lib/reflex/extension.rb +4 -0
- data/reflex.gemspec +4 -4
- data/src/event.cpp +7 -3
- data/src/event.h +2 -0
- data/src/ios/event.mm +21 -27
- data/src/shape.cpp +2 -2
- data/src/view.cpp +1 -0
- data/src/win32/application.cpp +48 -35
- data/src/win32/device.cpp +18 -0
- data/src/win32/event.cpp +221 -0
- data/src/win32/event.h +50 -0
- data/src/win32/opengl.cpp +54 -27
- data/src/win32/opengl.h +15 -13
- data/src/win32/reflex.cpp +10 -16
- data/src/win32/screen.cpp +61 -0
- data/src/win32/screen.h +21 -0
- data/src/win32/window.cpp +445 -240
- data/src/window.cpp +1 -0
- data/test/test_window.rb +24 -21
- metadata +14 -11
- data/src/win32/defs.cpp +0 -303
- 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
|
-
|
9
|
-
: hwnd(NULL), hdc(NULL), hrc(NULL)
|
11
|
+
OpenGLContext::OpenGLContext ()
|
10
12
|
{
|
11
13
|
}
|
12
14
|
|
13
|
-
|
15
|
+
OpenGLContext::~OpenGLContext ()
|
14
16
|
{
|
15
17
|
fin();
|
16
18
|
}
|
17
19
|
|
18
|
-
|
19
|
-
|
20
|
+
void
|
21
|
+
OpenGLContext::init (HWND hwnd_)
|
20
22
|
{
|
21
|
-
if (!hwnd_
|
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)
|
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)
|
43
|
+
if (pf == 0)
|
44
|
+
system_error(__FILE__, __LINE__);
|
37
45
|
|
38
46
|
if (!SetPixelFormat(hdc, pf, &PFD))
|
39
|
-
|
47
|
+
system_error(__FILE__, __LINE__);
|
40
48
|
|
41
49
|
hrc = wglCreateContext(hdc);
|
42
|
-
if (!hrc)
|
50
|
+
if (!hrc)
|
51
|
+
system_error(__FILE__, __LINE__);
|
43
52
|
|
44
|
-
|
53
|
+
make_current();
|
45
54
|
}
|
46
55
|
|
47
|
-
|
48
|
-
|
56
|
+
void
|
57
|
+
OpenGLContext::fin ()
|
49
58
|
{
|
50
|
-
if (!*this) return
|
59
|
+
if (!*this) return;
|
51
60
|
|
52
61
|
if (hrc)
|
53
62
|
{
|
54
|
-
|
55
|
-
|
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
|
-
|
70
|
-
|
86
|
+
void
|
87
|
+
OpenGLContext::make_current ()
|
71
88
|
{
|
72
|
-
if (!*this) return
|
73
|
-
|
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
|
-
|
105
|
+
OpenGLContext::is_active () const
|
78
106
|
{
|
79
|
-
|
80
|
-
return SwapBuffers(hdc) != FALSE;
|
107
|
+
return *this && hrc == wglGetCurrentContext();
|
81
108
|
}
|
82
109
|
|
83
|
-
|
110
|
+
OpenGLContext::operator bool () const
|
84
111
|
{
|
85
112
|
return hwnd && hdc && hrc;
|
86
113
|
}
|
87
114
|
|
88
115
|
bool
|
89
|
-
|
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 <
|
8
|
-
#include <
|
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
|
15
|
+
class OpenGLContext
|
16
16
|
{
|
17
17
|
|
18
18
|
public:
|
19
19
|
|
20
|
-
|
20
|
+
OpenGLContext ();
|
21
21
|
|
22
|
-
~
|
22
|
+
~OpenGLContext ();
|
23
23
|
|
24
|
-
|
24
|
+
void init (HWND hwnd);
|
25
25
|
|
26
|
-
|
26
|
+
void fin ();
|
27
27
|
|
28
|
-
|
28
|
+
void make_current ();
|
29
29
|
|
30
|
-
|
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
|
-
};//
|
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
|
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
|
14
|
+
static bool initialized = false;
|
15
15
|
|
16
16
|
}// global
|
17
17
|
|
18
18
|
|
19
|
-
|
20
|
-
initialized ()
|
21
|
-
{
|
22
|
-
return global::init;
|
23
|
-
}
|
24
|
-
|
25
|
-
bool
|
19
|
+
void
|
26
20
|
init ()
|
27
21
|
{
|
28
|
-
if (global::
|
22
|
+
if (global::initialized)
|
23
|
+
reflex_error(__FILE__, __LINE__, "already initialized.");
|
29
24
|
|
30
|
-
global::
|
31
|
-
return true;
|
25
|
+
global::initialized = true;
|
32
26
|
}
|
33
27
|
|
34
|
-
|
28
|
+
void
|
35
29
|
fin ()
|
36
30
|
{
|
37
|
-
if (!global::
|
31
|
+
if (!global::initialized)
|
32
|
+
reflex_error(__FILE__, __LINE__, "not initialized.");
|
38
33
|
|
39
|
-
global::
|
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
|
data/src/win32/screen.h
ADDED
@@ -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
|