reflexion 0.5.2 → 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 +30 -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 +4 -2
- 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
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 7dfd1c406c7a371f5d109f3d24816c4dce13dc011a91915f790355a779c21020
|
|
4
|
+
data.tar.gz: 4d42b1ce9f95d72d222a016a41ea216786276b539abd77d6818c4f71d4bf6d9b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e90160117d281ea46b2cf1d2a51e086575f5790154c67059d877c5ec85c3c0c00e34ee7972f70188cb125b08028154f86ba9f61d6ebd5ac55c6614f443ed10d4
|
|
7
|
+
data.tar.gz: 103874aa03b0f69b65e576c2841c7962d566dfb0642ac3a8041b7bd489a1d5b5a7312822eecb4b078b6738a834e92254297a5c79a39d7e317e9d2f0192b38053
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
#include "reflex/ruby/application.h"
|
|
2
2
|
|
|
3
3
|
|
|
4
|
+
#include "reflex/ruby/menu.h"
|
|
4
5
|
#include "reflex/ruby/window.h"
|
|
5
6
|
#include "defs.h"
|
|
6
7
|
|
|
@@ -52,6 +53,21 @@ VALUE get_name(VALUE self)
|
|
|
52
53
|
return value(THIS->name());
|
|
53
54
|
}
|
|
54
55
|
|
|
56
|
+
static
|
|
57
|
+
VALUE set_menu(VALUE self, VALUE menu)
|
|
58
|
+
{
|
|
59
|
+
CHECK;
|
|
60
|
+
THIS->set_menu(menu ? to<Reflex::Menu*>(menu) : NULL);
|
|
61
|
+
return menu;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
static
|
|
65
|
+
VALUE get_menu(VALUE self)
|
|
66
|
+
{
|
|
67
|
+
CHECK;
|
|
68
|
+
return value(THIS->menu());
|
|
69
|
+
}
|
|
70
|
+
|
|
55
71
|
static
|
|
56
72
|
VALUE each_window(VALUE self)
|
|
57
73
|
{
|
|
@@ -59,7 +75,7 @@ VALUE each_window(VALUE self)
|
|
|
59
75
|
|
|
60
76
|
Value ret;
|
|
61
77
|
for (auto it = THIS->window_begin(), end = THIS->window_end(); it != end; ++it)
|
|
62
|
-
ret =
|
|
78
|
+
ret = yield(value(it->get()));
|
|
63
79
|
return ret;
|
|
64
80
|
}
|
|
65
81
|
|
|
@@ -136,6 +152,8 @@ Init_reflex_application ()
|
|
|
136
152
|
rb_define_method(cApplication, "quit", RUBY_METHOD_FUNC(quit), 0);
|
|
137
153
|
rb_define_method(cApplication, "name=", RUBY_METHOD_FUNC(set_name), 1);
|
|
138
154
|
rb_define_method(cApplication, "name", RUBY_METHOD_FUNC(get_name), 0);
|
|
155
|
+
rb_define_method(cApplication, "menu=", RUBY_METHOD_FUNC(set_menu), 1);
|
|
156
|
+
rb_define_method(cApplication, "menu", RUBY_METHOD_FUNC(get_menu), 0);
|
|
139
157
|
rb_define_method(cApplication, "each_window", RUBY_METHOD_FUNC(each_window), 0);
|
|
140
158
|
rb_define_method(cApplication, "on_start", RUBY_METHOD_FUNC(on_start), 1);
|
|
141
159
|
rb_define_method(cApplication, "on_quit", RUBY_METHOD_FUNC(on_quit), 1);
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
#include "reflex/ruby/constraint.h"
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
#include <rays/ruby/point.h>
|
|
5
|
+
#include "reflex/exception.h"
|
|
6
|
+
#include "reflex/ruby/pin.h"
|
|
7
|
+
#include "reflex/ruby/view.h"
|
|
8
|
+
#include "defs.h"
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
RUCY_DEFINE_WRAPPER_VALUE_FROM_TO(REFLEX_EXPORT, Reflex::ChaseConstraint)
|
|
12
|
+
|
|
13
|
+
#define THIS to<Reflex::ChaseConstraint*>(self)
|
|
14
|
+
|
|
15
|
+
#define CHECK RUCY_CHECK_OBJ(Reflex::ChaseConstraint, self)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
static
|
|
19
|
+
VALUE alloc(VALUE klass)
|
|
20
|
+
{
|
|
21
|
+
Reflex::reflex_error(
|
|
22
|
+
__FILE__, __LINE__, "can not instantiate ChaseConstraint class");
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
static
|
|
26
|
+
VALUE set_target(VALUE self)
|
|
27
|
+
{
|
|
28
|
+
CHECK;
|
|
29
|
+
THIS->set_target(to<Reflex::Pin>(argc, argv));
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
static
|
|
33
|
+
VALUE get_target(VALUE self)
|
|
34
|
+
{
|
|
35
|
+
CHECK;
|
|
36
|
+
return value(THIS->target());
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
static
|
|
40
|
+
VALUE set_force(VALUE self, VALUE max_force)
|
|
41
|
+
{
|
|
42
|
+
CHECK;
|
|
43
|
+
if (max_force.is_nil())
|
|
44
|
+
THIS->clear_force();
|
|
45
|
+
else
|
|
46
|
+
THIS->set_force(to<float>(max_force));
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
static
|
|
50
|
+
VALUE get_force(VALUE self)
|
|
51
|
+
{
|
|
52
|
+
CHECK;
|
|
53
|
+
return THIS->has_force() ? value(THIS->force()) : nil();
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
static Class cChaseConstraint;
|
|
58
|
+
|
|
59
|
+
void
|
|
60
|
+
Init_reflex_chase_constraint ()
|
|
61
|
+
{
|
|
62
|
+
Module mReflex = rb_define_module("Reflex");
|
|
63
|
+
|
|
64
|
+
cChaseConstraint = mReflex.define_class("ChaseConstraint", Reflex::constraint_class());
|
|
65
|
+
rb_define_alloc_func(cChaseConstraint, alloc);
|
|
66
|
+
rb_define_method(cChaseConstraint, "target=", RUBY_METHOD_FUNC(set_target), -1);
|
|
67
|
+
rb_define_method(cChaseConstraint, "target", RUBY_METHOD_FUNC(get_target), 0);
|
|
68
|
+
rb_define_method(cChaseConstraint, "force=", RUBY_METHOD_FUNC(set_force), 1);
|
|
69
|
+
rb_define_method(cChaseConstraint, "force", RUBY_METHOD_FUNC(get_force), 0);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
namespace Reflex
|
|
74
|
+
{
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
Class
|
|
78
|
+
chase_constraint_class ()
|
|
79
|
+
{
|
|
80
|
+
return cChaseConstraint;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
}// Reflex
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
#include "reflex/ruby/clipboard.h"
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
#include "reflex/exception.h"
|
|
5
|
+
#include "defs.h"
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
static
|
|
9
|
+
VALUE alloc(VALUE klass)
|
|
10
|
+
{
|
|
11
|
+
Reflex::reflex_error(__FILE__, __LINE__, "can not instantiate Clipboard class.");
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
static
|
|
15
|
+
VALUE set_text(VALUE self, VALUE text)
|
|
16
|
+
{
|
|
17
|
+
Reflex::Clipboard clipboard;
|
|
18
|
+
if (!text.is_nil()) clipboard.set_text(text.c_str());
|
|
19
|
+
Reflex::set_clipboard(clipboard);
|
|
20
|
+
return text;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
static
|
|
24
|
+
VALUE get_text(VALUE self)
|
|
25
|
+
{
|
|
26
|
+
Reflex::Clipboard clipboard = Reflex::get_clipboard();
|
|
27
|
+
const char* text = clipboard.text();
|
|
28
|
+
return text ? value(text, rb_utf8_encoding()) : nil();
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
static
|
|
32
|
+
VALUE clear(VALUE self)
|
|
33
|
+
{
|
|
34
|
+
Reflex::set_clipboard(Reflex::Clipboard());
|
|
35
|
+
return self;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
static Class cClipboard;
|
|
40
|
+
|
|
41
|
+
void
|
|
42
|
+
Init_reflex_clipboard ()
|
|
43
|
+
{
|
|
44
|
+
Module mReflex = rb_define_module("Reflex");
|
|
45
|
+
|
|
46
|
+
cClipboard = rb_define_class_under(mReflex, "Clipboard", rb_cObject);
|
|
47
|
+
rb_define_alloc_func(cClipboard, alloc);
|
|
48
|
+
rb_define_singleton_method(cClipboard, "text=", RUBY_METHOD_FUNC(set_text), 1);
|
|
49
|
+
rb_define_singleton_method(cClipboard, "text", RUBY_METHOD_FUNC(get_text), 0);
|
|
50
|
+
rb_define_singleton_method(cClipboard, "clear", RUBY_METHOD_FUNC(clear), 0);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
namespace Reflex
|
|
55
|
+
{
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
Class
|
|
59
|
+
clipboard_class ()
|
|
60
|
+
{
|
|
61
|
+
return cClipboard;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
}// Reflex
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
#include "reflex/ruby/constraint.h"
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
#include <rays/ruby/point.h>
|
|
5
|
+
#include "reflex/exception.h"
|
|
6
|
+
#include "reflex/ruby/view.h"
|
|
7
|
+
#include "reflex/ruby/pin.h"
|
|
8
|
+
#include "defs.h"
|
|
9
|
+
#include "selector.h"
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
RUCY_DEFINE_WRAPPER_VALUE_FROM_TO(REFLEX_EXPORT, Reflex::Constraint)
|
|
13
|
+
|
|
14
|
+
#define THIS to<Reflex::Constraint*>(self)
|
|
15
|
+
|
|
16
|
+
#define CHECK RUCY_CHECK_OBJ(Reflex::Constraint, self)
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
static
|
|
20
|
+
VALUE alloc(VALUE klass)
|
|
21
|
+
{
|
|
22
|
+
Reflex::reflex_error(
|
|
23
|
+
__FILE__, __LINE__, "can not instantiate Constraint class");
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
static
|
|
27
|
+
VALUE remove(VALUE self)
|
|
28
|
+
{
|
|
29
|
+
CHECK;
|
|
30
|
+
THIS->remove();
|
|
31
|
+
return self;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
static
|
|
35
|
+
VALUE get_pin(VALUE self, VALUE index)
|
|
36
|
+
{
|
|
37
|
+
CHECK;
|
|
38
|
+
return value(THIS->pin(to<int>(index)));
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
static
|
|
42
|
+
VALUE set_spring(VALUE self, VALUE hertz)
|
|
43
|
+
{
|
|
44
|
+
CHECK;
|
|
45
|
+
THIS->set_spring(hertz ? to<float>(hertz) : 0);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
static
|
|
49
|
+
VALUE get_spring(VALUE self)
|
|
50
|
+
{
|
|
51
|
+
CHECK;
|
|
52
|
+
float hertz = THIS->spring();
|
|
53
|
+
return hertz > 0 ? value(hertz) : nil();
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
static
|
|
57
|
+
VALUE set_damping(VALUE self, VALUE ratio)
|
|
58
|
+
{
|
|
59
|
+
CHECK;
|
|
60
|
+
THIS->set_damping(to<float>(ratio));
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
static
|
|
64
|
+
VALUE get_damping(VALUE self)
|
|
65
|
+
{
|
|
66
|
+
CHECK;
|
|
67
|
+
return value(THIS->damping());
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
static
|
|
71
|
+
VALUE set_collide(VALUE self, VALUE state)
|
|
72
|
+
{
|
|
73
|
+
CHECK;
|
|
74
|
+
THIS->set_collide(to<bool>(state));
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
static
|
|
78
|
+
VALUE can_collide(VALUE self)
|
|
79
|
+
{
|
|
80
|
+
CHECK;
|
|
81
|
+
return value(THIS->can_collide());
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
static
|
|
85
|
+
VALUE is_removed(VALUE self)
|
|
86
|
+
{
|
|
87
|
+
CHECK;
|
|
88
|
+
return value(THIS->is_removed());
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
static
|
|
92
|
+
VALUE is_active(VALUE self)
|
|
93
|
+
{
|
|
94
|
+
CHECK;
|
|
95
|
+
return value(THIS->operator bool());
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
static Class cConstraint;
|
|
100
|
+
|
|
101
|
+
void
|
|
102
|
+
Init_reflex_constraint ()
|
|
103
|
+
{
|
|
104
|
+
Module mReflex = rb_define_module("Reflex");
|
|
105
|
+
|
|
106
|
+
cConstraint = rb_define_class_under(mReflex, "Constraint", rb_cObject);
|
|
107
|
+
rb_define_alloc_func(cConstraint, alloc);
|
|
108
|
+
rb_define_method(cConstraint, "remove", RUBY_METHOD_FUNC(remove), 0);
|
|
109
|
+
rb_define_private_method(cConstraint, "get_pin", RUBY_METHOD_FUNC(get_pin), 1);
|
|
110
|
+
rb_define_method(cConstraint, "spring=", RUBY_METHOD_FUNC(set_spring), 1);
|
|
111
|
+
rb_define_method(cConstraint, "spring", RUBY_METHOD_FUNC(get_spring), 0);
|
|
112
|
+
rb_define_method(cConstraint, "damping=", RUBY_METHOD_FUNC(set_damping), 1);
|
|
113
|
+
rb_define_method(cConstraint, "damping", RUBY_METHOD_FUNC(get_damping), 0);
|
|
114
|
+
rb_define_method(cConstraint, "collide=", RUBY_METHOD_FUNC(set_collide), 1);
|
|
115
|
+
cConstraint.define_method("collide?", can_collide);
|
|
116
|
+
cConstraint.define_method("removed?", is_removed);
|
|
117
|
+
cConstraint.define_method("active?", is_active);
|
|
118
|
+
|
|
119
|
+
define_selector_methods<Reflex::Constraint>(cConstraint);
|
|
120
|
+
define_wrapper_equality_methods<Reflex::Constraint>(cConstraint);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
namespace Reflex
|
|
125
|
+
{
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
Class
|
|
129
|
+
constraint_class ()
|
|
130
|
+
{
|
|
131
|
+
return cConstraint;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
}// Reflex
|
|
@@ -228,12 +228,12 @@ VALUE get_key(VALUE self)
|
|
|
228
228
|
CASE(VOLUME_DOWN): SYMBOL1(volume_down);
|
|
229
229
|
CASE(MUTE): SYMBOL1(mute);
|
|
230
230
|
|
|
231
|
-
CASE(SLEEP):
|
|
232
|
-
CASE(EXEC):
|
|
233
|
-
CASE(PRINT):
|
|
234
|
-
CASE(
|
|
235
|
-
CASE(SELECT):
|
|
236
|
-
CASE(CLEAR):
|
|
231
|
+
CASE(SLEEP): SYMBOL1(sleep);
|
|
232
|
+
CASE(EXEC): SYMBOL1(exec);
|
|
233
|
+
CASE(PRINT): SYMBOL1(print);
|
|
234
|
+
CASE(CONTEXT_MENU): SYMBOL1(context_menu);
|
|
235
|
+
CASE(SELECT): SYMBOL1(select);
|
|
236
|
+
CASE(CLEAR): SYMBOL1(clear);
|
|
237
237
|
|
|
238
238
|
CASE(NAVIGATION_VIEW): SYMBOL1(navigation_view);
|
|
239
239
|
CASE(NAVIGATION_MENU): SYMBOL1(navigation_menu);
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
#include "reflex/ruby/constraint.h"
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
#include <rays/ruby/point.h>
|
|
5
|
+
#include "reflex/exception.h"
|
|
6
|
+
#include "defs.h"
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
RUCY_DEFINE_WRAPPER_VALUE_FROM_TO(REFLEX_EXPORT, Reflex::LinkConstraint)
|
|
10
|
+
|
|
11
|
+
#define THIS to<Reflex::LinkConstraint*>(self)
|
|
12
|
+
|
|
13
|
+
#define CHECK RUCY_CHECK_OBJ(Reflex::LinkConstraint, self)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
static
|
|
17
|
+
VALUE alloc(VALUE klass)
|
|
18
|
+
{
|
|
19
|
+
Reflex::reflex_error(
|
|
20
|
+
__FILE__, __LINE__, "can not instantiate LinkConstraint class");
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
static
|
|
24
|
+
VALUE set_axis(VALUE self)
|
|
25
|
+
{
|
|
26
|
+
CHECK;
|
|
27
|
+
if (argc == 1 && argv[0].is_nil())
|
|
28
|
+
THIS->clear_axis();
|
|
29
|
+
else
|
|
30
|
+
THIS->set_axis(to<Rays::Point>(argc, argv));
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
static
|
|
34
|
+
VALUE get_axis(VALUE self)
|
|
35
|
+
{
|
|
36
|
+
CHECK;
|
|
37
|
+
return THIS->has_axis() ? value(THIS->axis()) : nil();
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
static
|
|
41
|
+
VALUE set_distance(VALUE self, VALUE distance)
|
|
42
|
+
{
|
|
43
|
+
CHECK;
|
|
44
|
+
if (distance.is_nil())
|
|
45
|
+
THIS->clear_distance();
|
|
46
|
+
else
|
|
47
|
+
THIS->set_distance(to<coord>(distance));
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
static
|
|
51
|
+
VALUE get_distance(VALUE self)
|
|
52
|
+
{
|
|
53
|
+
CHECK;
|
|
54
|
+
return value(THIS->distance());
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
static
|
|
58
|
+
VALUE has_distance(VALUE self)
|
|
59
|
+
{
|
|
60
|
+
CHECK;
|
|
61
|
+
return value(THIS->has_distance());
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
static
|
|
65
|
+
VALUE current_distance(VALUE self)
|
|
66
|
+
{
|
|
67
|
+
CHECK;
|
|
68
|
+
return value(THIS->current_distance());
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
static
|
|
72
|
+
VALUE set_range(VALUE self, VALUE min, VALUE max)
|
|
73
|
+
{
|
|
74
|
+
CHECK;
|
|
75
|
+
THIS->set_range(to<coord>(min), to<coord>(max));
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
static
|
|
79
|
+
VALUE clear_range(VALUE self)
|
|
80
|
+
{
|
|
81
|
+
CHECK;
|
|
82
|
+
THIS->clear_range();
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
static
|
|
86
|
+
VALUE range_min(VALUE self)
|
|
87
|
+
{
|
|
88
|
+
CHECK;
|
|
89
|
+
return value(THIS->range_min());
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
static
|
|
93
|
+
VALUE range_max(VALUE self)
|
|
94
|
+
{
|
|
95
|
+
CHECK;
|
|
96
|
+
return value(THIS->range_max());
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
static
|
|
100
|
+
VALUE has_range(VALUE self)
|
|
101
|
+
{
|
|
102
|
+
CHECK;
|
|
103
|
+
return value(THIS->has_range());
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
static
|
|
107
|
+
VALUE set_motor(VALUE self, VALUE pixels_per_second)
|
|
108
|
+
{
|
|
109
|
+
CHECK;
|
|
110
|
+
if (pixels_per_second.is_nil())
|
|
111
|
+
THIS->clear_motor();
|
|
112
|
+
else
|
|
113
|
+
THIS->set_motor(to<coord>(pixels_per_second));
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
static
|
|
117
|
+
VALUE get_motor(VALUE self)
|
|
118
|
+
{
|
|
119
|
+
CHECK;
|
|
120
|
+
return THIS->has_motor() ? value(THIS->motor()) : nil();
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
static
|
|
124
|
+
VALUE set_force(VALUE self, VALUE max_force)
|
|
125
|
+
{
|
|
126
|
+
CHECK;
|
|
127
|
+
if (max_force.is_nil())
|
|
128
|
+
THIS->clear_force();
|
|
129
|
+
else
|
|
130
|
+
THIS->set_force(to<float>(max_force));
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
static
|
|
134
|
+
VALUE get_force(VALUE self)
|
|
135
|
+
{
|
|
136
|
+
CHECK;
|
|
137
|
+
return THIS->has_force() ? value(THIS->force()) : nil();
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
static Class cLinkConstraint;
|
|
142
|
+
|
|
143
|
+
void
|
|
144
|
+
Init_reflex_link_constraint ()
|
|
145
|
+
{
|
|
146
|
+
Module mReflex = rb_define_module("Reflex");
|
|
147
|
+
|
|
148
|
+
cLinkConstraint = mReflex.define_class("LinkConstraint", Reflex::constraint_class());
|
|
149
|
+
rb_define_alloc_func(cLinkConstraint, alloc);
|
|
150
|
+
rb_define_method(cLinkConstraint, "axis=", RUBY_METHOD_FUNC(set_axis), -1);
|
|
151
|
+
rb_define_method(cLinkConstraint, "axis", RUBY_METHOD_FUNC(get_axis), 0);
|
|
152
|
+
rb_define_method(cLinkConstraint, "distance=", RUBY_METHOD_FUNC(set_distance), 1);
|
|
153
|
+
rb_define_method(cLinkConstraint, "distance", RUBY_METHOD_FUNC(get_distance), 0);
|
|
154
|
+
rb_define_method(cLinkConstraint, "current_distance", RUBY_METHOD_FUNC(current_distance), 0);
|
|
155
|
+
cLinkConstraint.define_private_method( "set_range!", set_range);
|
|
156
|
+
cLinkConstraint.define_private_method("clear_range!", clear_range);
|
|
157
|
+
cLinkConstraint.define_private_method( "range_min!", range_min);
|
|
158
|
+
cLinkConstraint.define_private_method( "range_max!", range_max);
|
|
159
|
+
cLinkConstraint.define_private_method( "has_range!", has_range);
|
|
160
|
+
rb_define_method(cLinkConstraint, "motor=", RUBY_METHOD_FUNC(set_motor), 1);
|
|
161
|
+
rb_define_method(cLinkConstraint, "motor", RUBY_METHOD_FUNC(get_motor), 0);
|
|
162
|
+
rb_define_method(cLinkConstraint, "force=", RUBY_METHOD_FUNC(set_force), 1);
|
|
163
|
+
rb_define_method(cLinkConstraint, "force", RUBY_METHOD_FUNC(get_force), 0);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
namespace Reflex
|
|
168
|
+
{
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
Class
|
|
172
|
+
link_constraint_class ()
|
|
173
|
+
{
|
|
174
|
+
return cLinkConstraint;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
}// Reflex
|