reflexion 0.5.3 → 0.7.0
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 +56 -7
- data/.doc/ext/reflex/capture_event.cpp +1 -1
- data/.doc/ext/reflex/chase_constraint.cpp +84 -0
- data/.doc/ext/reflex/clipboard.cpp +65 -0
- data/.doc/ext/reflex/color_event.cpp +76 -0
- data/.doc/ext/reflex/color_picker.cpp +113 -0
- data/.doc/ext/reflex/constraint.cpp +135 -0
- data/.doc/ext/reflex/contact_event.cpp +1 -1
- data/.doc/ext/reflex/control_change_event.cpp +1 -1
- data/.doc/ext/reflex/device.cpp +1 -1
- data/.doc/ext/reflex/device_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/file_dialog.cpp +181 -0
- data/.doc/ext/reflex/file_event.cpp +103 -0
- 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/gamepad.cpp +48 -0
- data/.doc/ext/reflex/image_view.cpp +1 -1
- data/.doc/ext/reflex/key_event.cpp +1 -274
- data/.doc/ext/reflex/line_shape.cpp +1 -1
- data/.doc/ext/reflex/link_constraint.cpp +178 -0
- data/.doc/ext/reflex/menu.cpp +303 -0
- data/.doc/ext/reflex/midi.cpp +9 -2
- data/.doc/ext/reflex/midi_event.cpp +1 -1
- data/.doc/ext/reflex/motion_event.cpp +1 -1
- data/.doc/ext/reflex/native.cpp +40 -10
- data/.doc/ext/reflex/note_event.cpp +1 -1
- data/.doc/ext/reflex/pin.cpp +156 -0
- data/.doc/ext/reflex/pointer.cpp +3 -1
- data/.doc/ext/reflex/pointer_event.cpp +3 -3
- data/.doc/ext/reflex/polygon_shape.cpp +1 -1
- data/.doc/ext/reflex/rect_shape.cpp +1 -1
- data/.doc/ext/reflex/reflex.cpp +606 -237
- data/.doc/ext/reflex/screen.cpp +27 -1
- data/.doc/ext/reflex/scroll_event.cpp +1 -1
- data/.doc/ext/reflex/selector.cpp +5 -5
- data/.doc/ext/reflex/shape.cpp +1 -1
- data/.doc/ext/reflex/snap_constraint.cpp +125 -0
- data/.doc/ext/reflex/style.cpp +1 -1
- data/.doc/ext/reflex/style_length.cpp +4 -3
- data/.doc/ext/reflex/text_event.cpp +104 -0
- 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 +206 -79
- data/.doc/ext/reflex/wheel_constraint.cpp +142 -0
- data/.doc/ext/reflex/wheel_event.cpp +1 -1
- data/.doc/ext/reflex/window.cpp +282 -31
- data/.github/workflows/release-gem.yml +2 -40
- data/.github/workflows/tag.yml +5 -28
- data/.github/workflows/test.yml +1 -28
- data/ChangeLog.md +79 -0
- data/Gemfile.lock +13 -8
- data/README.md +1 -0
- data/Rakefile +13 -2
- data/Reflex.podspec +2 -2
- data/VERSION +1 -1
- data/ext/reflex/application.cpp +62 -7
- data/ext/reflex/capture_event.cpp +1 -1
- data/ext/reflex/chase_constraint.cpp +89 -0
- data/ext/reflex/clipboard.cpp +69 -0
- data/ext/reflex/color_event.cpp +80 -0
- data/ext/reflex/color_picker.cpp +121 -0
- data/ext/reflex/constraint.cpp +146 -0
- data/ext/reflex/contact_event.cpp +1 -1
- data/ext/reflex/control_change_event.cpp +1 -1
- data/ext/reflex/device.cpp +1 -1
- data/ext/reflex/device_event.cpp +1 -1
- 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 -2
- data/ext/reflex/file_dialog.cpp +194 -0
- data/ext/reflex/file_event.cpp +108 -0
- 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/gamepad.cpp +50 -0
- data/ext/reflex/image_view.cpp +1 -1
- data/ext/reflex/key_event.cpp +1 -275
- data/ext/reflex/line_shape.cpp +1 -1
- data/ext/reflex/link_constraint.cpp +194 -0
- data/ext/reflex/menu.cpp +331 -0
- data/ext/reflex/midi.cpp +11 -3
- data/ext/reflex/midi_event.cpp +1 -1
- data/ext/reflex/motion_event.cpp +1 -1
- data/ext/reflex/native.cpp +40 -10
- data/ext/reflex/note_event.cpp +1 -1
- data/ext/reflex/pin.cpp +165 -0
- data/ext/reflex/pointer.cpp +3 -1
- data/ext/reflex/pointer_event.cpp +3 -3
- data/ext/reflex/polygon_shape.cpp +1 -1
- data/ext/reflex/rect_shape.cpp +1 -1
- data/ext/reflex/reflex.cpp +608 -237
- data/ext/reflex/screen.cpp +31 -2
- data/ext/reflex/scroll_event.cpp +1 -1
- data/ext/reflex/selector.cpp +5 -5
- data/ext/reflex/selector.h +10 -10
- data/ext/reflex/shape.cpp +1 -1
- data/ext/reflex/snap_constraint.cpp +135 -0
- data/ext/reflex/style.cpp +1 -1
- data/ext/reflex/style_length.cpp +4 -3
- data/ext/reflex/text_event.cpp +111 -0
- 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 +236 -96
- data/ext/reflex/wheel_constraint.cpp +154 -0
- data/ext/reflex/wheel_event.cpp +1 -1
- data/ext/reflex/window.cpp +318 -40
- data/include/reflex/application.h +19 -0
- data/include/reflex/clipboard.h +53 -0
- data/include/reflex/color_picker.h +65 -0
- data/include/reflex/constraint.h +275 -0
- data/include/reflex/defs.h +204 -195
- data/include/reflex/event.h +180 -88
- data/include/reflex/file_dialog.h +73 -0
- data/include/reflex/gamepad.h +3 -0
- data/include/reflex/menu.h +120 -0
- data/include/reflex/midi.h +3 -0
- data/include/reflex/pin.h +68 -0
- data/include/reflex/pointer.h +4 -0
- data/include/reflex/reflex.h +2 -0
- data/include/reflex/ruby/application.h +6 -1
- data/include/reflex/ruby/clipboard.h +23 -0
- data/include/reflex/ruby/color_picker.h +89 -0
- data/include/reflex/ruby/constraint.h +94 -0
- data/include/reflex/ruby/event.h +62 -29
- data/include/reflex/ruby/file_dialog.h +89 -0
- data/include/reflex/ruby/gamepad.h +46 -0
- data/include/reflex/ruby/menu.h +103 -0
- data/include/reflex/ruby/pin.h +40 -0
- data/include/reflex/ruby/reflex.h +3 -0
- data/include/reflex/ruby/view.h +123 -39
- data/include/reflex/ruby/window.h +96 -19
- data/include/reflex/ruby.h +3 -0
- data/include/reflex/screen.h +11 -2
- data/include/reflex/view.h +66 -27
- data/include/reflex/window.h +57 -12
- data/include/reflex.h +8 -0
- data/lib/reflex/application.rb +5 -5
- data/lib/reflex/autoinit.rb +3 -1
- data/lib/reflex/button.rb +3 -3
- data/lib/reflex/chase_constraint.rb +15 -0
- data/lib/reflex/clipboard.rb +19 -0
- data/lib/reflex/color_event.rb +16 -0
- data/lib/reflex/color_picker.rb +45 -0
- data/lib/reflex/constraint.rb +29 -0
- data/lib/reflex/control_change_event.rb +17 -0
- data/lib/reflex/extension.rb +1 -1
- data/lib/reflex/file_dialog.rb +70 -0
- data/lib/reflex/file_event.rb +37 -0
- data/lib/reflex/helper.rb +79 -0
- data/lib/reflex/key_event.rb +14 -14
- data/lib/reflex/link_constraint.rb +31 -0
- data/lib/reflex/menu.rb +92 -0
- data/lib/reflex/model.rb +19 -19
- data/lib/reflex/note_event.rb +1 -1
- data/lib/reflex/pin.rb +39 -0
- data/lib/reflex/pointer.rb +30 -1
- data/lib/reflex/pointer_event.rb +13 -2
- data/lib/reflex/reflex.rb +5 -0
- data/lib/reflex/shape.rb +14 -14
- data/lib/reflex/snap_constraint.rb +28 -0
- data/lib/reflex/style.rb +16 -16
- data/lib/reflex/text_event.rb +40 -0
- data/lib/reflex/timer.rb +3 -3
- data/lib/reflex/view.rb +85 -18
- data/lib/reflex/wheel_constraint.rb +28 -0
- data/lib/reflex/wheel_event.rb +19 -1
- data/lib/reflex/window.rb +25 -13
- data/lib/reflex.rb +23 -8
- data/pod.rake +1 -1
- data/reflex.gemspec +4 -4
- data/samples/constraint.rb +152 -0
- data/samples/ime.rb +100 -0
- data/samples/ios/hello/hello.xcodeproj/project.pbxproj +236 -224
- data/samples/menu.rb +32 -0
- data/samples/model.rb +3 -3
- data/samples/test/alert.rb +93 -0
- data/samples/test/always_on.rb +76 -0
- data/samples/test/app_background.rb +51 -0
- data/samples/test/boundary.rb +75 -0
- data/samples/test/callback_exception.rb +101 -0
- data/samples/test/cancel.rb +53 -0
- data/samples/test/color_picker.rb +63 -0
- data/samples/test/file_dialog.rb +102 -0
- data/samples/window_style.rb +156 -0
- data/src/application.cpp +180 -20
- data/src/application.h +95 -5
- data/src/clipboard.cpp +81 -0
- data/src/color_picker.cpp +113 -0
- data/src/color_picker.h +36 -0
- data/src/constraint.cpp +1662 -0
- data/src/constraint.h +64 -0
- data/src/event.cpp +416 -252
- data/src/event.h +13 -2
- data/src/file_dialog.cpp +163 -0
- data/src/file_dialog.h +52 -0
- data/src/gamepad.cpp +42 -5
- data/src/gamepad.h +4 -0
- data/src/ios/app_delegate.mm +5 -3
- data/src/ios/application.mm +29 -0
- data/src/ios/clipboard.mm +44 -0
- data/src/ios/color_picker.mm +19 -0
- data/src/ios/event.h +6 -2
- data/src/ios/event.mm +31 -12
- data/src/ios/file_dialog.mm +21 -0
- data/src/ios/gamepad.mm +4 -4
- data/src/ios/menu.mm +41 -0
- data/src/ios/reflex.mm +8 -0
- data/src/ios/screen.mm +26 -0
- data/src/ios/view_controller.mm +47 -42
- data/src/ios/window.mm +44 -9
- data/src/menu.cpp +387 -0
- data/src/menu.h +81 -0
- data/src/midi.cpp +61 -31
- data/src/osx/app_delegate.h +4 -0
- data/src/osx/app_delegate.mm +168 -139
- data/src/osx/application.mm +103 -5
- data/src/osx/clipboard.mm +45 -0
- data/src/osx/color_picker.mm +112 -0
- data/src/osx/event.h +10 -0
- data/src/osx/event.mm +114 -30
- data/src/osx/file_dialog.mm +168 -0
- data/src/osx/gamepad.mm +2 -2
- data/src/osx/gamepad_hid.mm +1 -1
- data/src/osx/menu.h +25 -0
- data/src/osx/menu.mm +516 -0
- data/src/osx/native_window.h +16 -2
- data/src/osx/native_window.mm +141 -57
- data/src/osx/opengl_view.h +2 -1
- data/src/osx/opengl_view.mm +229 -37
- data/src/osx/reflex.mm +38 -0
- data/src/osx/screen.mm +36 -0
- data/src/osx/window.mm +117 -24
- data/src/pin.cpp +137 -0
- data/src/pointer.cpp +36 -16
- data/src/pointer.h +10 -0
- data/src/rays.h +46 -0
- data/src/sdl/application.cpp +73 -8
- data/src/sdl/clipboard.cpp +39 -0
- data/src/sdl/color_picker.cpp +18 -0
- data/src/sdl/event.cpp +44 -6
- data/src/sdl/event.h +18 -3
- data/src/sdl/file_dialog.cpp +20 -0
- data/src/sdl/gamepad.cpp +3 -7
- data/src/sdl/menu.cpp +40 -0
- data/src/sdl/reflex.cpp +20 -0
- data/src/sdl/screen.cpp +36 -0
- data/src/sdl/window.cpp +168 -37
- data/src/shape.cpp +15 -10
- data/src/view.cpp +583 -233
- data/src/view.h +22 -4
- data/src/vk.h +416 -0
- data/src/win32/application.cpp +167 -12
- data/src/win32/application.h +20 -0
- data/src/win32/clipboard.cpp +210 -0
- data/src/win32/color_picker.cpp +82 -0
- data/src/win32/event.cpp +123 -11
- data/src/win32/event.h +22 -3
- data/src/win32/file_dialog.cpp +226 -0
- data/src/win32/gamepad.cpp +9 -2
- data/src/win32/menu.cpp +490 -0
- data/src/win32/menu.h +35 -0
- data/src/win32/opengl.cpp +2 -9
- data/src/win32/reflex.cpp +44 -3
- data/src/win32/screen.cpp +164 -3
- data/src/win32/screen.h +8 -0
- data/src/win32/tray.cpp +191 -0
- data/src/win32/tray.h +22 -0
- data/src/win32/vk.cpp +11 -0
- data/src/win32/window.cpp +858 -135
- data/src/win32/window.h +9 -0
- data/src/window.cpp +929 -183
- data/src/window.h +77 -33
- data/src/world.cpp +86 -15
- data/src/world.h +9 -2
- data/test/helper.rb +24 -0
- data/test/test_application.rb +101 -1
- data/test/test_chase_constraint.rb +122 -0
- data/test/test_clipboard.rb +54 -0
- data/test/test_color_event.rb +36 -0
- data/test/test_color_picker.rb +62 -0
- data/test/test_constraint.rb +184 -0
- data/test/test_event.rb +1 -1
- data/test/test_file_dialog.rb +48 -0
- data/test/test_file_event.rb +43 -0
- data/test/test_has_text_preedit.rb +54 -0
- data/test/test_key_event.rb +23 -2
- data/test/test_link_constraint.rb +237 -0
- data/test/test_menu.rb +237 -0
- data/test/test_pin.rb +65 -0
- data/test/test_pointer.rb +50 -26
- data/test/test_pointer_event.rb +25 -10
- data/test/test_reflex.rb +36 -0
- data/test/test_screen.rb +24 -2
- data/test/test_snap_constraint.rb +140 -0
- data/test/test_text_event.rb +54 -0
- data/test/test_view.rb +152 -25
- data/test/test_wheel_constraint.rb +125 -0
- data/test/test_wheel_event.rb +24 -10
- data/test/test_window.rb +205 -43
- metadata +154 -10
- data/.github/workflows/utils.rb +0 -127
data/src/sdl/application.cpp
CHANGED
|
@@ -5,6 +5,11 @@
|
|
|
5
5
|
#ifdef WASM
|
|
6
6
|
#include <emscripten.h>
|
|
7
7
|
#endif
|
|
8
|
+
#ifdef LINUX
|
|
9
|
+
#include <limits.h>
|
|
10
|
+
#include <string.h>
|
|
11
|
+
#include <unistd.h>
|
|
12
|
+
#endif
|
|
8
13
|
#include <xot/time.h>
|
|
9
14
|
#include "reflex/exception.h"
|
|
10
15
|
#include "reflex/debug.h"
|
|
@@ -41,6 +46,43 @@ namespace Reflex
|
|
|
41
46
|
return new ApplicationData();
|
|
42
47
|
}
|
|
43
48
|
|
|
49
|
+
String
|
|
50
|
+
Application_get_default_name ()
|
|
51
|
+
{
|
|
52
|
+
#ifdef LINUX
|
|
53
|
+
char path[PATH_MAX];
|
|
54
|
+
ssize_t len = readlink("/proc/self/exe", path, sizeof(path) - 1);
|
|
55
|
+
if (len > 0)
|
|
56
|
+
{
|
|
57
|
+
path[len] = '\0';
|
|
58
|
+
char* slash = strrchr(path, '/');
|
|
59
|
+
return slash ? slash + 1 : path;
|
|
60
|
+
}
|
|
61
|
+
#endif
|
|
62
|
+
return "";
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
void
|
|
66
|
+
Application_stop (Application* app)
|
|
67
|
+
{
|
|
68
|
+
get_data(app)->quit = true;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
void
|
|
72
|
+
Application_set_menu (Application* app, Menu* menu)
|
|
73
|
+
{
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
void
|
|
77
|
+
Application_set_background (Application* app, bool state)
|
|
78
|
+
{
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
void
|
|
82
|
+
Application_set_background_menu (Application* app, Menu* menu)
|
|
83
|
+
{
|
|
84
|
+
}
|
|
85
|
+
|
|
44
86
|
|
|
45
87
|
static bool
|
|
46
88
|
dispatch_window_event (const SDL_Event& event)
|
|
@@ -60,11 +102,18 @@ namespace Reflex
|
|
|
60
102
|
SDL_Event event;
|
|
61
103
|
while (SDL_PollEvent(&event))
|
|
62
104
|
{
|
|
63
|
-
|
|
64
|
-
|
|
105
|
+
bool dispatched = dispatch_window_event(event);
|
|
106
|
+
|
|
107
|
+
#if SDL_VERSION_ATLEAST(2, 0, 22)
|
|
108
|
+
// the text of an extended composition event is handed over to
|
|
109
|
+
// whoever takes the event, so it is freed here rather than in the
|
|
110
|
+
// window that may or may not have been found for it
|
|
111
|
+
if (event.type == SDL_TEXTEDITING_EXT)
|
|
112
|
+
SDL_free(event.editExt.text);
|
|
113
|
+
#endif
|
|
65
114
|
|
|
66
|
-
if (event.type == SDL_QUIT)
|
|
67
|
-
app
|
|
115
|
+
if (!dispatched && event.type == SDL_QUIT)
|
|
116
|
+
Application_call_quit(app);
|
|
68
117
|
}
|
|
69
118
|
}
|
|
70
119
|
|
|
@@ -110,7 +159,10 @@ namespace Reflex
|
|
|
110
159
|
dispatch_events(app);
|
|
111
160
|
|
|
112
161
|
if (get_data(app)->quit)
|
|
162
|
+
{
|
|
113
163
|
emscripten_cancel_main_loop();
|
|
164
|
+
Application_cleanup(app);
|
|
165
|
+
}
|
|
114
166
|
else
|
|
115
167
|
update_all_windows(app);
|
|
116
168
|
}
|
|
@@ -119,13 +171,26 @@ namespace Reflex
|
|
|
119
171
|
void
|
|
120
172
|
Application::start ()
|
|
121
173
|
{
|
|
174
|
+
get_data(this)->quit = false;
|
|
175
|
+
self->started = false;
|
|
176
|
+
self->quitting = false;
|
|
177
|
+
self->running = true;
|
|
178
|
+
|
|
122
179
|
Event e;
|
|
123
|
-
|
|
180
|
+
Application_call_start_event(this, &e);
|
|
124
181
|
|
|
125
182
|
#ifdef WASM
|
|
126
183
|
emscripten_set_main_loop_arg(emscripten_main_loop, this, 0, true);
|
|
127
184
|
#else
|
|
128
|
-
|
|
185
|
+
// guarded here too, since rays can throw while drawing
|
|
186
|
+
Application_guard([&]()
|
|
187
|
+
{
|
|
188
|
+
main_loop(this);
|
|
189
|
+
});
|
|
190
|
+
self->running = false;
|
|
191
|
+
|
|
192
|
+
Application_cleanup(this);
|
|
193
|
+
Application_throw_exception(this);
|
|
129
194
|
#endif
|
|
130
195
|
}
|
|
131
196
|
|
|
@@ -133,10 +198,10 @@ namespace Reflex
|
|
|
133
198
|
Application::quit ()
|
|
134
199
|
{
|
|
135
200
|
Event e;
|
|
136
|
-
|
|
201
|
+
Application_call_quit_event(this, &e);
|
|
137
202
|
if (e.is_blocked()) return;
|
|
138
203
|
|
|
139
|
-
|
|
204
|
+
Application_stop(this);
|
|
140
205
|
}
|
|
141
206
|
|
|
142
207
|
void
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
#include "reflex/clipboard.h"
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
#include <SDL.h>
|
|
5
|
+
#include "reflex/exception.h"
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
namespace Reflex
|
|
9
|
+
{
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
void
|
|
13
|
+
set_clipboard (const Clipboard& clipboard)
|
|
14
|
+
{
|
|
15
|
+
const char* text = clipboard.text();
|
|
16
|
+
if (SDL_SetClipboardText(text ? text : "") != 0)
|
|
17
|
+
reflex_error(__FILE__, __LINE__, SDL_GetError());
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
Clipboard
|
|
21
|
+
get_clipboard ()
|
|
22
|
+
{
|
|
23
|
+
Clipboard clipboard;
|
|
24
|
+
|
|
25
|
+
if (SDL_HasClipboardText() == SDL_TRUE)
|
|
26
|
+
{
|
|
27
|
+
char* text = SDL_GetClipboardText();
|
|
28
|
+
if (text)
|
|
29
|
+
{
|
|
30
|
+
clipboard.set_text(text);
|
|
31
|
+
SDL_free(text);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return clipboard;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
}// Reflex
|
data/src/sdl/event.cpp
CHANGED
|
@@ -70,6 +70,21 @@ namespace Reflex
|
|
|
70
70
|
}
|
|
71
71
|
|
|
72
72
|
|
|
73
|
+
NativeTextEvent::NativeTextEvent (
|
|
74
|
+
const char* text, int selection_offset, int selection_size)
|
|
75
|
+
: TextEvent(
|
|
76
|
+
PREEDIT, text, selection_offset,
|
|
77
|
+
// a size below zero is how sdl says nothing is selected
|
|
78
|
+
selection_size < 0 ? 0 : selection_size)
|
|
79
|
+
{
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
NativeTextEvent::NativeTextEvent (const SDL_TextInputEvent& e)
|
|
83
|
+
: TextEvent(COMMIT, e.text)
|
|
84
|
+
{
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
|
|
73
88
|
static uint
|
|
74
89
|
get_pointer_type (Uint8 button)
|
|
75
90
|
{
|
|
@@ -94,7 +109,7 @@ namespace Reflex
|
|
|
94
109
|
}
|
|
95
110
|
|
|
96
111
|
NativePointerEvent::NativePointerEvent (
|
|
97
|
-
const SDL_MouseButtonEvent& e,
|
|
112
|
+
SDL_Window* window, const SDL_MouseButtonEvent& e, Pointer::Action action)
|
|
98
113
|
{
|
|
99
114
|
PointerEvent_add_pointer(this, Pointer(
|
|
100
115
|
0,
|
|
@@ -108,7 +123,7 @@ namespace Reflex
|
|
|
108
123
|
}
|
|
109
124
|
|
|
110
125
|
NativePointerEvent::NativePointerEvent (
|
|
111
|
-
const SDL_MouseMotionEvent& e
|
|
126
|
+
SDL_Window* window, const SDL_MouseMotionEvent& e)
|
|
112
127
|
{
|
|
113
128
|
PointerEvent_add_pointer(this, Pointer(
|
|
114
129
|
0,
|
|
@@ -122,7 +137,7 @@ namespace Reflex
|
|
|
122
137
|
}
|
|
123
138
|
|
|
124
139
|
NativePointerEvent::NativePointerEvent (
|
|
125
|
-
const SDL_TouchFingerEvent& e,
|
|
140
|
+
SDL_Window* window, const SDL_TouchFingerEvent& e, Pointer::Action action)
|
|
126
141
|
{
|
|
127
142
|
uint mods = get_modifiers(SDL_GetModState());
|
|
128
143
|
double t = time();
|
|
@@ -157,14 +172,37 @@ namespace Reflex
|
|
|
157
172
|
}
|
|
158
173
|
}
|
|
159
174
|
|
|
175
|
+
NativePointerEvent::NativePointerEvent (
|
|
176
|
+
SDL_Window* window, Pointer::Action action)
|
|
177
|
+
{
|
|
178
|
+
int x = 0, y = 0;
|
|
179
|
+
Uint32 state = SDL_GetMouseState(&x, &y);
|
|
180
|
+
|
|
181
|
+
PointerEvent_add_pointer(this, Pointer(
|
|
182
|
+
0,
|
|
183
|
+
get_current_pointer_type(state),
|
|
184
|
+
action,
|
|
185
|
+
Point(x, y),
|
|
186
|
+
get_modifiers(SDL_GetModState()),
|
|
187
|
+
0,
|
|
188
|
+
false,
|
|
189
|
+
time()));
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
static coord
|
|
194
|
+
to_wheel_pixels (const SDL_MouseWheelEvent& e, float delta)
|
|
195
|
+
{
|
|
196
|
+
float scale = WHEEL_PIXELS_PER_NOTCH;
|
|
197
|
+
if (e.direction == SDL_MOUSEWHEEL_FLIPPED) scale = -scale;
|
|
198
|
+
return delta * scale;
|
|
199
|
+
}
|
|
160
200
|
|
|
161
201
|
NativeWheelEvent::NativeWheelEvent (
|
|
162
202
|
const SDL_MouseWheelEvent& e, SDL_Window* window)
|
|
163
203
|
: WheelEvent(
|
|
164
204
|
0, 0, 0,
|
|
165
|
-
e
|
|
166
|
-
e.direction == SDL_MOUSEWHEEL_FLIPPED ? -e.preciseY : e.preciseY,
|
|
167
|
-
0,
|
|
205
|
+
to_wheel_pixels(e, e.preciseX), to_wheel_pixels(e, -e.preciseY), 0,
|
|
168
206
|
get_modifiers(SDL_GetModState()))
|
|
169
207
|
{
|
|
170
208
|
int mx, my;
|
data/src/sdl/event.h
CHANGED
|
@@ -22,22 +22,37 @@ namespace Reflex
|
|
|
22
22
|
};// NativeKeyEvent
|
|
23
23
|
|
|
24
24
|
|
|
25
|
+
class NativeTextEvent : public TextEvent
|
|
26
|
+
{
|
|
27
|
+
|
|
28
|
+
public:
|
|
29
|
+
|
|
30
|
+
NativeTextEvent (const char* text, int selection_offset, int selection_size);
|
|
31
|
+
|
|
32
|
+
NativeTextEvent (const SDL_TextInputEvent& event);
|
|
33
|
+
|
|
34
|
+
};// NativeTextEvent
|
|
35
|
+
|
|
36
|
+
|
|
25
37
|
class NativePointerEvent : public PointerEvent
|
|
26
38
|
{
|
|
27
39
|
|
|
28
40
|
public:
|
|
29
41
|
|
|
30
42
|
NativePointerEvent (
|
|
31
|
-
const SDL_MouseButtonEvent& event,
|
|
43
|
+
SDL_Window* window, const SDL_MouseButtonEvent& event,
|
|
32
44
|
Pointer::Action action);
|
|
33
45
|
|
|
34
46
|
NativePointerEvent (
|
|
35
|
-
const SDL_MouseMotionEvent& event
|
|
47
|
+
SDL_Window* window, const SDL_MouseMotionEvent& event);
|
|
36
48
|
|
|
37
49
|
NativePointerEvent (
|
|
38
|
-
const SDL_TouchFingerEvent& event,
|
|
50
|
+
SDL_Window* window, const SDL_TouchFingerEvent& event,
|
|
39
51
|
Pointer::Action action);
|
|
40
52
|
|
|
53
|
+
NativePointerEvent (
|
|
54
|
+
SDL_Window* window, Pointer::Action action);
|
|
55
|
+
|
|
41
56
|
};// NativePointerEvent
|
|
42
57
|
|
|
43
58
|
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
#include "../file_dialog.h"
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
#include "reflex/exception.h"
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
namespace Reflex
|
|
8
|
+
{
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
void
|
|
12
|
+
FileDialog_show (
|
|
13
|
+
FileDialog* dialog, FileDialog::Data::Mode mode,
|
|
14
|
+
const char* dir, const char* name)
|
|
15
|
+
{
|
|
16
|
+
not_implemented_error(__FILE__, __LINE__);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
}// Reflex
|
data/src/sdl/gamepad.cpp
CHANGED
|
@@ -9,17 +9,13 @@ namespace Reflex
|
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
void
|
|
12
|
-
|
|
12
|
+
Gamepad_init_native (Application* app)
|
|
13
13
|
{
|
|
14
|
+
not_implemented_error(__FILE__, __LINE__);
|
|
14
15
|
}
|
|
15
16
|
|
|
16
17
|
void
|
|
17
|
-
|
|
18
|
-
{
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
void
|
|
22
|
-
Gamepad_poll ()
|
|
18
|
+
Gamepad_fin_native (Application* app)
|
|
23
19
|
{
|
|
24
20
|
}
|
|
25
21
|
|
data/src/sdl/menu.cpp
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
#include "../menu.h"
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
namespace Reflex
|
|
5
|
+
{
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
Menu::Data*
|
|
9
|
+
Menu_create_data ()
|
|
10
|
+
{
|
|
11
|
+
return new Menu::Data();
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
void
|
|
15
|
+
Menu_validate_shortcut_modifiers (uint modifiers)
|
|
16
|
+
{
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
void
|
|
20
|
+
Menu_update (Menu* menu)
|
|
21
|
+
{
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
void
|
|
25
|
+
Menu_popup (Menu* menu, View* view, coord x, coord y)
|
|
26
|
+
{
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
void
|
|
30
|
+
Menu_child_added (Menu* parent, Menu* child, int index)
|
|
31
|
+
{
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
void
|
|
35
|
+
Menu_child_removed (Menu* parent, Menu* child)
|
|
36
|
+
{
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
}// Reflex
|
data/src/sdl/reflex.cpp
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
#include <SDL.h>
|
|
5
5
|
#include "reflex/exception.h"
|
|
6
|
+
#include "../vk.h"
|
|
6
7
|
|
|
7
8
|
|
|
8
9
|
namespace Reflex
|
|
@@ -23,6 +24,13 @@ namespace Reflex
|
|
|
23
24
|
if (global::initialized)
|
|
24
25
|
reflex_error(__FILE__, __LINE__, "already initialized.");
|
|
25
26
|
|
|
27
|
+
#if SDL_VERSION_ATLEAST(2, 0, 22)
|
|
28
|
+
// without this, sdl cuts a composition longer than 32 bytes into
|
|
29
|
+
// pieces and reuses the offset field to say where each piece goes,
|
|
30
|
+
// which leaves no way to tell a composition from its selection
|
|
31
|
+
SDL_SetHint(SDL_HINT_IME_SUPPORT_EXTENDED_TEXT, "1");
|
|
32
|
+
#endif
|
|
33
|
+
|
|
26
34
|
global::initialized = true;
|
|
27
35
|
}
|
|
28
36
|
|
|
@@ -35,5 +43,17 @@ namespace Reflex
|
|
|
35
43
|
global::initialized = false;
|
|
36
44
|
}
|
|
37
45
|
|
|
46
|
+
void
|
|
47
|
+
alert (const char* message, const char* title)
|
|
48
|
+
{
|
|
49
|
+
if (!message)
|
|
50
|
+
argument_error(__FILE__, __LINE__);
|
|
51
|
+
|
|
52
|
+
int ret = SDL_ShowSimpleMessageBox(
|
|
53
|
+
SDL_MESSAGEBOX_INFORMATION, title ? title : "", message, NULL);
|
|
54
|
+
if (ret < 0)
|
|
55
|
+
reflex_error(__FILE__, __LINE__, SDL_GetError());
|
|
56
|
+
}
|
|
57
|
+
|
|
38
58
|
|
|
39
59
|
}// Reflex
|
data/src/sdl/screen.cpp
CHANGED
|
@@ -35,6 +35,16 @@ namespace Reflex
|
|
|
35
35
|
{
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
+
String
|
|
39
|
+
Screen::name () const
|
|
40
|
+
{
|
|
41
|
+
if (!*this)
|
|
42
|
+
invalid_state_error(__FILE__, __LINE__);
|
|
43
|
+
|
|
44
|
+
const char* name = SDL_GetDisplayName(self->display_index);
|
|
45
|
+
return name ? name : "";
|
|
46
|
+
}
|
|
47
|
+
|
|
38
48
|
Bounds
|
|
39
49
|
Screen::frame () const
|
|
40
50
|
{
|
|
@@ -48,6 +58,15 @@ namespace Reflex
|
|
|
48
58
|
return Bounds(rect.x, rect.y, rect.w, rect.h);
|
|
49
59
|
}
|
|
50
60
|
|
|
61
|
+
float
|
|
62
|
+
Screen::pixel_density () const
|
|
63
|
+
{
|
|
64
|
+
if (!*this)
|
|
65
|
+
invalid_state_error(__FILE__, __LINE__);
|
|
66
|
+
|
|
67
|
+
return 1;
|
|
68
|
+
}
|
|
69
|
+
|
|
51
70
|
Screen::operator bool () const
|
|
52
71
|
{
|
|
53
72
|
return self->display_index >= 0;
|
|
@@ -59,5 +78,22 @@ namespace Reflex
|
|
|
59
78
|
return !operator bool();
|
|
60
79
|
}
|
|
61
80
|
|
|
81
|
+
Screen::List
|
|
82
|
+
Screen::all ()
|
|
83
|
+
{
|
|
84
|
+
int count = SDL_GetNumVideoDisplays();
|
|
85
|
+
if (count < 0)
|
|
86
|
+
reflex_error(__FILE__, __LINE__, SDL_GetError());
|
|
87
|
+
|
|
88
|
+
List list;
|
|
89
|
+
for (int i = 0; i < count; ++i)
|
|
90
|
+
{
|
|
91
|
+
Screen s;
|
|
92
|
+
Screen_initialize(&s, i);
|
|
93
|
+
list.emplace_back(s);
|
|
94
|
+
}
|
|
95
|
+
return list;
|
|
96
|
+
}
|
|
97
|
+
|
|
62
98
|
|
|
63
99
|
}// Reflex
|