reflexion 0.6.0 → 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 +37 -6
- data/.doc/ext/reflex/capture_event.cpp +1 -1
- data/.doc/ext/reflex/chase_constraint.cpp +1 -1
- data/.doc/ext/reflex/clipboard.cpp +1 -1
- data/.doc/ext/reflex/color_event.cpp +76 -0
- data/.doc/ext/reflex/color_picker.cpp +113 -0
- data/.doc/ext/reflex/constraint.cpp +1 -1
- 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 +1 -1
- data/.doc/ext/reflex/menu.cpp +6 -5
- 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 +18 -6
- data/.doc/ext/reflex/note_event.cpp +1 -1
- data/.doc/ext/reflex/pin.cpp +1 -1
- data/.doc/ext/reflex/pointer.cpp +1 -1
- data/.doc/ext/reflex/pointer_event.cpp +2 -2
- data/.doc/ext/reflex/polygon_shape.cpp +1 -1
- data/.doc/ext/reflex/rect_shape.cpp +1 -1
- data/.doc/ext/reflex/reflex.cpp +566 -232
- data/.doc/ext/reflex/screen.cpp +27 -1
- data/.doc/ext/reflex/scroll_event.cpp +1 -1
- data/.doc/ext/reflex/selector.cpp +1 -1
- data/.doc/ext/reflex/shape.cpp +1 -1
- data/.doc/ext/reflex/snap_constraint.cpp +1 -1
- data/.doc/ext/reflex/style.cpp +1 -1
- data/.doc/ext/reflex/style_length.cpp +1 -1
- 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 +110 -56
- data/.doc/ext/reflex/wheel_constraint.cpp +1 -1
- data/.doc/ext/reflex/wheel_event.cpp +1 -1
- data/.doc/ext/reflex/window.cpp +226 -17
- data/.github/workflows/release-gem.yml +2 -49
- data/.github/workflows/tag.yml +5 -28
- data/.github/workflows/test.yml +1 -37
- data/ChangeLog.md +54 -0
- data/Gemfile.lock +13 -8
- data/Rakefile +13 -2
- data/Reflex.podspec +2 -2
- data/VERSION +1 -1
- data/ext/reflex/application.cpp +41 -6
- data/ext/reflex/capture_event.cpp +1 -1
- data/ext/reflex/chase_constraint.cpp +1 -1
- data/ext/reflex/clipboard.cpp +1 -1
- data/ext/reflex/color_event.cpp +80 -0
- data/ext/reflex/color_picker.cpp +121 -0
- data/ext/reflex/constraint.cpp +1 -1
- 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 +1 -1
- data/ext/reflex/menu.cpp +8 -7
- 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 +18 -6
- data/ext/reflex/note_event.cpp +1 -1
- data/ext/reflex/pin.cpp +1 -1
- data/ext/reflex/pointer.cpp +1 -1
- data/ext/reflex/pointer_event.cpp +2 -2
- data/ext/reflex/polygon_shape.cpp +1 -1
- data/ext/reflex/rect_shape.cpp +1 -1
- data/ext/reflex/reflex.cpp +568 -232
- data/ext/reflex/screen.cpp +31 -2
- data/ext/reflex/scroll_event.cpp +1 -1
- data/ext/reflex/selector.cpp +1 -1
- data/ext/reflex/selector.h +9 -9
- data/ext/reflex/shape.cpp +1 -1
- data/ext/reflex/snap_constraint.cpp +1 -1
- data/ext/reflex/style.cpp +1 -1
- data/ext/reflex/style_length.cpp +1 -1
- 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 +121 -61
- data/ext/reflex/wheel_constraint.cpp +1 -1
- data/ext/reflex/wheel_event.cpp +1 -1
- data/ext/reflex/window.cpp +256 -25
- data/include/reflex/application.h +10 -0
- data/include/reflex/color_picker.h +65 -0
- data/include/reflex/event.h +178 -88
- data/include/reflex/file_dialog.h +73 -0
- data/include/reflex/gamepad.h +3 -0
- data/include/reflex/menu.h +3 -3
- data/include/reflex/midi.h +3 -0
- data/include/reflex/reflex.h +2 -0
- data/include/reflex/ruby/application.h +6 -1
- data/include/reflex/ruby/color_picker.h +89 -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/reflex.h +3 -0
- data/include/reflex/ruby/view.h +92 -44
- data/include/reflex/ruby/window.h +60 -1
- data/include/reflex/ruby.h +3 -0
- data/include/reflex/screen.h +11 -2
- data/include/reflex/view.h +28 -16
- data/include/reflex/window.h +40 -8
- data/include/reflex.h +3 -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/color_event.rb +16 -0
- data/lib/reflex/color_picker.rb +45 -0
- data/lib/reflex/control_change_event.rb +17 -0
- data/lib/reflex/file_dialog.rb +70 -0
- data/lib/reflex/file_event.rb +37 -0
- data/lib/reflex/helper.rb +58 -7
- data/lib/reflex/key_event.rb +9 -4
- data/lib/reflex/menu.rb +17 -1
- data/lib/reflex/model.rb +19 -19
- data/lib/reflex/note_event.rb +1 -1
- data/lib/reflex/pointer.rb +14 -3
- data/lib/reflex/pointer_event.rb +12 -1
- data/lib/reflex/reflex.rb +5 -0
- data/lib/reflex/shape.rb +14 -14
- 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 +29 -14
- data/lib/reflex/wheel_event.rb +12 -3
- data/lib/reflex/window.rb +25 -13
- data/lib/reflex.rb +8 -2
- data/reflex.gemspec +4 -4
- data/samples/ime.rb +100 -0
- data/samples/ios/hello/hello.xcodeproj/project.pbxproj +236 -224
- data/samples/menu.rb +4 -1
- 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 +159 -18
- data/src/application.h +92 -7
- data/src/color_picker.cpp +113 -0
- data/src/color_picker.h +36 -0
- data/src/event.cpp +410 -252
- data/src/event.h +12 -0
- 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 +24 -0
- data/src/ios/color_picker.mm +19 -0
- data/src/ios/file_dialog.mm +21 -0
- data/src/ios/gamepad.mm +4 -4
- data/src/ios/menu.mm +5 -0
- data/src/ios/reflex.mm +8 -0
- data/src/ios/screen.mm +26 -0
- data/src/ios/view_controller.mm +2 -30
- data/src/ios/window.mm +38 -9
- data/src/menu.cpp +66 -4
- data/src/menu.h +17 -1
- data/src/midi.cpp +61 -31
- data/src/osx/app_delegate.h +4 -0
- data/src/osx/app_delegate.mm +102 -22
- data/src/osx/application.mm +88 -6
- data/src/osx/color_picker.mm +112 -0
- data/src/osx/event.h +10 -0
- data/src/osx/event.mm +84 -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.mm +177 -33
- data/src/osx/native_window.h +16 -2
- data/src/osx/native_window.mm +114 -57
- data/src/osx/opengl_view.h +2 -1
- data/src/osx/opengl_view.mm +184 -43
- data/src/osx/reflex.mm +38 -0
- data/src/osx/screen.mm +36 -0
- data/src/osx/window.mm +106 -24
- data/src/pointer.cpp +13 -4
- data/src/pointer.h +4 -0
- data/src/rays.h +46 -0
- data/src/sdl/application.cpp +68 -8
- data/src/sdl/color_picker.cpp +18 -0
- data/src/sdl/event.cpp +24 -3
- data/src/sdl/event.h +12 -0
- data/src/sdl/file_dialog.cpp +20 -0
- data/src/sdl/gamepad.cpp +3 -7
- data/src/sdl/menu.cpp +5 -0
- data/src/sdl/reflex.cpp +20 -0
- data/src/sdl/screen.cpp +36 -0
- data/src/sdl/window.cpp +142 -29
- data/src/shape.cpp +15 -10
- data/src/view.cpp +287 -198
- data/src/view.h +4 -2
- data/src/vk.h +416 -0
- data/src/win32/application.cpp +162 -12
- data/src/win32/application.h +20 -0
- data/src/win32/color_picker.cpp +82 -0
- data/src/win32/event.cpp +114 -12
- data/src/win32/event.h +21 -4
- data/src/win32/file_dialog.cpp +226 -0
- data/src/win32/gamepad.cpp +9 -2
- data/src/win32/menu.cpp +191 -53
- data/src/win32/menu.h +9 -1
- 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 +809 -148
- data/src/win32/window.h +6 -0
- data/src/window.cpp +718 -185
- data/src/window.h +66 -33
- data/src/world.cpp +9 -1
- data/test/helper.rb +17 -0
- data/test/test_application.rb +90 -1
- data/test/test_chase_constraint.rb +1 -3
- data/test/test_color_event.rb +36 -0
- data/test/test_color_picker.rb +62 -0
- data/test/test_constraint.rb +2 -4
- 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 +20 -5
- data/test/test_link_constraint.rb +1 -3
- data/test/test_menu.rb +40 -10
- data/test/test_pointer.rb +33 -23
- data/test/test_pointer_event.rb +24 -9
- data/test/test_reflex.rb +36 -0
- data/test/test_screen.rb +24 -2
- data/test/test_snap_constraint.rb +1 -3
- data/test/test_text_event.rb +54 -0
- data/test/test_view.rb +41 -4
- data/test/test_wheel_constraint.rb +1 -3
- data/test/test_wheel_event.rb +13 -5
- data/test/test_window.rb +196 -44
- metadata +80 -10
- data/.github/workflows/utils.rb +0 -127
data/src/menu.cpp
CHANGED
|
@@ -4,12 +4,73 @@
|
|
|
4
4
|
#include <algorithm>
|
|
5
5
|
#include <rays/point.h>
|
|
6
6
|
#include "reflex/exception.h"
|
|
7
|
+
#include "application.h"
|
|
8
|
+
#include "view.h"
|
|
9
|
+
#include "window.h"
|
|
7
10
|
|
|
8
11
|
|
|
9
12
|
namespace Reflex
|
|
10
13
|
{
|
|
11
14
|
|
|
12
15
|
|
|
16
|
+
void
|
|
17
|
+
Menu_cancel_active_pointers_for_popup (View* view)
|
|
18
|
+
{
|
|
19
|
+
Window* window = view ? view->window() : Window_get_active();
|
|
20
|
+
if (!window) return;
|
|
21
|
+
|
|
22
|
+
// popup runs a modal event loop that swallows every event until the
|
|
23
|
+
// menu is dismissed, so pointers being pressed would never see their
|
|
24
|
+
// up; canceling them first keeps every pointer stream closed.
|
|
25
|
+
Window_cancel_active_pointers(window);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
void
|
|
29
|
+
Menu_call_click_event (Menu* menu, Event* event)
|
|
30
|
+
{
|
|
31
|
+
Application_guard([&]()
|
|
32
|
+
{
|
|
33
|
+
menu->on_click(event);
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
void
|
|
38
|
+
Menu_call_show_event (Menu* menu, Event* event)
|
|
39
|
+
{
|
|
40
|
+
Application_guard([&]()
|
|
41
|
+
{
|
|
42
|
+
menu->on_show(event);
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
void
|
|
47
|
+
Menu_call_hide_event (Menu* menu, Event* event)
|
|
48
|
+
{
|
|
49
|
+
Application_guard([&]()
|
|
50
|
+
{
|
|
51
|
+
menu->on_hide(event);
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
void
|
|
56
|
+
Menu_call_open_submenu_event (Menu* menu, Event* event)
|
|
57
|
+
{
|
|
58
|
+
Application_guard([&]()
|
|
59
|
+
{
|
|
60
|
+
menu->on_open_submenu(event);
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
void
|
|
65
|
+
Menu_call_close_submenu_event (Menu* menu, Event* event)
|
|
66
|
+
{
|
|
67
|
+
Application_guard([&]()
|
|
68
|
+
{
|
|
69
|
+
menu->on_close_submenu(event);
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
|
|
13
74
|
Menu::Data::Data ()
|
|
14
75
|
{
|
|
15
76
|
}
|
|
@@ -194,9 +255,10 @@ namespace Reflex
|
|
|
194
255
|
}
|
|
195
256
|
|
|
196
257
|
void
|
|
197
|
-
Menu::set_shortcut (
|
|
258
|
+
Menu::set_shortcut (KeyCode key, uint modifiers)
|
|
198
259
|
{
|
|
199
|
-
|
|
260
|
+
Menu_validate_shortcut_modifiers(modifiers);
|
|
261
|
+
|
|
200
262
|
if (key == self->key && modifiers == self->modifiers)
|
|
201
263
|
return;
|
|
202
264
|
|
|
@@ -205,10 +267,10 @@ namespace Reflex
|
|
|
205
267
|
Menu_update(this);
|
|
206
268
|
}
|
|
207
269
|
|
|
208
|
-
|
|
270
|
+
KeyCode
|
|
209
271
|
Menu::shortcut_key () const
|
|
210
272
|
{
|
|
211
|
-
return self->key
|
|
273
|
+
return self->key;
|
|
212
274
|
}
|
|
213
275
|
|
|
214
276
|
uint
|
data/src/menu.h
CHANGED
|
@@ -19,10 +19,12 @@ namespace Reflex
|
|
|
19
19
|
|
|
20
20
|
Xot::WeakRef<Menu> parent;
|
|
21
21
|
|
|
22
|
-
String label
|
|
22
|
+
String label;
|
|
23
23
|
|
|
24
24
|
Image image;
|
|
25
25
|
|
|
26
|
+
KeyCode key = KEY_NONE;
|
|
27
|
+
|
|
26
28
|
uint modifiers = MOD_NONE;
|
|
27
29
|
|
|
28
30
|
bool enabled = true;
|
|
@@ -50,6 +52,8 @@ namespace Reflex
|
|
|
50
52
|
|
|
51
53
|
Menu::Data* Menu_create_data ();
|
|
52
54
|
|
|
55
|
+
void Menu_validate_shortcut_modifiers (uint modifiers);
|
|
56
|
+
|
|
53
57
|
void Menu_update (Menu* menu);
|
|
54
58
|
|
|
55
59
|
void Menu_popup (Menu* menu, View* view, coord x, coord y);
|
|
@@ -58,6 +62,18 @@ namespace Reflex
|
|
|
58
62
|
|
|
59
63
|
void Menu_child_removed (Menu* parent, Menu* child);
|
|
60
64
|
|
|
65
|
+
void Menu_cancel_active_pointers_for_popup (View* view);
|
|
66
|
+
|
|
67
|
+
void Menu_call_click_event (Menu* menu, Event* event);
|
|
68
|
+
|
|
69
|
+
void Menu_call_show_event (Menu* menu, Event* event);
|
|
70
|
+
|
|
71
|
+
void Menu_call_hide_event (Menu* menu, Event* event);
|
|
72
|
+
|
|
73
|
+
void Menu_call_open_submenu_event (Menu* menu, Event* event);
|
|
74
|
+
|
|
75
|
+
void Menu_call_close_submenu_event (Menu* menu, Event* event);
|
|
76
|
+
|
|
61
77
|
|
|
62
78
|
}// Reflex
|
|
63
79
|
|
data/src/midi.cpp
CHANGED
|
@@ -40,23 +40,24 @@ namespace Reflex
|
|
|
40
40
|
|
|
41
41
|
enum Type {UNKNOWN, MESSAGE, ERROR};
|
|
42
42
|
|
|
43
|
-
Type type
|
|
43
|
+
Type type = UNKNOWN;
|
|
44
44
|
|
|
45
|
-
MIDI
|
|
45
|
+
MIDI* midi = NULL;
|
|
46
46
|
|
|
47
47
|
Message message;
|
|
48
48
|
|
|
49
49
|
RtMidiError error;
|
|
50
50
|
|
|
51
|
-
double time = 0;
|
|
51
|
+
double time = 0, delta_time = 0;
|
|
52
52
|
|
|
53
53
|
RtMidiEvent ()
|
|
54
54
|
: error("")
|
|
55
55
|
{
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
-
RtMidiEvent (MIDI* midi, const Message& message, double time)
|
|
59
|
-
: type(MESSAGE), midi(midi), message(message), error(""),
|
|
58
|
+
RtMidiEvent (MIDI* midi, const Message& message, double time, double delta_time)
|
|
59
|
+
: type(MESSAGE), midi(midi), message(message), error(""),
|
|
60
|
+
time(time), delta_time(delta_time)
|
|
60
61
|
{
|
|
61
62
|
}
|
|
62
63
|
|
|
@@ -104,13 +105,34 @@ namespace Reflex
|
|
|
104
105
|
|
|
105
106
|
call_midi_event(midi, event);
|
|
106
107
|
|
|
107
|
-
|
|
108
|
-
|
|
108
|
+
for (auto& win : Window_all())
|
|
109
|
+
{
|
|
110
|
+
MIDIEvent e = event.dup();
|
|
111
|
+
Window_call_midi_event(win, &e);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
static MIDI::List midis;
|
|
109
116
|
|
|
110
|
-
|
|
117
|
+
static MIDI::Ref
|
|
118
|
+
find_midi (MIDI* midi)
|
|
119
|
+
{
|
|
120
|
+
auto it = std::find_if(
|
|
121
|
+
midis.begin(), midis.end(),
|
|
122
|
+
[=](const MIDI::Ref& ref) {return ref.get() == midi;});
|
|
123
|
+
return it == midis.end() ? MIDI::Ref() : *it;
|
|
111
124
|
}
|
|
112
125
|
|
|
113
|
-
static
|
|
126
|
+
static double
|
|
127
|
+
apply_time (MIDI* midi, const RtMidiEvent& event)
|
|
128
|
+
{
|
|
129
|
+
MIDI::Data* self = midi->self.get();
|
|
130
|
+
if (self->time == 0)
|
|
131
|
+
self->time = event.time;
|
|
132
|
+
else
|
|
133
|
+
self->time += event.delta_time;
|
|
134
|
+
return self->time;
|
|
135
|
+
}
|
|
114
136
|
|
|
115
137
|
static void
|
|
116
138
|
dispatch_midi_event (RtMidiEvent* event)
|
|
@@ -118,8 +140,12 @@ namespace Reflex
|
|
|
118
140
|
switch (event->type)
|
|
119
141
|
{
|
|
120
142
|
case RtMidiEvent::MESSAGE:
|
|
121
|
-
|
|
143
|
+
{
|
|
144
|
+
MIDI::Ref midi = find_midi(event->midi);
|
|
145
|
+
if (midi)
|
|
146
|
+
call_events(midi, event->message.data(), apply_time(midi, *event));
|
|
122
147
|
break;
|
|
148
|
+
}
|
|
123
149
|
|
|
124
150
|
case RtMidiEvent::ERROR:
|
|
125
151
|
system_error(
|
|
@@ -132,6 +158,8 @@ namespace Reflex
|
|
|
132
158
|
}
|
|
133
159
|
}
|
|
134
160
|
|
|
161
|
+
static Queue<RtMidiEvent> queue;
|
|
162
|
+
|
|
135
163
|
static void
|
|
136
164
|
process_midi_events ()
|
|
137
165
|
{
|
|
@@ -143,23 +171,13 @@ namespace Reflex
|
|
|
143
171
|
static void
|
|
144
172
|
event_callback (double dt, RtMidiEvent::Message* message, void* data)
|
|
145
173
|
{
|
|
146
|
-
MIDI*
|
|
147
|
-
MIDI::Data* self = midi->self.get();
|
|
148
|
-
|
|
149
|
-
if (self->time == 0)
|
|
150
|
-
self->time = Xot::time();
|
|
151
|
-
else
|
|
152
|
-
self->time += dt;
|
|
153
|
-
|
|
154
|
-
queue.push(RtMidiEvent(midi, *message, self->time));
|
|
174
|
+
queue.push(RtMidiEvent((MIDI*) data, *message, Xot::time(), dt));
|
|
155
175
|
}
|
|
156
176
|
|
|
157
177
|
static void
|
|
158
178
|
error_callback (RtMidiError::Type type, const std::string& message, void* data)
|
|
159
179
|
{
|
|
160
|
-
MIDI*
|
|
161
|
-
|
|
162
|
-
queue.push(RtMidiEvent(midi, RtMidiError(message, type)));
|
|
180
|
+
queue.push(RtMidiEvent((MIDI*) data, RtMidiError(message, type)));
|
|
163
181
|
}
|
|
164
182
|
|
|
165
183
|
static MIDI_CreateFun midi_create_fun = NULL;
|
|
@@ -191,13 +209,11 @@ namespace Reflex
|
|
|
191
209
|
self->name = name;
|
|
192
210
|
}
|
|
193
211
|
|
|
194
|
-
static MIDI::List midis;
|
|
195
|
-
|
|
196
212
|
static void
|
|
197
213
|
add_midi (MIDI* midi)
|
|
198
214
|
{
|
|
199
215
|
midis.emplace_back(midi);
|
|
200
|
-
|
|
216
|
+
Application_call_device_connect_event(app(), midi);
|
|
201
217
|
}
|
|
202
218
|
|
|
203
219
|
static void
|
|
@@ -208,7 +224,7 @@ namespace Reflex
|
|
|
208
224
|
if (it == midis.end()) return;
|
|
209
225
|
|
|
210
226
|
midis.erase(it);
|
|
211
|
-
|
|
227
|
+
Application_call_device_disconnect_event(app(), ref);
|
|
212
228
|
}
|
|
213
229
|
|
|
214
230
|
|
|
@@ -227,7 +243,7 @@ namespace Reflex
|
|
|
227
243
|
~MIDIDeviceManager ()
|
|
228
244
|
{
|
|
229
245
|
for (auto& midi : midis)
|
|
230
|
-
|
|
246
|
+
Application_call_device_disconnect_event(app(), midi);
|
|
231
247
|
}
|
|
232
248
|
|
|
233
249
|
void update ()
|
|
@@ -308,8 +324,10 @@ namespace Reflex
|
|
|
308
324
|
return;
|
|
309
325
|
#endif
|
|
310
326
|
|
|
311
|
-
if (
|
|
312
|
-
|
|
327
|
+
if (!app)
|
|
328
|
+
argument_error(__FILE__, __LINE__);
|
|
329
|
+
|
|
330
|
+
if (manager) return;
|
|
313
331
|
|
|
314
332
|
manager.reset(new MIDIDeviceManager());
|
|
315
333
|
}
|
|
@@ -317,8 +335,10 @@ namespace Reflex
|
|
|
317
335
|
void
|
|
318
336
|
MIDI_fin (Application* app)
|
|
319
337
|
{
|
|
320
|
-
if (!
|
|
321
|
-
|
|
338
|
+
if (!app)
|
|
339
|
+
argument_error(__FILE__, __LINE__);
|
|
340
|
+
|
|
341
|
+
if (!manager) return;
|
|
322
342
|
|
|
323
343
|
midis.clear();
|
|
324
344
|
manager.reset();
|
|
@@ -337,6 +357,16 @@ namespace Reflex
|
|
|
337
357
|
}
|
|
338
358
|
}
|
|
339
359
|
|
|
360
|
+
void
|
|
361
|
+
enable_midi ()
|
|
362
|
+
{
|
|
363
|
+
Application* app_ = app();
|
|
364
|
+
if (!app_)
|
|
365
|
+
invalid_state_error(__FILE__, __LINE__);
|
|
366
|
+
|
|
367
|
+
MIDI_init(app_);
|
|
368
|
+
}
|
|
369
|
+
|
|
340
370
|
|
|
341
371
|
MIDI::MIDI ()
|
|
342
372
|
{
|
data/src/osx/app_delegate.h
CHANGED
data/src/osx/app_delegate.mm
CHANGED
|
@@ -6,17 +6,19 @@
|
|
|
6
6
|
#import <Cocoa/Cocoa.h>
|
|
7
7
|
#include "reflex/event.h"
|
|
8
8
|
#include "reflex/exception.h"
|
|
9
|
+
#include "../application.h"
|
|
10
|
+
#include "../rays.h"
|
|
9
11
|
#include "menu.h"
|
|
10
12
|
|
|
11
13
|
|
|
12
14
|
static Reflex::Menu::Ref
|
|
13
15
|
create_menu (
|
|
14
16
|
const char* label, const char* name, SEL action = NULL,
|
|
15
|
-
|
|
17
|
+
Reflex::KeyCode key = Reflex::KEY_NONE, uint modifiers = Reflex::MOD_COMMAND)
|
|
16
18
|
{
|
|
17
19
|
Reflex::Menu* item = new Reflex::Menu(label);
|
|
18
20
|
item->set_name(name);
|
|
19
|
-
if (key) item->set_shortcut(key, modifiers);
|
|
21
|
+
if (key != Reflex::KEY_NONE) item->set_shortcut(key, modifiers);
|
|
20
22
|
Reflex::Menu_set_native_action(item, action);
|
|
21
23
|
return item;
|
|
22
24
|
}
|
|
@@ -40,17 +42,17 @@ create_application_menu (Reflex::Application* application)
|
|
|
40
42
|
|
|
41
43
|
app->add_child(create_menu(("About" + name).c_str(), "about", @selector(showAbout)));
|
|
42
44
|
app->add_child(create_sep());
|
|
43
|
-
app->add_child(create_menu("Preferences", "preferences", @selector(showPreference),
|
|
45
|
+
app->add_child(create_menu("Preferences", "preferences", @selector(showPreference), KEY_COMMA));
|
|
44
46
|
app->add_child(create_sep());
|
|
45
47
|
app->add_child(services.get());
|
|
46
48
|
app->add_child(create_sep());
|
|
47
|
-
app->add_child(create_menu(("Hide" + name).c_str(), "hide", @selector(hide:),
|
|
49
|
+
app->add_child(create_menu(("Hide" + name).c_str(), "hide", @selector(hide:), KEY_H));
|
|
48
50
|
app->add_child(create_menu(
|
|
49
51
|
"Hide Others", "hide_others", @selector(hideOtherApplications:),
|
|
50
|
-
|
|
52
|
+
KEY_H, MOD_OPTION | MOD_COMMAND));
|
|
51
53
|
app->add_child(create_menu("ShowAll", "show_all", @selector(unhideAllApplications:)));
|
|
52
54
|
app->add_child(create_sep());
|
|
53
|
-
app->add_child(create_menu(("Quit" + name).c_str(), "quit", @selector(quit),
|
|
55
|
+
app->add_child(create_menu(("Quit" + name).c_str(), "quit", @selector(quit), KEY_Q));
|
|
54
56
|
|
|
55
57
|
[NSApp setServicesMenu: Menu_get_nssubmenu(services)];
|
|
56
58
|
if ([NSApp respondsToSelector: @selector(setAppleMenu:)])
|
|
@@ -62,9 +64,11 @@ create_application_menu (Reflex::Application* application)
|
|
|
62
64
|
static Reflex::Menu::Ref
|
|
63
65
|
create_window_menu ()
|
|
64
66
|
{
|
|
67
|
+
using namespace Reflex;
|
|
68
|
+
|
|
65
69
|
Reflex::Menu::Ref win = create_menu("Window", "window");
|
|
66
70
|
|
|
67
|
-
win->add_child(create_menu("Minimize", "minimize", @selector(performMiniaturize:),
|
|
71
|
+
win->add_child(create_menu("Minimize", "minimize", @selector(performMiniaturize:), KEY_M));
|
|
68
72
|
win->add_child(create_menu("Zoom", "zoom", @selector(performZoom:)));
|
|
69
73
|
win->add_child(create_sep());
|
|
70
74
|
win->add_child(create_menu(
|
|
@@ -80,7 +84,8 @@ create_window_menu ()
|
|
|
80
84
|
|
|
81
85
|
{
|
|
82
86
|
Reflex::Application* application;
|
|
83
|
-
|
|
87
|
+
NSStatusItem* status_item;
|
|
88
|
+
bool launched;
|
|
84
89
|
}
|
|
85
90
|
|
|
86
91
|
- (id) init
|
|
@@ -89,7 +94,8 @@ create_window_menu ()
|
|
|
89
94
|
if (!self) return nil;
|
|
90
95
|
|
|
91
96
|
application = NULL;
|
|
92
|
-
|
|
97
|
+
status_item = nil;
|
|
98
|
+
launched = false;
|
|
93
99
|
|
|
94
100
|
return self;
|
|
95
101
|
}
|
|
@@ -98,9 +104,20 @@ create_window_menu ()
|
|
|
98
104
|
{
|
|
99
105
|
assert(!application);
|
|
100
106
|
|
|
107
|
+
[self clearStatusItem];
|
|
108
|
+
|
|
101
109
|
[super dealloc];
|
|
102
110
|
}
|
|
103
111
|
|
|
112
|
+
- (void) clearStatusItem
|
|
113
|
+
{
|
|
114
|
+
if (!status_item) return;
|
|
115
|
+
|
|
116
|
+
[NSStatusBar.systemStatusBar removeStatusItem: status_item];
|
|
117
|
+
[status_item release];
|
|
118
|
+
status_item = nil;
|
|
119
|
+
}
|
|
120
|
+
|
|
104
121
|
- (void) bind: (Reflex::Application*) app
|
|
105
122
|
{
|
|
106
123
|
if (!app)
|
|
@@ -133,21 +150,59 @@ create_window_menu ()
|
|
|
133
150
|
|
|
134
151
|
- (BOOL) callOnStart
|
|
135
152
|
{
|
|
136
|
-
if (!application
|
|
153
|
+
if (!application)
|
|
137
154
|
return YES;
|
|
138
155
|
|
|
139
156
|
Reflex::Event e;
|
|
140
|
-
|
|
141
|
-
started = true;
|
|
157
|
+
Application_call_start_event(application, &e);
|
|
142
158
|
|
|
143
159
|
if (e.is_blocked()) [self quit];
|
|
144
160
|
return !e.is_blocked();
|
|
145
161
|
}
|
|
146
162
|
|
|
163
|
+
- (BOOL) isLaunched
|
|
164
|
+
{
|
|
165
|
+
return launched;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
- (void) updateStatusItem
|
|
169
|
+
{
|
|
170
|
+
Reflex::Menu* menu = application ? application->background_menu() : NULL;
|
|
171
|
+
if (!menu && application && application->background())
|
|
172
|
+
menu = application->menu();
|
|
173
|
+
if (!menu)
|
|
174
|
+
return [self clearStatusItem];
|
|
175
|
+
|
|
176
|
+
if (!status_item)
|
|
177
|
+
{
|
|
178
|
+
status_item =
|
|
179
|
+
[[NSStatusBar.systemStatusBar statusItemWithLength: NSVariableStatusItemLength]
|
|
180
|
+
retain];
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
NSImage* image =
|
|
184
|
+
menu->image() ? Rays::Bitmap_get_nsimage(menu->image().bitmap()) : nil;
|
|
185
|
+
[image setTemplate: YES];
|
|
186
|
+
|
|
187
|
+
NSString* title = @"";
|
|
188
|
+
if (!image)
|
|
189
|
+
{
|
|
190
|
+
Reflex::String label = menu->label();
|
|
191
|
+
if (label.empty()) label = application->name();
|
|
192
|
+
title = !label.empty()
|
|
193
|
+
? [NSString stringWithUTF8String: label]
|
|
194
|
+
: NSProcessInfo.processInfo.processName;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
status_item.button.image = image;
|
|
198
|
+
status_item.button.title = title;
|
|
199
|
+
status_item.menu = Reflex::Menu_get_nssubmenu(menu);
|
|
200
|
+
}
|
|
201
|
+
|
|
147
202
|
- (void) quit
|
|
148
203
|
{
|
|
149
204
|
if (application)
|
|
150
|
-
application
|
|
205
|
+
Application_call_quit(application);
|
|
151
206
|
else
|
|
152
207
|
[NSApp terminate: nil];
|
|
153
208
|
}
|
|
@@ -157,7 +212,7 @@ create_window_menu ()
|
|
|
157
212
|
if (!application) return;
|
|
158
213
|
|
|
159
214
|
Reflex::Event e;
|
|
160
|
-
application
|
|
215
|
+
Application_call_preference_event(application, &e);
|
|
161
216
|
}
|
|
162
217
|
|
|
163
218
|
- (void) showAbout
|
|
@@ -165,7 +220,7 @@ create_window_menu ()
|
|
|
165
220
|
if (application)
|
|
166
221
|
{
|
|
167
222
|
Reflex::Event e;
|
|
168
|
-
application
|
|
223
|
+
Application_call_about_event(application, &e);
|
|
169
224
|
}
|
|
170
225
|
else
|
|
171
226
|
[NSApp orderFrontStandardAboutPanel: nil];
|
|
@@ -183,31 +238,56 @@ create_window_menu ()
|
|
|
183
238
|
|
|
184
239
|
- (void) applicationDidFinishLaunching: (NSNotification*) notification
|
|
185
240
|
{
|
|
186
|
-
|
|
187
|
-
|
|
241
|
+
if (application)
|
|
242
|
+
Application_set_background(application, application->background());
|
|
188
243
|
|
|
244
|
+
launched = true;
|
|
189
245
|
[self callOnStart];
|
|
190
246
|
}
|
|
191
247
|
|
|
192
248
|
- (NSApplicationTerminateReply) applicationShouldTerminate: (NSApplication*) application
|
|
193
249
|
{
|
|
194
|
-
|
|
250
|
+
Reflex::Application* app = self->application;
|
|
251
|
+
if (!app) return NSTerminateNow;
|
|
252
|
+
|
|
253
|
+
if (app->self->running && !self.isQuitBySystem)
|
|
195
254
|
{
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
if (e.is_blocked()) return NSTerminateCancel;
|
|
255
|
+
Application_call_quit(app);
|
|
256
|
+
return NSTerminateCancel;
|
|
199
257
|
}
|
|
200
258
|
|
|
259
|
+
Reflex::Event e;
|
|
260
|
+
Application_call_quit_event(app, &e);
|
|
261
|
+
if (e.is_blocked()) return NSTerminateCancel;
|
|
262
|
+
|
|
201
263
|
return NSTerminateNow;
|
|
202
264
|
}
|
|
203
265
|
|
|
266
|
+
- (BOOL) isQuitBySystem
|
|
267
|
+
{
|
|
268
|
+
// log out, shut down and restart put a reason on the quit event,
|
|
269
|
+
// while a quit from the dock or a script comes without one
|
|
270
|
+
NSAppleEventDescriptor* event =
|
|
271
|
+
NSAppleEventManager.sharedAppleEventManager.currentAppleEvent;
|
|
272
|
+
return
|
|
273
|
+
event &&
|
|
274
|
+
event.eventClass == kCoreEventClass &&
|
|
275
|
+
event.eventID == kAEQuitApplication &&
|
|
276
|
+
[event attributeDescriptorForKeyword: kAEQuitReason];
|
|
277
|
+
}
|
|
278
|
+
|
|
204
279
|
- (BOOL) applicationShouldTerminateAfterLastWindowClosed: (NSApplication*) application
|
|
205
280
|
{
|
|
206
|
-
|
|
281
|
+
if (Application_should_quit(self->application))
|
|
282
|
+
[self quit];
|
|
283
|
+
return NO;
|
|
207
284
|
}
|
|
208
285
|
|
|
209
286
|
- (void) applicationWillTerminate: (NSNotification*) notification
|
|
210
287
|
{
|
|
288
|
+
if (application)
|
|
289
|
+
Application_cleanup(application);
|
|
290
|
+
|
|
211
291
|
[self unbind];
|
|
212
292
|
}
|
|
213
293
|
|