reflexion 0.5.3 → 0.6.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 +19 -1
- data/.doc/ext/reflex/chase_constraint.cpp +84 -0
- data/.doc/ext/reflex/clipboard.cpp +65 -0
- data/.doc/ext/reflex/constraint.cpp +135 -0
- data/.doc/ext/reflex/key_event.cpp +6 -6
- data/.doc/ext/reflex/link_constraint.cpp +178 -0
- data/.doc/ext/reflex/menu.cpp +302 -0
- data/.doc/ext/reflex/native.cpp +22 -4
- data/.doc/ext/reflex/pin.cpp +156 -0
- data/.doc/ext/reflex/pointer.cpp +2 -0
- data/.doc/ext/reflex/pointer_event.cpp +1 -1
- data/.doc/ext/reflex/reflex.cpp +42 -7
- data/.doc/ext/reflex/selector.cpp +4 -4
- data/.doc/ext/reflex/snap_constraint.cpp +125 -0
- data/.doc/ext/reflex/style_length.cpp +3 -2
- data/.doc/ext/reflex/view.cpp +96 -23
- data/.doc/ext/reflex/wheel_constraint.cpp +142 -0
- data/.doc/ext/reflex/window.cpp +59 -17
- data/.github/workflows/release-gem.yml +10 -1
- data/.github/workflows/test.yml +9 -0
- data/ChangeLog.md +25 -0
- data/README.md +1 -0
- data/VERSION +1 -1
- data/ext/reflex/application.cpp +21 -1
- data/ext/reflex/chase_constraint.cpp +89 -0
- data/ext/reflex/clipboard.cpp +69 -0
- data/ext/reflex/constraint.cpp +146 -0
- data/ext/reflex/key_event.cpp +6 -6
- data/ext/reflex/link_constraint.cpp +194 -0
- data/ext/reflex/menu.cpp +330 -0
- data/ext/reflex/native.cpp +22 -4
- data/ext/reflex/pin.cpp +165 -0
- data/ext/reflex/pointer.cpp +2 -0
- data/ext/reflex/pointer_event.cpp +1 -1
- data/ext/reflex/reflex.cpp +42 -7
- data/ext/reflex/selector.cpp +4 -4
- data/ext/reflex/selector.h +1 -1
- data/ext/reflex/snap_constraint.cpp +135 -0
- data/ext/reflex/style_length.cpp +3 -2
- data/ext/reflex/view.cpp +117 -37
- data/ext/reflex/wheel_constraint.cpp +154 -0
- data/ext/reflex/window.cpp +65 -18
- data/include/reflex/application.h +9 -0
- data/include/reflex/clipboard.h +53 -0
- data/include/reflex/constraint.h +275 -0
- data/include/reflex/defs.h +204 -195
- data/include/reflex/event.h +2 -0
- data/include/reflex/menu.h +120 -0
- data/include/reflex/pin.h +68 -0
- data/include/reflex/pointer.h +4 -0
- data/include/reflex/ruby/clipboard.h +23 -0
- data/include/reflex/ruby/constraint.h +94 -0
- data/include/reflex/ruby/menu.h +103 -0
- data/include/reflex/ruby/pin.h +40 -0
- data/include/reflex/ruby/view.h +36 -0
- data/include/reflex/ruby/window.h +36 -18
- data/include/reflex/view.h +39 -12
- data/include/reflex/window.h +17 -4
- data/include/reflex.h +5 -0
- data/lib/reflex/chase_constraint.rb +15 -0
- data/lib/reflex/clipboard.rb +19 -0
- data/lib/reflex/constraint.rb +29 -0
- data/lib/reflex/extension.rb +1 -1
- data/lib/reflex/helper.rb +28 -0
- data/lib/reflex/key_event.rb +7 -12
- data/lib/reflex/link_constraint.rb +31 -0
- data/lib/reflex/menu.rb +76 -0
- data/lib/reflex/pin.rb +39 -0
- data/lib/reflex/pointer.rb +18 -0
- data/lib/reflex/pointer_event.rb +1 -1
- data/lib/reflex/snap_constraint.rb +28 -0
- data/lib/reflex/view.rb +56 -4
- data/lib/reflex/wheel_constraint.rb +28 -0
- data/lib/reflex/wheel_event.rb +9 -0
- data/lib/reflex.rb +15 -6
- data/pod.rake +1 -1
- data/reflex.gemspec +3 -3
- data/samples/constraint.rb +152 -0
- data/samples/menu.rb +29 -0
- data/src/application.cpp +21 -2
- data/src/application.h +5 -0
- data/src/clipboard.cpp +81 -0
- data/src/constraint.cpp +1662 -0
- data/src/constraint.h +64 -0
- data/src/event.cpp +7 -1
- data/src/event.h +1 -2
- data/src/ios/application.mm +5 -0
- data/src/ios/clipboard.mm +44 -0
- data/src/ios/event.h +6 -2
- data/src/ios/event.mm +31 -12
- data/src/ios/menu.mm +36 -0
- data/src/ios/view_controller.mm +45 -12
- data/src/ios/window.mm +6 -0
- data/src/menu.cpp +325 -0
- data/src/menu.h +65 -0
- data/src/osx/app_delegate.mm +74 -125
- data/src/osx/application.mm +16 -0
- data/src/osx/clipboard.mm +45 -0
- data/src/osx/event.mm +40 -10
- data/src/osx/menu.h +25 -0
- data/src/osx/menu.mm +372 -0
- data/src/osx/native_window.mm +27 -0
- data/src/osx/opengl_view.mm +51 -0
- data/src/osx/window.mm +11 -0
- data/src/pin.cpp +137 -0
- data/src/pointer.cpp +27 -16
- data/src/pointer.h +6 -0
- data/src/sdl/application.cpp +5 -0
- data/src/sdl/clipboard.cpp +39 -0
- data/src/sdl/event.cpp +20 -3
- data/src/sdl/event.h +6 -3
- data/src/sdl/menu.cpp +35 -0
- data/src/sdl/window.cpp +26 -8
- data/src/view.cpp +313 -52
- data/src/view.h +18 -2
- data/src/win32/application.cpp +5 -0
- data/src/win32/clipboard.cpp +210 -0
- data/src/win32/event.cpp +11 -1
- data/src/win32/event.h +2 -0
- data/src/win32/menu.cpp +352 -0
- data/src/win32/menu.h +27 -0
- data/src/win32/window.cpp +62 -0
- data/src/win32/window.h +3 -0
- data/src/window.cpp +235 -22
- data/src/window.h +13 -2
- data/src/world.cpp +77 -14
- data/src/world.h +9 -2
- data/test/helper.rb +7 -0
- data/test/test_application.rb +11 -0
- data/test/test_chase_constraint.rb +124 -0
- data/test/test_clipboard.rb +54 -0
- data/test/test_constraint.rb +186 -0
- data/test/test_key_event.rb +6 -0
- data/test/test_link_constraint.rb +239 -0
- data/test/test_menu.rb +207 -0
- data/test/test_pin.rb +65 -0
- data/test/test_pointer.rb +23 -9
- data/test/test_pointer_event.rb +1 -1
- data/test/test_snap_constraint.rb +142 -0
- data/test/test_view.rb +113 -23
- data/test/test_wheel_constraint.rb +127 -0
- data/test/test_wheel_event.rb +15 -9
- data/test/test_window.rb +10 -0
- metadata +82 -8
|
@@ -0,0 +1,302 @@
|
|
|
1
|
+
#include "reflex/ruby/menu.h"
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
#include <ranges>
|
|
5
|
+
#include <rays/ruby/image.h>
|
|
6
|
+
#include "reflex/exception.h"
|
|
7
|
+
#include "reflex/ruby/selector.h"
|
|
8
|
+
#include "reflex/ruby/view.h"
|
|
9
|
+
#include "defs.h"
|
|
10
|
+
#include "selector.h"
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
RUCY_DEFINE_WRAPPER_VALUE_FROM_TO(REFLEX_EXPORT, Reflex::Menu)
|
|
14
|
+
|
|
15
|
+
#define THIS to<Reflex::Menu*>(self)
|
|
16
|
+
|
|
17
|
+
#define CHECK RUCY_CHECK_OBJ(Reflex::Menu, self)
|
|
18
|
+
|
|
19
|
+
#define CALL(fun) RUCY_CALL_SUPER(THIS, fun)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
static
|
|
23
|
+
VALUE alloc(VALUE klass)
|
|
24
|
+
{
|
|
25
|
+
return value(new Reflex::RubyMenu<Reflex::Menu>, klass);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
static
|
|
29
|
+
VALUE popup(VALUE self)
|
|
30
|
+
{
|
|
31
|
+
CHECK;
|
|
32
|
+
check_arg_count(__FILE__, __LINE__, "Menu#popup", argc, 2, 3);
|
|
33
|
+
|
|
34
|
+
Reflex::View* view = NULL;
|
|
35
|
+
if (argv[0].is_a(Reflex::view_class()))
|
|
36
|
+
{
|
|
37
|
+
view = to<Reflex::View*>(argv[0]);
|
|
38
|
+
argc--;
|
|
39
|
+
argv++;
|
|
40
|
+
}
|
|
41
|
+
THIS->popup(view, to<Rays::Point>(argc, argv));
|
|
42
|
+
return self;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
static
|
|
46
|
+
VALUE add_child(VALUE self, VALUE child, VALUE index)
|
|
47
|
+
{
|
|
48
|
+
CHECK;
|
|
49
|
+
THIS->add_child(to<Reflex::Menu*>(child), index.is_nil() ? -1 : to<int>(index));
|
|
50
|
+
return child;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
static
|
|
54
|
+
VALUE remove_child(VALUE self, VALUE child)
|
|
55
|
+
{
|
|
56
|
+
CHECK;
|
|
57
|
+
THIS->remove_child(to<Reflex::Menu*>(child));
|
|
58
|
+
return child;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
static
|
|
62
|
+
VALUE clear_children(VALUE self)
|
|
63
|
+
{
|
|
64
|
+
CHECK;
|
|
65
|
+
THIS->clear_children();
|
|
66
|
+
return self;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
static
|
|
70
|
+
VALUE find_children(VALUE self)
|
|
71
|
+
{
|
|
72
|
+
CHECK;
|
|
73
|
+
check_arg_count(__FILE__, __LINE__, "Menu#find_children", argc, 1, 2);
|
|
74
|
+
|
|
75
|
+
bool recursive = (argc >= 2) ? to<bool>(argv[1]) : true;
|
|
76
|
+
|
|
77
|
+
auto children =
|
|
78
|
+
THIS->find_children(to<Reflex::Selector>(argv[0]), recursive) |
|
|
79
|
+
std::views::transform([](auto& ref) {return value(ref);});
|
|
80
|
+
return array(children.begin(), children.end());
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
static
|
|
84
|
+
VALUE set_label(VALUE self, VALUE label)
|
|
85
|
+
{
|
|
86
|
+
CHECK;
|
|
87
|
+
THIS->set_label(label ? to<const char*>(label) : NULL);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
static
|
|
91
|
+
VALUE get_label(VALUE self)
|
|
92
|
+
{
|
|
93
|
+
CHECK;
|
|
94
|
+
return value(THIS->label());
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
static
|
|
98
|
+
VALUE set_image(VALUE self, VALUE image)
|
|
99
|
+
{
|
|
100
|
+
CHECK;
|
|
101
|
+
THIS->set_image(image ? to<Rays::Image&>(image) : Rays::Image());
|
|
102
|
+
return image;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
static
|
|
106
|
+
VALUE get_image(VALUE self)
|
|
107
|
+
{
|
|
108
|
+
CHECK;
|
|
109
|
+
const Rays::Image& image = THIS->image();
|
|
110
|
+
return image ? value(image) : nil();
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
static
|
|
114
|
+
VALUE enable(VALUE self, VALUE state)
|
|
115
|
+
{
|
|
116
|
+
CHECK;
|
|
117
|
+
THIS->enable(to<bool>(state));
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
static
|
|
121
|
+
VALUE is_enabled(VALUE self)
|
|
122
|
+
{
|
|
123
|
+
CHECK;
|
|
124
|
+
return value(THIS->is_enabled());
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
static
|
|
128
|
+
VALUE check(VALUE self, VALUE state)
|
|
129
|
+
{
|
|
130
|
+
CHECK;
|
|
131
|
+
THIS->check(to<bool>(state));
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
static
|
|
135
|
+
VALUE is_checked(VALUE self)
|
|
136
|
+
{
|
|
137
|
+
CHECK;
|
|
138
|
+
return value(THIS->is_checked());
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
static
|
|
143
|
+
VALUE set_shortcut_key(VALUE self, VALUE key)
|
|
144
|
+
{
|
|
145
|
+
CHECK;
|
|
146
|
+
THIS->set_shortcut(
|
|
147
|
+
key ? to<const char*>(key) : NULL,
|
|
148
|
+
THIS->shortcut_modifiers());
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
static
|
|
152
|
+
VALUE get_shortcut_key(VALUE self)
|
|
153
|
+
{
|
|
154
|
+
CHECK;
|
|
155
|
+
return value(THIS->shortcut_key());
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
static
|
|
159
|
+
VALUE set_shortcut_modifiers(VALUE self, VALUE modifiers)
|
|
160
|
+
{
|
|
161
|
+
CHECK;
|
|
162
|
+
THIS->set_shortcut(THIS->shortcut_key(), to<uint>(modifiers));
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
static
|
|
166
|
+
VALUE get_shortcut_modifiers(VALUE self)
|
|
167
|
+
{
|
|
168
|
+
CHECK;
|
|
169
|
+
return value(THIS->shortcut_modifiers());
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
static
|
|
173
|
+
VALUE is_separator(VALUE self)
|
|
174
|
+
{
|
|
175
|
+
CHECK;
|
|
176
|
+
return value(THIS->is_separator());
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
static
|
|
180
|
+
VALUE get_parent(VALUE self)
|
|
181
|
+
{
|
|
182
|
+
CHECK;
|
|
183
|
+
return value(THIS->parent());
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
static
|
|
187
|
+
VALUE get_size(VALUE self)
|
|
188
|
+
{
|
|
189
|
+
CHECK;
|
|
190
|
+
return value((int) THIS->size());
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
static
|
|
194
|
+
VALUE is_empty(VALUE self)
|
|
195
|
+
{
|
|
196
|
+
CHECK;
|
|
197
|
+
return value(THIS->empty());
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
static
|
|
201
|
+
VALUE each(VALUE self)
|
|
202
|
+
{
|
|
203
|
+
CHECK;
|
|
204
|
+
|
|
205
|
+
std::vector<Reflex::Menu::Ref> children(THIS->begin(), THIS->end());
|
|
206
|
+
|
|
207
|
+
Value ret;
|
|
208
|
+
for (auto& child : children)
|
|
209
|
+
ret = yield(value(child.get()));
|
|
210
|
+
return ret;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
static
|
|
214
|
+
VALUE on_show(VALUE self, VALUE event)
|
|
215
|
+
{
|
|
216
|
+
CHECK;
|
|
217
|
+
CALL(on_show(to<Reflex::Event*>(event)));
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
static
|
|
221
|
+
VALUE on_hide(VALUE self, VALUE event)
|
|
222
|
+
{
|
|
223
|
+
CHECK;
|
|
224
|
+
CALL(on_hide(to<Reflex::Event*>(event)));
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
static
|
|
228
|
+
VALUE on_open_submenu(VALUE self, VALUE event)
|
|
229
|
+
{
|
|
230
|
+
CHECK;
|
|
231
|
+
CALL(on_open_submenu(to<Reflex::Event*>(event)));
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
static
|
|
235
|
+
VALUE on_close_submenu(VALUE self, VALUE event)
|
|
236
|
+
{
|
|
237
|
+
CHECK;
|
|
238
|
+
CALL(on_close_submenu(to<Reflex::Event*>(event)));
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
static
|
|
242
|
+
VALUE on_click(VALUE self, VALUE event)
|
|
243
|
+
{
|
|
244
|
+
CHECK;
|
|
245
|
+
CALL(on_click(to<Reflex::Event*>(event)));
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
|
|
249
|
+
static Class cMenu;
|
|
250
|
+
|
|
251
|
+
void
|
|
252
|
+
Init_reflex_menu ()
|
|
253
|
+
{
|
|
254
|
+
Module mReflex = rb_define_module("Reflex");
|
|
255
|
+
|
|
256
|
+
cMenu = rb_define_class_under(mReflex, "Menu", rb_cObject);
|
|
257
|
+
rb_define_alloc_func(cMenu, alloc);
|
|
258
|
+
rb_define_method(cMenu, "popup", RUBY_METHOD_FUNC(popup), -1);
|
|
259
|
+
cMenu.define_method( "add_child!", add_child);
|
|
260
|
+
rb_define_method(cMenu, "remove_child", RUBY_METHOD_FUNC(remove_child), 1);
|
|
261
|
+
rb_define_method(cMenu, "clear_children", RUBY_METHOD_FUNC(clear_children), 0);
|
|
262
|
+
rb_define_method(cMenu, "find_children", RUBY_METHOD_FUNC(find_children), -1);
|
|
263
|
+
rb_define_method(cMenu, "label=", RUBY_METHOD_FUNC(set_label), 1);
|
|
264
|
+
rb_define_method(cMenu, "label", RUBY_METHOD_FUNC(get_label), 0);
|
|
265
|
+
rb_define_method(cMenu, "image=", RUBY_METHOD_FUNC(set_image), 1);
|
|
266
|
+
rb_define_method(cMenu, "image", RUBY_METHOD_FUNC(get_image), 0);
|
|
267
|
+
cMenu.define_method("enable!", enable);
|
|
268
|
+
cMenu.define_method("enabled?", is_enabled);
|
|
269
|
+
cMenu.define_method("check!", check);
|
|
270
|
+
cMenu.define_method("checked?", is_checked);
|
|
271
|
+
rb_define_method(cMenu, "shortcut_key=", RUBY_METHOD_FUNC(set_shortcut_key), 1);
|
|
272
|
+
rb_define_method(cMenu, "shortcut_key", RUBY_METHOD_FUNC(get_shortcut_key), 0);
|
|
273
|
+
rb_define_method(cMenu, "shortcut_modifiers=", RUBY_METHOD_FUNC(set_shortcut_modifiers), 1);
|
|
274
|
+
rb_define_method(cMenu, "shortcut_modifiers", RUBY_METHOD_FUNC(get_shortcut_modifiers), 0);
|
|
275
|
+
cMenu.define_method("separator?", is_separator);
|
|
276
|
+
rb_define_method(cMenu, "parent", RUBY_METHOD_FUNC(get_parent), 0);
|
|
277
|
+
rb_define_method(cMenu, "size", RUBY_METHOD_FUNC(get_size), 0);
|
|
278
|
+
cMenu.define_method("empty?", is_empty);
|
|
279
|
+
cMenu.define_method("each!", each);
|
|
280
|
+
rb_define_method(cMenu, "on_show", RUBY_METHOD_FUNC(on_show), 1);
|
|
281
|
+
rb_define_method(cMenu, "on_hide", RUBY_METHOD_FUNC(on_hide), 1);
|
|
282
|
+
rb_define_method(cMenu, "on_open_submenu", RUBY_METHOD_FUNC(on_open_submenu), 1);
|
|
283
|
+
rb_define_method(cMenu, "on_close_submenu", RUBY_METHOD_FUNC(on_close_submenu), 1);
|
|
284
|
+
rb_define_method(cMenu, "on_click", RUBY_METHOD_FUNC(on_click), 1);
|
|
285
|
+
|
|
286
|
+
define_wrapper_equality_methods<Reflex::Menu>(cMenu);
|
|
287
|
+
define_selector_methods<Reflex::Menu>(cMenu);
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
|
|
291
|
+
namespace Reflex
|
|
292
|
+
{
|
|
293
|
+
|
|
294
|
+
|
|
295
|
+
Class
|
|
296
|
+
menu_class ()
|
|
297
|
+
{
|
|
298
|
+
return cMenu;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
|
|
302
|
+
}// Reflex
|
data/.doc/ext/reflex/native.cpp
CHANGED
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
void Init_reflex ();
|
|
5
5
|
void Init_reflex_exception ();
|
|
6
6
|
|
|
7
|
-
void Init_reflex_pointer ();
|
|
8
7
|
void Init_reflex_selector ();
|
|
8
|
+
void Init_reflex_pointer ();
|
|
9
9
|
void Init_reflex_style ();
|
|
10
10
|
void Init_reflex_style_length ();
|
|
11
11
|
void Init_reflex_timer ();
|
|
@@ -35,10 +35,19 @@ void Init_reflex_line_shape ();
|
|
|
35
35
|
void Init_reflex_rect_shape ();
|
|
36
36
|
void Init_reflex_ellipse_shape ();
|
|
37
37
|
|
|
38
|
+
void Init_reflex_pin ();
|
|
39
|
+
void Init_reflex_constraint ();
|
|
40
|
+
void Init_reflex_snap_constraint ();
|
|
41
|
+
void Init_reflex_link_constraint ();
|
|
42
|
+
void Init_reflex_wheel_constraint ();
|
|
43
|
+
void Init_reflex_chase_constraint ();
|
|
44
|
+
|
|
38
45
|
void Init_reflex_application ();
|
|
39
|
-
void Init_reflex_screen ();
|
|
40
46
|
void Init_reflex_window ();
|
|
41
47
|
void Init_reflex_view ();
|
|
48
|
+
void Init_reflex_menu ();
|
|
49
|
+
void Init_reflex_screen ();
|
|
50
|
+
void Init_reflex_clipboard ();
|
|
42
51
|
|
|
43
52
|
void Init_reflex_device ();
|
|
44
53
|
void Init_reflex_midi ();
|
|
@@ -56,8 +65,8 @@ Init_reflex_ext ()
|
|
|
56
65
|
Init_reflex();
|
|
57
66
|
Init_reflex_exception();
|
|
58
67
|
|
|
59
|
-
Init_reflex_pointer();
|
|
60
68
|
Init_reflex_selector();
|
|
69
|
+
Init_reflex_pointer();
|
|
61
70
|
Init_reflex_style();
|
|
62
71
|
Init_reflex_style_length();
|
|
63
72
|
Init_reflex_timer();
|
|
@@ -87,10 +96,19 @@ Init_reflex_ext ()
|
|
|
87
96
|
Init_reflex_rect_shape();
|
|
88
97
|
Init_reflex_ellipse_shape();
|
|
89
98
|
|
|
99
|
+
Init_reflex_pin();
|
|
100
|
+
Init_reflex_constraint();
|
|
101
|
+
Init_reflex_snap_constraint();
|
|
102
|
+
Init_reflex_link_constraint();
|
|
103
|
+
Init_reflex_wheel_constraint();
|
|
104
|
+
Init_reflex_chase_constraint();
|
|
105
|
+
|
|
90
106
|
Init_reflex_application();
|
|
91
|
-
Init_reflex_screen();
|
|
92
107
|
Init_reflex_window();
|
|
93
108
|
Init_reflex_view();
|
|
109
|
+
Init_reflex_menu();
|
|
110
|
+
Init_reflex_screen();
|
|
111
|
+
Init_reflex_clipboard();
|
|
94
112
|
|
|
95
113
|
Init_reflex_device();
|
|
96
114
|
Init_reflex_midi();
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
#include "reflex/ruby/pin.h"
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
#include <rays/ruby/point.h>
|
|
5
|
+
#include "reflex/ruby/constraint.h"
|
|
6
|
+
#include "reflex/ruby/view.h"
|
|
7
|
+
#include "defs.h"
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
RUCY_DEFINE_VALUE_OR_ARRAY_FROM_TO(REFLEX_EXPORT, Reflex::Pin)
|
|
11
|
+
|
|
12
|
+
#define THIS to<Reflex::Pin*>(self)
|
|
13
|
+
|
|
14
|
+
#define CHECK RUCY_CHECK_OBJ(Reflex::Pin, self)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
static
|
|
18
|
+
VALUE alloc(VALUE klass)
|
|
19
|
+
{
|
|
20
|
+
return new_type<Reflex::Pin>(klass);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
static
|
|
24
|
+
VALUE initialize(VALUE self)
|
|
25
|
+
{
|
|
26
|
+
CHECK;
|
|
27
|
+
*THIS = to<Reflex::Pin>(argc, argv);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
static
|
|
31
|
+
VALUE initialize_copy(VALUE self, VALUE obj)
|
|
32
|
+
{
|
|
33
|
+
CHECK;
|
|
34
|
+
*THIS = to<Reflex::Pin&>(obj);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
static
|
|
38
|
+
VALUE snap(VALUE self)
|
|
39
|
+
{
|
|
40
|
+
CHECK;
|
|
41
|
+
return value(THIS->snap(to<Reflex::Pin>(argc, argv)));
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
static
|
|
45
|
+
VALUE link(VALUE self)
|
|
46
|
+
{
|
|
47
|
+
CHECK;
|
|
48
|
+
return value(THIS->link(to<Reflex::Pin>(argc, argv)));
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
static
|
|
52
|
+
VALUE wheel(VALUE self)
|
|
53
|
+
{
|
|
54
|
+
CHECK;
|
|
55
|
+
return value(THIS->wheel(to<Reflex::Pin>(argc, argv)));
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
static
|
|
59
|
+
VALUE chase(VALUE self)
|
|
60
|
+
{
|
|
61
|
+
CHECK;
|
|
62
|
+
return value(THIS->chase(to<Reflex::Pin>(argc, argv)));
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
static
|
|
66
|
+
VALUE get_view(VALUE self)
|
|
67
|
+
{
|
|
68
|
+
CHECK;
|
|
69
|
+
return value(THIS->view());
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
static
|
|
73
|
+
VALUE get_position(VALUE self)
|
|
74
|
+
{
|
|
75
|
+
CHECK;
|
|
76
|
+
const Rays::Point* pos = THIS->position();
|
|
77
|
+
return pos ? value(*pos) : nil();
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
static Class cPin;
|
|
82
|
+
|
|
83
|
+
void
|
|
84
|
+
Init_reflex_pin ()
|
|
85
|
+
{
|
|
86
|
+
Module mReflex = rb_define_module("Reflex");
|
|
87
|
+
|
|
88
|
+
cPin = rb_define_class_under(mReflex, "Pin", rb_cObject);
|
|
89
|
+
rb_define_alloc_func(cPin, alloc);
|
|
90
|
+
rb_define_private_method(cPin, "initialize", RUBY_METHOD_FUNC(initialize), -1);
|
|
91
|
+
rb_define_private_method(cPin, "initialize_copy", RUBY_METHOD_FUNC(initialize_copy), 1);
|
|
92
|
+
cPin.define_private_method("snap!", snap);
|
|
93
|
+
cPin.define_private_method("link!", link);
|
|
94
|
+
cPin.define_private_method("wheel!", wheel);
|
|
95
|
+
cPin.define_private_method("chase!", chase);
|
|
96
|
+
rb_define_method(cPin, "view", RUBY_METHOD_FUNC(get_view), 0);
|
|
97
|
+
rb_define_method(cPin, "position", RUBY_METHOD_FUNC(get_position), 0);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
namespace Rucy
|
|
102
|
+
{
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
template <> REFLEX_EXPORT Reflex::Pin
|
|
106
|
+
value_to<Reflex::Pin> (int argc, const Value* argv, bool convert)
|
|
107
|
+
{
|
|
108
|
+
if (argc == 1 && argv && argv->is_array())
|
|
109
|
+
{
|
|
110
|
+
argc = argv->size();
|
|
111
|
+
argv = argv->as_array();
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
if (convert)
|
|
115
|
+
{
|
|
116
|
+
if (argc == 0 || argv->is_nil())
|
|
117
|
+
return Reflex::Pin();
|
|
118
|
+
|
|
119
|
+
if (argv->is_a(Reflex::view_class()))
|
|
120
|
+
{
|
|
121
|
+
Reflex::View* view = value_to<Reflex::View*>(*argv);
|
|
122
|
+
argc -= 1;
|
|
123
|
+
argv += 1;
|
|
124
|
+
|
|
125
|
+
if (argc == 0)
|
|
126
|
+
return Reflex::Pin(view);
|
|
127
|
+
else
|
|
128
|
+
return Reflex::Pin(view, value_to<Rays::Point>(argc, argv, convert));
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
if (!argv->is_a(Reflex::pin_class()))
|
|
132
|
+
return Reflex::Pin(value_to<Rays::Point>(argc, argv, convert));
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
if (argc != 1)
|
|
136
|
+
argument_error(__FILE__, __LINE__);
|
|
137
|
+
|
|
138
|
+
return value_to<Reflex::Pin&>(*argv, convert);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
}// Rucy
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
namespace Reflex
|
|
146
|
+
{
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
Class
|
|
150
|
+
pin_class ()
|
|
151
|
+
{
|
|
152
|
+
return cPin;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
}// Reflex
|
data/.doc/ext/reflex/pointer.cpp
CHANGED
|
@@ -150,6 +150,8 @@ Init_reflex_pointer ()
|
|
|
150
150
|
cPointer.define_const("UP", Reflex::Pointer::UP);
|
|
151
151
|
cPointer.define_const("MOVE", Reflex::Pointer::MOVE);
|
|
152
152
|
cPointer.define_const("CANCEL", Reflex::Pointer::CANCEL);
|
|
153
|
+
cPointer.define_const("ENTER", Reflex::Pointer::ENTER);
|
|
154
|
+
cPointer.define_const("LEAVE", Reflex::Pointer::LEAVE);
|
|
153
155
|
cPointer.define_const("STAY", Reflex::Pointer::STAY);
|
|
154
156
|
}
|
|
155
157
|
|
data/.doc/ext/reflex/reflex.cpp
CHANGED
|
@@ -2,9 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
#include "reflex/ruby/view.h"
|
|
5
|
+
#include "reflex/ruby/constraint.h"
|
|
5
6
|
#include "reflex/ruby/timer.h"
|
|
6
7
|
#include "reflex/ruby/midi.h"
|
|
7
8
|
#include "../../src/window.h"
|
|
9
|
+
#include "../../src/constraint.h"
|
|
8
10
|
#include "../../src/timer.h"
|
|
9
11
|
#include "../../src/midi.h"
|
|
10
12
|
#include "defs.h"
|
|
@@ -16,6 +18,30 @@ create_root_view ()
|
|
|
16
18
|
return new Reflex::RubyView<Reflex::View>();
|
|
17
19
|
}
|
|
18
20
|
|
|
21
|
+
static Reflex::SnapConstraint*
|
|
22
|
+
create_snap_constraint ()
|
|
23
|
+
{
|
|
24
|
+
return new Reflex::RubyConstraint<Reflex::SnapConstraint>();
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
static Reflex::LinkConstraint*
|
|
28
|
+
create_link_constraint ()
|
|
29
|
+
{
|
|
30
|
+
return new Reflex::RubyConstraint<Reflex::LinkConstraint>();
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
static Reflex::WheelConstraint*
|
|
34
|
+
create_wheel_constraint ()
|
|
35
|
+
{
|
|
36
|
+
return new Reflex::RubyConstraint<Reflex::WheelConstraint>();
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
static Reflex::ChaseConstraint*
|
|
40
|
+
create_chase_constraint ()
|
|
41
|
+
{
|
|
42
|
+
return new Reflex::RubyConstraint<Reflex::ChaseConstraint>();
|
|
43
|
+
}
|
|
44
|
+
|
|
19
45
|
static Reflex::Timer*
|
|
20
46
|
create_timer ()
|
|
21
47
|
{
|
|
@@ -35,9 +61,13 @@ static
|
|
|
35
61
|
VALUE init(VALUE self)
|
|
36
62
|
{
|
|
37
63
|
Reflex::init();
|
|
38
|
-
Reflex::Window_set_create_root_view_fun(create_root_view);
|
|
39
|
-
Reflex::
|
|
40
|
-
Reflex::
|
|
64
|
+
Reflex:: Window_set_create_root_view_fun(create_root_view);
|
|
65
|
+
Reflex:: SnapConstraint_set_create_fun(create_snap_constraint);
|
|
66
|
+
Reflex:: LinkConstraint_set_create_fun(create_link_constraint);
|
|
67
|
+
Reflex::WheelConstraint_set_create_fun(create_wheel_constraint);
|
|
68
|
+
Reflex::ChaseConstraint_set_create_fun(create_chase_constraint);
|
|
69
|
+
Reflex:: Timer_set_create_fun(create_timer);
|
|
70
|
+
Reflex:: MIDI_set_create_fun(create_midi);
|
|
41
71
|
|
|
42
72
|
return self;
|
|
43
73
|
}
|
|
@@ -45,9 +75,13 @@ VALUE init(VALUE self)
|
|
|
45
75
|
static
|
|
46
76
|
VALUE fin(VALUE self)
|
|
47
77
|
{
|
|
48
|
-
Reflex::Window_set_create_root_view_fun(NULL);
|
|
49
|
-
Reflex::
|
|
50
|
-
Reflex::
|
|
78
|
+
Reflex:: Window_set_create_root_view_fun(NULL);
|
|
79
|
+
Reflex:: SnapConstraint_set_create_fun(NULL);
|
|
80
|
+
Reflex:: LinkConstraint_set_create_fun(NULL);
|
|
81
|
+
Reflex::WheelConstraint_set_create_fun(NULL);
|
|
82
|
+
Reflex::ChaseConstraint_set_create_fun(NULL);
|
|
83
|
+
Reflex:: Timer_set_create_fun(NULL);
|
|
84
|
+
Reflex:: MIDI_set_create_fun(NULL);
|
|
51
85
|
Reflex::fin();
|
|
52
86
|
|
|
53
87
|
return self;
|
|
@@ -239,7 +273,7 @@ Init_reflex ()
|
|
|
239
273
|
DEFINE_CONST(KEY_SLEEP);
|
|
240
274
|
DEFINE_CONST(KEY_EXEC);
|
|
241
275
|
DEFINE_CONST(KEY_PRINT);
|
|
242
|
-
DEFINE_CONST(
|
|
276
|
+
DEFINE_CONST(KEY_CONTEXT_MENU);
|
|
243
277
|
DEFINE_CONST(KEY_SELECT);
|
|
244
278
|
DEFINE_CONST(KEY_CLEAR);
|
|
245
279
|
|
|
@@ -304,6 +338,7 @@ Init_reflex ()
|
|
|
304
338
|
DEFINE_CONST(MOD_FUNCTION);
|
|
305
339
|
DEFINE_CONST(MOD_NUMPAD);
|
|
306
340
|
DEFINE_CONST(MOD_CAPS);
|
|
341
|
+
DEFINE_CONST(MOD_SCROLL);
|
|
307
342
|
|
|
308
343
|
#undef DEFINE_CONST
|
|
309
344
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
#include "reflex/ruby/selector.h"
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
#include <assert.h>
|
|
5
4
|
#include "defs.h"
|
|
6
5
|
|
|
7
6
|
|
|
@@ -78,7 +77,7 @@ VALUE each_tag(VALUE self)
|
|
|
78
77
|
Value ret;
|
|
79
78
|
Reflex::Selector::const_iterator end = C_THIS->end();
|
|
80
79
|
for (Reflex::Selector::const_iterator it = C_THIS->begin(); it != end; ++it)
|
|
81
|
-
ret =
|
|
80
|
+
ret = yield(value(*it));
|
|
82
81
|
return ret;
|
|
83
82
|
}
|
|
84
83
|
|
|
@@ -134,13 +133,14 @@ namespace Rucy
|
|
|
134
133
|
template <> REFLEX_EXPORT Reflex::Selector
|
|
135
134
|
value_to<Reflex::Selector> (int argc, const Value* argv, bool convert)
|
|
136
135
|
{
|
|
137
|
-
if (argc == 1 && argv->is_array())
|
|
136
|
+
if (argc == 1 && argv && argv->is_array())
|
|
138
137
|
{
|
|
139
138
|
argc = argv->size();
|
|
140
139
|
argv = argv->as_array();
|
|
141
140
|
}
|
|
142
141
|
|
|
143
|
-
|
|
142
|
+
if (argc <= 0 || !argv)
|
|
143
|
+
argument_error(__FILE__, __LINE__);
|
|
144
144
|
|
|
145
145
|
if (convert)
|
|
146
146
|
{
|