reflexion 0.3.6 → 0.3.7
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/midi.cpp +82 -0
- data/.doc/ext/reflex/native.cpp +4 -0
- data/.doc/ext/reflex/note_event.cpp +121 -0
- data/.doc/ext/reflex/reflex.cpp +23 -2
- data/.doc/ext/reflex/view.cpp +11 -16
- data/.doc/ext/reflex/window.cpp +24 -0
- data/ChangeLog.md +8 -0
- data/Rakefile +7 -0
- data/VERSION +1 -1
- data/ext/reflex/midi.cpp +87 -0
- data/ext/reflex/native.cpp +4 -0
- data/ext/reflex/note_event.cpp +130 -0
- data/ext/reflex/reflex.cpp +24 -2
- data/ext/reflex/view.cpp +11 -16
- data/ext/reflex/window.cpp +27 -0
- data/include/reflex/event.h +39 -2
- data/include/reflex/gamepad.h +2 -2
- data/include/reflex/midi.h +53 -0
- data/include/reflex/reflex.h +2 -0
- data/include/reflex/ruby/event.h +11 -0
- data/include/reflex/ruby/midi.h +84 -0
- data/include/reflex/ruby/window.h +27 -0
- data/include/reflex/view.h +9 -1
- data/include/reflex/window.h +6 -0
- data/lib/reflex/note_event.rb +34 -0
- data/lib/reflex/view.rb +2 -1
- data/lib/reflex.rb +9 -8
- data/reflex.gemspec +3 -3
- data/src/application.cpp +3 -0
- data/src/event.cpp +95 -7
- data/src/event.h +5 -0
- data/src/gamepad.cpp +14 -14
- data/src/gamepad.h +9 -9
- data/src/ios/event.mm +10 -2
- data/src/ios/gamepad.mm +2 -1
- data/src/midi.cpp +379 -0
- data/src/midi.h +32 -0
- data/src/osx/event.h +0 -3
- data/src/osx/event.mm +6 -6
- data/src/osx/gamepad_gc.mm +1 -1
- data/src/osx/gamepad_hid.mm +1 -1
- data/src/queue.h +71 -0
- data/src/reflex.cpp +18 -0
- data/src/timer.cpp +3 -10
- data/src/view.cpp +39 -0
- data/src/view.h +2 -0
- data/src/win32/event.cpp +5 -5
- data/src/win32/event.h +0 -2
- data/src/win32/gamepad.cpp +1 -1
- data/src/window.cpp +61 -10
- data/src/window.h +2 -0
- data/test/test_capture_event.rb +20 -16
- data/test/test_key_event.rb +8 -1
- data/test/test_note_event.rb +43 -0
- data/test/test_view.rb +24 -12
- metadata +29 -14
data/ext/reflex/reflex.cpp
CHANGED
@@ -3,21 +3,31 @@
|
|
3
3
|
|
4
4
|
#include "reflex/ruby/view.h"
|
5
5
|
#include "reflex/ruby/timer.h"
|
6
|
+
#include "reflex/ruby/midi.h"
|
6
7
|
#include "../../src/window.h"
|
7
8
|
#include "../../src/timer.h"
|
9
|
+
#include "../../src/midi.h"
|
8
10
|
#include "defs.h"
|
9
11
|
|
10
12
|
|
11
13
|
static Reflex::View*
|
12
14
|
create_root_view ()
|
13
15
|
{
|
14
|
-
return new Reflex::RubyView<Reflex::View
|
16
|
+
return new Reflex::RubyView<Reflex::View>();
|
15
17
|
}
|
16
18
|
|
17
19
|
static Reflex::Timer*
|
18
20
|
create_timer ()
|
19
21
|
{
|
20
|
-
return new Reflex::RubyTimer<Reflex::Timer
|
22
|
+
return new Reflex::RubyTimer<Reflex::Timer>();
|
23
|
+
}
|
24
|
+
|
25
|
+
static Reflex::MIDI*
|
26
|
+
create_midi ()
|
27
|
+
{
|
28
|
+
Reflex::MIDI* midi = new Reflex::RubyMIDI<Reflex::MIDI>();
|
29
|
+
value(midi);// apply MIDI class to ClassWrapper's value
|
30
|
+
return midi;
|
21
31
|
}
|
22
32
|
|
23
33
|
|
@@ -27,6 +37,7 @@ RUCY_DEF0(init)
|
|
27
37
|
Reflex::init();
|
28
38
|
Reflex::Window_set_create_root_view_fun(create_root_view);
|
29
39
|
Reflex::Timer_set_create_fun(create_timer);
|
40
|
+
Reflex::MIDI_set_create_fun(create_midi);
|
30
41
|
|
31
42
|
return self;
|
32
43
|
}
|
@@ -37,12 +48,22 @@ RUCY_DEF0(fin)
|
|
37
48
|
{
|
38
49
|
Reflex::Window_set_create_root_view_fun(NULL);
|
39
50
|
Reflex::Timer_set_create_fun(NULL);
|
51
|
+
Reflex::MIDI_set_create_fun(NULL);
|
40
52
|
Reflex::fin();
|
41
53
|
|
42
54
|
return self;
|
43
55
|
}
|
44
56
|
RUCY_END
|
45
57
|
|
58
|
+
static
|
59
|
+
RUCY_DEF0(process_events)
|
60
|
+
{
|
61
|
+
Reflex::process_events();
|
62
|
+
|
63
|
+
return self;
|
64
|
+
}
|
65
|
+
RUCY_END
|
66
|
+
|
46
67
|
|
47
68
|
static Module mReflex;
|
48
69
|
|
@@ -52,6 +73,7 @@ Init_reflex ()
|
|
52
73
|
mReflex = define_module("Reflex");
|
53
74
|
mReflex.define_singleton_method("init!", init);
|
54
75
|
mReflex.define_singleton_method("fin!", fin);
|
76
|
+
mReflex.define_singleton_method("process_events!", process_events);
|
55
77
|
|
56
78
|
using namespace Reflex;
|
57
79
|
|
data/ext/reflex/view.cpp
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
|
4
4
|
#include <vector>
|
5
|
+
#include <ranges>
|
5
6
|
#include <rays/ruby/point.h>
|
6
7
|
#include <rays/ruby/bounds.h>
|
7
8
|
#include <rays/ruby/polygon.h>
|
@@ -25,16 +26,6 @@ RUCY_DEFINE_WRAPPER_VALUE_FROM_TO(REFLEX_EXPORT, Reflex::View)
|
|
25
26
|
#define CALL(fun) RUCY_CALL_SUPER(THIS, fun)
|
26
27
|
|
27
28
|
|
28
|
-
template <typename T>
|
29
|
-
static inline Value
|
30
|
-
array (T begin, T end)
|
31
|
-
{
|
32
|
-
std::vector<Value> v;
|
33
|
-
for (T it = begin; it != end; ++it) v.push_back(value(*it));
|
34
|
-
return array(&v[0], v.size());
|
35
|
-
}
|
36
|
-
|
37
|
-
|
38
29
|
static
|
39
30
|
RUCY_DEF_ALLOC(alloc, klass)
|
40
31
|
{
|
@@ -213,8 +204,9 @@ RUCY_DEFN(find_children)
|
|
213
204
|
|
214
205
|
bool recursive = (argc >= 2) ? to<bool>(argv[1]) : true;
|
215
206
|
|
216
|
-
|
217
|
-
THIS->find_children(to<Reflex::Selector>(argv[0]), recursive)
|
207
|
+
auto children =
|
208
|
+
THIS->find_children(to<Reflex::Selector>(argv[0]), recursive) |
|
209
|
+
std::views::transform([](auto& ref) {return value(ref);});
|
218
210
|
return array(children.begin(), children.end());
|
219
211
|
}
|
220
212
|
RUCY_END
|
@@ -273,8 +265,9 @@ RUCY_DEFN(find_styles)
|
|
273
265
|
|
274
266
|
bool recursive = (argc >= 2) ? to<bool>(argv[1]) : false;
|
275
267
|
|
276
|
-
|
277
|
-
THIS->find_styles(to<Reflex::Selector>(argv[0]), recursive)
|
268
|
+
auto styles =
|
269
|
+
THIS->find_styles(to<Reflex::Selector>(argv[0]), recursive) |
|
270
|
+
std::views::transform([](auto& ref) {return value(ref);});
|
278
271
|
return array(styles.begin(), styles.end());
|
279
272
|
}
|
280
273
|
RUCY_END
|
@@ -358,8 +351,9 @@ RUCY_DEFN(find_shapes)
|
|
358
351
|
CHECK;
|
359
352
|
check_arg_count(__FILE__, __LINE__, "View#find_shapes", argc, 1);
|
360
353
|
|
361
|
-
|
362
|
-
THIS->find_shapes(to<Reflex::Selector>(argv[0]))
|
354
|
+
auto shapes =
|
355
|
+
THIS->find_shapes(to<Reflex::Selector>(argv[0])) |
|
356
|
+
std::views::transform([](auto& ref) {return value(ref);});
|
363
357
|
return array(shapes.begin(), shapes.end());
|
364
358
|
}
|
365
359
|
RUCY_END
|
@@ -1352,6 +1346,7 @@ Init_reflex_view ()
|
|
1352
1346
|
cView.define_const("CAPTURE_NONE", Reflex::View::CAPTURE_NONE);
|
1353
1347
|
cView.define_const("CAPTURE_KEY", Reflex::View::CAPTURE_KEY);
|
1354
1348
|
cView.define_const("CAPTURE_POINTER", Reflex::View::CAPTURE_POINTER);
|
1349
|
+
cView.define_const("CAPTURE_NOTE", Reflex::View::CAPTURE_NOTE);
|
1355
1350
|
cView.define_const("CAPTURE_ALL", Reflex::View::CAPTURE_ALL);
|
1356
1351
|
|
1357
1352
|
define_selector_methods<Reflex::View>(cView);
|
data/ext/reflex/window.cpp
CHANGED
@@ -413,6 +413,30 @@ RUCY_DEF1(on_wheel, event)
|
|
413
413
|
}
|
414
414
|
RUCY_END
|
415
415
|
|
416
|
+
static
|
417
|
+
RUCY_DEF1(on_note, event)
|
418
|
+
{
|
419
|
+
CHECK;
|
420
|
+
CALL(on_note(to<Reflex::NoteEvent*>(event)));
|
421
|
+
}
|
422
|
+
RUCY_END
|
423
|
+
|
424
|
+
static
|
425
|
+
RUCY_DEF1(on_note_on, event)
|
426
|
+
{
|
427
|
+
CHECK;
|
428
|
+
CALL(on_note_on(to<Reflex::NoteEvent*>(event)));
|
429
|
+
}
|
430
|
+
RUCY_END
|
431
|
+
|
432
|
+
static
|
433
|
+
RUCY_DEF1(on_note_off, event)
|
434
|
+
{
|
435
|
+
CHECK;
|
436
|
+
CALL(on_note_off(to<Reflex::NoteEvent*>(event)));
|
437
|
+
}
|
438
|
+
RUCY_END
|
439
|
+
|
416
440
|
|
417
441
|
static Class cWindow;
|
418
442
|
|
@@ -466,6 +490,9 @@ Init_reflex_window ()
|
|
466
490
|
cWindow.define_method("on_pointer_move", on_pointer_move);
|
467
491
|
cWindow.define_method("on_pointer_cancel", on_pointer_cancel);
|
468
492
|
cWindow.define_method("on_wheel", on_wheel);
|
493
|
+
cWindow.define_method("on_note", on_note);
|
494
|
+
cWindow.define_method("on_note_on", on_note_on);
|
495
|
+
cWindow.define_method("on_note_off", on_note_off);
|
469
496
|
|
470
497
|
cWindow.define_const("ORIENTATION_PORTRAIT", Reflex::Window::FLAG_PORTRAIT);
|
471
498
|
cWindow.define_const("ORIENTATION_LANDSCAPE", Reflex::Window::FLAG_LANDSCAPE);
|
data/include/reflex/event.h
CHANGED
@@ -27,7 +27,7 @@ namespace Reflex
|
|
27
27
|
|
28
28
|
public:
|
29
29
|
|
30
|
-
Event ();
|
30
|
+
Event (double time = -1);
|
31
31
|
|
32
32
|
~Event ();
|
33
33
|
|
@@ -263,7 +263,7 @@ namespace Reflex
|
|
263
263
|
|
264
264
|
KeyEvent (
|
265
265
|
Action action, const char* chars, int code,
|
266
|
-
uint modifiers = 0, int repeat = 0);
|
266
|
+
uint modifiers = 0, int repeat = 0, double time = -1);
|
267
267
|
|
268
268
|
KeyEvent dup () const;
|
269
269
|
|
@@ -354,6 +354,43 @@ namespace Reflex
|
|
354
354
|
};// WheelEvent
|
355
355
|
|
356
356
|
|
357
|
+
class NoteEvent : public Event
|
358
|
+
{
|
359
|
+
|
360
|
+
public:
|
361
|
+
|
362
|
+
enum Action {ACTION_NONE = 0, ON, OFF};
|
363
|
+
|
364
|
+
NoteEvent ();
|
365
|
+
|
366
|
+
NoteEvent (
|
367
|
+
Action action, int channel, int note, float velocity, double time);
|
368
|
+
|
369
|
+
NoteEvent dup () const;
|
370
|
+
|
371
|
+
Action action () const;
|
372
|
+
|
373
|
+
int channel () const;
|
374
|
+
|
375
|
+
int note () const;
|
376
|
+
|
377
|
+
float frequency () const;
|
378
|
+
|
379
|
+
float velocity () const;
|
380
|
+
|
381
|
+
bool is_captured () const;
|
382
|
+
|
383
|
+
struct Data;
|
384
|
+
|
385
|
+
Xot::PSharedImpl<Data> self;
|
386
|
+
|
387
|
+
private:
|
388
|
+
|
389
|
+
NoteEvent (const NoteEvent* src);
|
390
|
+
|
391
|
+
};// NoteEvent
|
392
|
+
|
393
|
+
|
357
394
|
class CaptureEvent : public Event
|
358
395
|
{
|
359
396
|
|
data/include/reflex/gamepad.h
CHANGED
@@ -0,0 +1,53 @@
|
|
1
|
+
// -*- c++ -*-
|
2
|
+
#pragma once
|
3
|
+
#ifndef __REFLEX_MIDI_H__
|
4
|
+
#define __REFLEX_MIDI_H__
|
5
|
+
|
6
|
+
|
7
|
+
#include <vector>
|
8
|
+
#include <xot/ref.h>
|
9
|
+
#include <xot/pimpl.h>
|
10
|
+
#include <reflex/device.h>
|
11
|
+
#include <reflex/event.h>
|
12
|
+
|
13
|
+
|
14
|
+
namespace Reflex
|
15
|
+
{
|
16
|
+
|
17
|
+
|
18
|
+
class MIDI : public Device
|
19
|
+
{
|
20
|
+
|
21
|
+
public:
|
22
|
+
|
23
|
+
typedef Xot::Ref<MIDI> Ref;
|
24
|
+
|
25
|
+
typedef std::vector<Ref> List;
|
26
|
+
|
27
|
+
MIDI ();
|
28
|
+
|
29
|
+
virtual ~MIDI ();
|
30
|
+
|
31
|
+
virtual const char* name () const;
|
32
|
+
|
33
|
+
virtual void on_note (NoteEvent* e);
|
34
|
+
|
35
|
+
virtual void on_note_on (NoteEvent* e);
|
36
|
+
|
37
|
+
virtual void on_note_off (NoteEvent* e);
|
38
|
+
|
39
|
+
virtual operator bool () const;
|
40
|
+
|
41
|
+
static const List& all ();
|
42
|
+
|
43
|
+
struct Data;
|
44
|
+
|
45
|
+
Xot::PImpl<Data> self;
|
46
|
+
|
47
|
+
};// MIDI
|
48
|
+
|
49
|
+
|
50
|
+
}// Reflex
|
51
|
+
|
52
|
+
|
53
|
+
#endif//EOH
|
data/include/reflex/reflex.h
CHANGED
data/include/reflex/ruby/event.h
CHANGED
@@ -29,6 +29,8 @@ RUCY_DECLARE_VALUE_FROM_TO(REFLEX_EXPORT, Reflex::PointerEvent)
|
|
29
29
|
|
30
30
|
RUCY_DECLARE_VALUE_FROM_TO(REFLEX_EXPORT, Reflex::WheelEvent)
|
31
31
|
|
32
|
+
RUCY_DECLARE_VALUE_FROM_TO(REFLEX_EXPORT, Reflex::NoteEvent)
|
33
|
+
|
32
34
|
RUCY_DECLARE_VALUE_FROM_TO(REFLEX_EXPORT, Reflex::CaptureEvent)
|
33
35
|
|
34
36
|
RUCY_DECLARE_VALUE_FROM_TO(REFLEX_EXPORT, Reflex::TimerEvent)
|
@@ -72,6 +74,9 @@ namespace Reflex
|
|
72
74
|
REFLEX_EXPORT Rucy::Class wheel_event_class ();
|
73
75
|
// class Reflex::WheelEvent
|
74
76
|
|
77
|
+
REFLEX_EXPORT Rucy::Class note_event_class ();
|
78
|
+
// class Reflex::NoteEvent
|
79
|
+
|
75
80
|
REFLEX_EXPORT Rucy::Class capture_event_class ();
|
76
81
|
// class Reflex::CaptureEvent
|
77
82
|
|
@@ -152,6 +157,12 @@ namespace Rucy
|
|
152
157
|
return Reflex::wheel_event_class();
|
153
158
|
}
|
154
159
|
|
160
|
+
template <> inline Class
|
161
|
+
get_ruby_class<Reflex::NoteEvent> ()
|
162
|
+
{
|
163
|
+
return Reflex::note_event_class();
|
164
|
+
}
|
165
|
+
|
155
166
|
template <> inline Class
|
156
167
|
get_ruby_class<Reflex::CaptureEvent> ()
|
157
168
|
{
|
@@ -0,0 +1,84 @@
|
|
1
|
+
// -*- c++ -*-
|
2
|
+
#pragma once
|
3
|
+
#ifndef __REFLEX_RUBY_MIDI_H__
|
4
|
+
#define __REFLEX_RUBY_MIDI_H__
|
5
|
+
|
6
|
+
|
7
|
+
#include <rucy/class.h>
|
8
|
+
#include <rucy/extension.h>
|
9
|
+
#include <reflex/midi.h>
|
10
|
+
|
11
|
+
|
12
|
+
RUCY_DECLARE_WRAPPER_VALUE_FROM_TO(REFLEX_EXPORT, Reflex::MIDI)
|
13
|
+
|
14
|
+
|
15
|
+
namespace Reflex
|
16
|
+
{
|
17
|
+
|
18
|
+
|
19
|
+
REFLEX_EXPORT Rucy::Class midi_class ();
|
20
|
+
// class Reflex::MIDI
|
21
|
+
|
22
|
+
|
23
|
+
template <typename T>
|
24
|
+
class RubyMIDI : public Rucy::ClassWrapper<T>
|
25
|
+
{
|
26
|
+
|
27
|
+
typedef Rucy::ClassWrapper<T> Super;
|
28
|
+
|
29
|
+
public:
|
30
|
+
|
31
|
+
virtual void on_note (NoteEvent* e)
|
32
|
+
{
|
33
|
+
RUCY_SYM(on_note);
|
34
|
+
if (this->is_overridable())
|
35
|
+
this->value.call(on_note, Rucy::value(e));
|
36
|
+
else
|
37
|
+
Super::on_note(e);
|
38
|
+
}
|
39
|
+
|
40
|
+
virtual void on_note_on (NoteEvent* e)
|
41
|
+
{
|
42
|
+
RUCY_SYM(on_note_on);
|
43
|
+
if (this->is_overridable())
|
44
|
+
this->value.call(on_note_on, Rucy::value(e));
|
45
|
+
else
|
46
|
+
Super::on_note_on(e);
|
47
|
+
}
|
48
|
+
|
49
|
+
virtual void on_note_off (NoteEvent* e)
|
50
|
+
{
|
51
|
+
RUCY_SYM(on_note_off);
|
52
|
+
if (this->is_overridable())
|
53
|
+
this->value.call(on_note_off, Rucy::value(e));
|
54
|
+
else
|
55
|
+
Super::on_note_off(e);
|
56
|
+
}
|
57
|
+
|
58
|
+
};// RubyMIDI
|
59
|
+
|
60
|
+
|
61
|
+
}// Reflex
|
62
|
+
|
63
|
+
|
64
|
+
namespace Rucy
|
65
|
+
{
|
66
|
+
|
67
|
+
|
68
|
+
template <> inline Class
|
69
|
+
get_ruby_class<Reflex::MIDI> ()
|
70
|
+
{
|
71
|
+
return Reflex::midi_class();
|
72
|
+
}
|
73
|
+
|
74
|
+
inline Value
|
75
|
+
value (Reflex::MIDI::Ref& ref, Value klass = Reflex::midi_class())
|
76
|
+
{
|
77
|
+
return value(ref.get(), klass);
|
78
|
+
}
|
79
|
+
|
80
|
+
|
81
|
+
}// Rucy
|
82
|
+
|
83
|
+
|
84
|
+
#endif//EOH
|
@@ -191,6 +191,33 @@ namespace Reflex
|
|
191
191
|
Super::on_wheel(e);
|
192
192
|
}
|
193
193
|
|
194
|
+
virtual void on_note (NoteEvent* e)
|
195
|
+
{
|
196
|
+
RUCY_SYM(on_note);
|
197
|
+
if (this->is_overridable())
|
198
|
+
this->value.call(on_note, Rucy::value(e));
|
199
|
+
else
|
200
|
+
Super::on_note(e);
|
201
|
+
}
|
202
|
+
|
203
|
+
virtual void on_note_on (NoteEvent* e)
|
204
|
+
{
|
205
|
+
RUCY_SYM(on_note_on);
|
206
|
+
if (this->is_overridable())
|
207
|
+
this->value.call(on_note_on, Rucy::value(e));
|
208
|
+
else
|
209
|
+
Super::on_note_on(e);
|
210
|
+
}
|
211
|
+
|
212
|
+
virtual void on_note_off (NoteEvent* e)
|
213
|
+
{
|
214
|
+
RUCY_SYM(on_note_off);
|
215
|
+
if (this->is_overridable())
|
216
|
+
this->value.call(on_note_off, Rucy::value(e));
|
217
|
+
else
|
218
|
+
Super::on_note_off(e);
|
219
|
+
}
|
220
|
+
|
194
221
|
};// RubyWindow
|
195
222
|
|
196
223
|
|
data/include/reflex/view.h
CHANGED
@@ -82,7 +82,9 @@ namespace Reflex
|
|
82
82
|
|
83
83
|
CAPTURE_POINTER = Xot::bit(1),
|
84
84
|
|
85
|
-
|
85
|
+
CAPTURE_NOTE = Xot::bit(2),
|
86
|
+
|
87
|
+
CAPTURE_ALL = CAPTURE_KEY | CAPTURE_POINTER | CAPTURE_NOTE,
|
86
88
|
|
87
89
|
};// Capture
|
88
90
|
|
@@ -380,6 +382,12 @@ namespace Reflex
|
|
380
382
|
|
381
383
|
virtual void on_wheel (WheelEvent* e);
|
382
384
|
|
385
|
+
virtual void on_note (NoteEvent* e);
|
386
|
+
|
387
|
+
virtual void on_note_on (NoteEvent* e);
|
388
|
+
|
389
|
+
virtual void on_note_off (NoteEvent* e);
|
390
|
+
|
383
391
|
virtual void on_capture (CaptureEvent* e);
|
384
392
|
|
385
393
|
virtual void on_timer (TimerEvent* e);
|
data/include/reflex/window.h
CHANGED
@@ -135,6 +135,12 @@ namespace Reflex
|
|
135
135
|
|
136
136
|
virtual void on_wheel (WheelEvent* e);
|
137
137
|
|
138
|
+
virtual void on_note (NoteEvent* e);
|
139
|
+
|
140
|
+
virtual void on_note_on (NoteEvent* e);
|
141
|
+
|
142
|
+
virtual void on_note_off (NoteEvent* e);
|
143
|
+
|
138
144
|
operator bool () const;
|
139
145
|
|
140
146
|
bool operator ! () const;
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'xot/const_symbol_accessor'
|
2
|
+
require 'reflex/ext'
|
3
|
+
|
4
|
+
|
5
|
+
module Reflex
|
6
|
+
|
7
|
+
|
8
|
+
class NoteEvent < Event
|
9
|
+
|
10
|
+
alias get_action action
|
11
|
+
|
12
|
+
const_symbol_reader :action, **{
|
13
|
+
none: ACTION_NONE,
|
14
|
+
on: ON,
|
15
|
+
off: OFF
|
16
|
+
}
|
17
|
+
|
18
|
+
def on?()
|
19
|
+
get_action == ON
|
20
|
+
end
|
21
|
+
|
22
|
+
def off?()
|
23
|
+
get_action == OFF
|
24
|
+
end
|
25
|
+
|
26
|
+
def inspect()
|
27
|
+
"#<Reflex::NoteEvent action:%s channel:%d note:%d vel:0f time:%f captured?:%s>" %
|
28
|
+
[action, channel, note, velocity, time, captured?]
|
29
|
+
end
|
30
|
+
|
31
|
+
end# NoteEvent
|
32
|
+
|
33
|
+
|
34
|
+
end# Reflex
|
data/lib/reflex/view.rb
CHANGED
@@ -49,6 +49,7 @@ module Reflex
|
|
49
49
|
bit_flag_accessor :capture do
|
50
50
|
flag :key, CAPTURE_KEY
|
51
51
|
flag :pointer, CAPTURE_POINTER
|
52
|
+
flag :note, CAPTURE_NOTE
|
52
53
|
flag :all, CAPTURE_ALL
|
53
54
|
end
|
54
55
|
|
@@ -103,7 +104,7 @@ module Reflex
|
|
103
104
|
if args.empty?
|
104
105
|
not cap.empty?
|
105
106
|
elsif args.include?(:all)
|
106
|
-
cap == [:key, :pointer]
|
107
|
+
cap == [:key, :pointer, :note]
|
107
108
|
else
|
108
109
|
args.all? {|type| cap.include? type}
|
109
110
|
end
|
data/lib/reflex.rb
CHANGED
@@ -19,37 +19,38 @@ require 'reflex/reflex'
|
|
19
19
|
require 'reflex/helper'
|
20
20
|
|
21
21
|
require 'reflex/selector'
|
22
|
+
require 'reflex/pointer'
|
22
23
|
require 'reflex/style'
|
23
24
|
require 'reflex/style_length'
|
24
25
|
require 'reflex/timer'
|
25
26
|
require 'reflex/filter'
|
26
27
|
|
28
|
+
require 'reflex/shape'
|
29
|
+
require 'reflex/polygon_shape'
|
30
|
+
require 'reflex/line_shape'
|
31
|
+
require 'reflex/rect_shape'
|
32
|
+
require 'reflex/ellipse_shape'
|
33
|
+
|
27
34
|
require 'reflex/update_event'
|
28
35
|
require 'reflex/draw_event'
|
29
36
|
require 'reflex/frame_event'
|
30
37
|
require 'reflex/scroll_event'
|
31
38
|
require 'reflex/focus_event'
|
32
39
|
require 'reflex/key_event'
|
33
|
-
require 'reflex/pointer'
|
34
40
|
require 'reflex/pointer_event'
|
35
41
|
require 'reflex/wheel_event'
|
42
|
+
require 'reflex/note_event'
|
36
43
|
require 'reflex/capture_event'
|
37
44
|
require 'reflex/timer_event'
|
38
45
|
require 'reflex/contact_event'
|
39
46
|
|
40
|
-
require 'reflex/shape'
|
41
|
-
require 'reflex/polygon_shape'
|
42
|
-
require 'reflex/line_shape'
|
43
|
-
require 'reflex/rect_shape'
|
44
|
-
require 'reflex/ellipse_shape'
|
45
|
-
|
46
47
|
require 'reflex/model'
|
47
48
|
require 'reflex/model_owner'
|
48
49
|
|
49
50
|
require 'reflex/application'
|
50
|
-
require 'reflex/screen'
|
51
51
|
require 'reflex/window'
|
52
52
|
require 'reflex/view'
|
53
|
+
require 'reflex/screen'
|
53
54
|
|
54
55
|
require 'reflex/button'
|
55
56
|
require 'reflex/text_view'
|
data/reflex.gemspec
CHANGED
@@ -25,9 +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.
|
29
|
-
s.add_dependency 'rucy', '~> 0.3.
|
30
|
-
s.add_dependency 'rays', '~> 0.3.
|
28
|
+
s.add_dependency 'xot', '~> 0.3.7', '>= 0.3.7'
|
29
|
+
s.add_dependency 'rucy', '~> 0.3.7', '>= 0.3.7'
|
30
|
+
s.add_dependency 'rays', '~> 0.3.7', '>= 0.3.7'
|
31
31
|
|
32
32
|
s.files = `git ls-files`.split $/
|
33
33
|
s.executables = s.files.grep(%r{^bin/}) {|f| File.basename f}
|
data/src/application.cpp
CHANGED
@@ -5,6 +5,7 @@
|
|
5
5
|
#include "reflex/debug.h"
|
6
6
|
#include "window.h"
|
7
7
|
#include "gamepad.h"
|
8
|
+
#include "midi.h"
|
8
9
|
|
9
10
|
|
10
11
|
namespace Reflex
|
@@ -23,6 +24,7 @@ namespace Reflex
|
|
23
24
|
Application_call_start (Application* app, Event* e)
|
24
25
|
{
|
25
26
|
Gamepad_init(app);
|
27
|
+
MIDI_init(app);
|
26
28
|
|
27
29
|
app->on_start(e);
|
28
30
|
}
|
@@ -33,6 +35,7 @@ namespace Reflex
|
|
33
35
|
app->on_quit(e);
|
34
36
|
if (e->is_blocked()) return;
|
35
37
|
|
38
|
+
MIDI_fin(app);
|
36
39
|
Gamepad_fin(app);
|
37
40
|
}
|
38
41
|
|