reflexion 0.1.6 → 0.1.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (225) hide show
  1. checksums.yaml +7 -0
  2. data/.doc/ext/reflex/application.cpp +54 -39
  3. data/.doc/ext/reflex/capture_event.cpp +87 -0
  4. data/.doc/ext/reflex/draw_event.cpp +103 -0
  5. data/.doc/ext/reflex/event.cpp +73 -0
  6. data/.doc/ext/reflex/focus_event.cpp +98 -0
  7. data/.doc/ext/reflex/frame_event.cpp +133 -0
  8. data/.doc/ext/reflex/image_view.cpp +74 -0
  9. data/.doc/ext/reflex/key_event.cpp +124 -0
  10. data/.doc/ext/reflex/native.cpp +45 -6
  11. data/.doc/ext/reflex/pointer_event.cpp +181 -0
  12. data/.doc/ext/reflex/reflex.cpp +17 -41
  13. data/.doc/ext/reflex/scroll_event.cpp +141 -0
  14. data/.doc/ext/reflex/selector.cpp +135 -0
  15. data/.doc/ext/reflex/style.cpp +253 -0
  16. data/.doc/ext/reflex/style_length.cpp +133 -0
  17. data/.doc/ext/reflex/style_length2.cpp +149 -0
  18. data/.doc/ext/reflex/style_length4.cpp +192 -0
  19. data/.doc/ext/reflex/update_event.cpp +77 -0
  20. data/.doc/ext/reflex/view.cpp +408 -88
  21. data/.doc/ext/reflex/wheel_event.cpp +146 -0
  22. data/.doc/ext/reflex/window.cpp +95 -92
  23. data/Rakefile +6 -5
  24. data/VERSION +1 -1
  25. data/ext/reflex/application.cpp +67 -49
  26. data/ext/reflex/capture_event.cpp +92 -0
  27. data/ext/reflex/draw_event.cpp +110 -0
  28. data/ext/reflex/event.cpp +77 -0
  29. data/ext/reflex/extconf.rb +18 -68
  30. data/ext/reflex/focus_event.cpp +104 -0
  31. data/ext/reflex/frame_event.cpp +143 -0
  32. data/ext/reflex/image_view.cpp +77 -0
  33. data/ext/reflex/key_event.cpp +133 -0
  34. data/ext/reflex/native.cpp +45 -6
  35. data/ext/reflex/pointer_event.cpp +195 -0
  36. data/ext/reflex/reflex.cpp +21 -47
  37. data/ext/reflex/scroll_event.cpp +152 -0
  38. data/ext/reflex/selector.cpp +144 -0
  39. data/ext/reflex/style.cpp +277 -0
  40. data/ext/reflex/style_length.cpp +140 -0
  41. data/ext/reflex/style_length2.cpp +157 -0
  42. data/ext/reflex/style_length4.cpp +204 -0
  43. data/ext/reflex/update_event.cpp +81 -0
  44. data/ext/reflex/view.cpp +469 -114
  45. data/ext/reflex/wheel_event.cpp +158 -0
  46. data/ext/reflex/window.cpp +130 -123
  47. data/include/reflex/application.h +12 -7
  48. data/include/reflex/defs.h +13 -89
  49. data/include/reflex/event.h +260 -0
  50. data/include/reflex/exception.h +17 -11
  51. data/include/reflex/image_view.h +45 -0
  52. data/include/reflex/reflex.h +2 -6
  53. data/include/reflex/ruby/application.h +40 -13
  54. data/include/reflex/ruby/event.h +72 -0
  55. data/include/reflex/ruby/image_view.h +25 -0
  56. data/include/reflex/ruby/selector.h +27 -0
  57. data/include/reflex/ruby/style.h +27 -0
  58. data/include/reflex/ruby/style_length.h +37 -0
  59. data/include/reflex/ruby/view.h +193 -38
  60. data/include/reflex/ruby/window.h +123 -39
  61. data/include/reflex/ruby.h +3 -2
  62. data/include/reflex/selector.h +64 -0
  63. data/include/reflex/style.h +144 -0
  64. data/include/reflex/style_length.h +147 -0
  65. data/include/reflex/view.h +182 -19
  66. data/include/reflex/window.h +35 -19
  67. data/include/reflex.h +7 -0
  68. data/lib/reflex/application.rb +14 -5
  69. data/lib/reflex/arc_shape.rb +20 -0
  70. data/lib/reflex/button.rb +75 -0
  71. data/lib/reflex/capture_event.rb +37 -0
  72. data/lib/reflex/color.rb +13 -0
  73. data/lib/reflex/color_space.rb +13 -0
  74. data/lib/reflex/draw_event.rb +19 -0
  75. data/lib/reflex/ellipse_shape.rb +20 -0
  76. data/lib/reflex/ext.rb +1 -1
  77. data/lib/reflex/flags.rb +18 -0
  78. data/lib/reflex/focus_event.rb +38 -0
  79. data/lib/reflex/font.rb +13 -0
  80. data/lib/reflex/frame_event.rb +42 -0
  81. data/lib/reflex/helper.rb +87 -30
  82. data/lib/reflex/image_view.rb +25 -0
  83. data/lib/reflex/key_event.rb +38 -0
  84. data/lib/reflex/line_shape.rb +20 -0
  85. data/lib/reflex/list_view.rb +15 -0
  86. data/lib/reflex/model.rb +149 -0
  87. data/lib/reflex/model_owner.rb +57 -0
  88. data/lib/reflex/model_view.rb +22 -0
  89. data/lib/reflex/module.rb +11 -7
  90. data/lib/reflex/pointer_event.rb +85 -0
  91. data/lib/reflex/rect_shape.rb +20 -0
  92. data/lib/reflex/reflex.rb +13 -2
  93. data/lib/reflex/scroll_event.rb +19 -0
  94. data/lib/reflex/selector.rb +31 -0
  95. data/lib/reflex/shader.rb +13 -0
  96. data/lib/reflex/shape.rb +34 -0
  97. data/lib/reflex/style.rb +55 -0
  98. data/lib/reflex/style_length.rb +30 -0
  99. data/lib/reflex/style_length2.rb +34 -0
  100. data/lib/reflex/style_length4.rb +38 -0
  101. data/lib/reflex/text_view.rb +55 -0
  102. data/lib/reflex/update_event.rb +19 -0
  103. data/lib/reflex/view.rb +38 -4
  104. data/lib/reflex/wheel_event.rb +19 -0
  105. data/lib/reflex/window.rb +7 -5
  106. data/lib/reflex.rb +38 -1
  107. data/lib/reflexion/include.rb +5 -0
  108. data/lib/reflexion.rb +100 -0
  109. data/reflex.gemspec +3 -4
  110. data/samples/app.rb +13 -0
  111. data/samples/bats.rb +91 -0
  112. data/samples/checker.rb +36 -0
  113. data/{examples/ruby/shapes.rb → samples/fans.rb} +12 -16
  114. data/samples/fps.rb +46 -0
  115. data/samples/grid.rb +60 -0
  116. data/{examples/ruby → samples}/hello.rb +14 -16
  117. data/samples/image.rb +44 -0
  118. data/samples/ios/hello/hello/Images.xcassets/AppIcon.appiconset/Contents.json +53 -0
  119. data/samples/ios/hello/hello/Images.xcassets/LaunchImage.launchimage/Contents.json +51 -0
  120. data/samples/ios/hello/hello/en.lproj/InfoPlist.strings +2 -0
  121. data/samples/ios/hello/hello/hello-Info.plist +47 -0
  122. data/samples/ios/hello/hello/hello-Prefix.pch +10 -0
  123. data/samples/ios/hello/hello/main.cpp +79 -0
  124. data/samples/ios/hello/hello.xcodeproj/project.pbxproj +725 -0
  125. data/{examples/ruby → samples}/key.rb +11 -14
  126. data/samples/layout.rb +89 -0
  127. data/samples/model.rb +86 -0
  128. data/samples/osx/hello/hello/Images.xcassets/AppIcon.appiconset/Contents.json +58 -0
  129. data/samples/osx/hello/hello/en.lproj/Credits.rtf +29 -0
  130. data/samples/osx/hello/hello/en.lproj/InfoPlist.strings +2 -0
  131. data/samples/osx/hello/hello/hello-Info.plist +32 -0
  132. data/samples/osx/hello/hello/hello-Prefix.pch +3 -0
  133. data/samples/osx/hello/hello/main.cpp +79 -0
  134. data/samples/osx/hello/hello.xcodeproj/project.pbxproj +725 -0
  135. data/samples/reflexion/hello.rb +24 -0
  136. data/samples/reflexion/paint.rb +40 -0
  137. data/samples/reflexion/pulse.rb +34 -0
  138. data/samples/repl.rb +69 -0
  139. data/samples/shader.rb +41 -0
  140. data/samples/shapes.rb +30 -0
  141. data/{examples/ruby → samples}/text.rb +7 -8
  142. data/samples/tree.rb +71 -0
  143. data/samples/views.rb +41 -0
  144. data/samples/visuals.rb +22 -0
  145. data/src/event.cpp +225 -0
  146. data/src/exception.cpp +24 -15
  147. data/src/image_view.cpp +70 -0
  148. data/src/ios/app_delegate.h +17 -0
  149. data/src/ios/app_delegate.mm +120 -0
  150. data/src/ios/application.mm +116 -0
  151. data/src/{cocoa/applicationdata.h → ios/application_data.h} +6 -6
  152. data/src/ios/event.h +26 -0
  153. data/src/ios/event.mm +31 -0
  154. data/src/ios/native_window.h +37 -0
  155. data/src/ios/native_window.mm +220 -0
  156. data/src/ios/opengl_view.h +13 -0
  157. data/src/ios/opengl_view.mm +131 -0
  158. data/src/{cocoa → ios}/reflex.mm +8 -12
  159. data/src/ios/window.mm +303 -0
  160. data/src/ios/window_data.h +75 -0
  161. data/src/osx/app_delegate.h +17 -0
  162. data/src/{cocoa/cocoaapplication.mm → osx/app_delegate.mm} +90 -48
  163. data/src/osx/application.mm +132 -0
  164. data/src/osx/application_data.h +45 -0
  165. data/src/osx/event.h +42 -0
  166. data/src/osx/event.mm +112 -0
  167. data/src/osx/native_window.h +26 -0
  168. data/src/osx/native_window.mm +322 -0
  169. data/src/{cocoa/openglview.h → osx/opengl_view.h} +0 -4
  170. data/src/{cocoa/openglview.mm → osx/opengl_view.mm} +66 -23
  171. data/src/osx/reflex.mm +50 -0
  172. data/src/osx/window.mm +308 -0
  173. data/src/osx/window_data.h +75 -0
  174. data/src/selector.cpp +121 -0
  175. data/src/style.cpp +576 -0
  176. data/src/style_length.cpp +341 -0
  177. data/src/view.cpp +1228 -129
  178. data/src/win32/application.cpp +1 -1
  179. data/src/window.cpp +54 -26
  180. data/test/helper.rb +8 -4
  181. data/test/test_capture_event.rb +41 -0
  182. data/test/test_event.rb +20 -0
  183. data/test/test_has_frame.rb +45 -0
  184. data/test/test_model.rb +9 -0
  185. data/test/test_model_owner.rb +9 -0
  186. data/test/test_selector.rb +75 -0
  187. data/test/test_style.rb +70 -0
  188. data/test/test_style_length.rb +38 -0
  189. data/test/test_style_length2.rb +50 -0
  190. data/test/test_style_length4.rb +56 -0
  191. data/test/test_view.rb +97 -23
  192. data/test/test_window.rb +54 -46
  193. metadata +205 -84
  194. data/.doc/ext/reflex/defs.cpp +0 -8
  195. data/.doc/ext/reflex/key.cpp +0 -122
  196. data/.doc/ext/reflex/points.cpp +0 -151
  197. data/.gitignore +0 -14
  198. data/ChangeLog +0 -8
  199. data/examples/hello/.gitignore +0 -2
  200. data/examples/hello/Rakefile +0 -41
  201. data/examples/hello/main.cpp +0 -18
  202. data/examples/ruby/app.rb +0 -13
  203. data/examples/ruby/checker.rb +0 -41
  204. data/examples/ruby/fps.rb +0 -49
  205. data/examples/ruby/grid.rb +0 -65
  206. data/examples/ruby/views.rb +0 -88
  207. data/examples/ruby/visuals.rb +0 -27
  208. data/ext/reflex/defs.cpp +0 -8
  209. data/ext/reflex/key.cpp +0 -129
  210. data/ext/reflex/points.cpp +0 -161
  211. data/include/reflex/ruby/key.h +0 -39
  212. data/include/reflex/ruby/points.h +0 -39
  213. data/lib/reflex/visuals/string.rb +0 -53
  214. data/src/cocoa/application.mm +0 -101
  215. data/src/cocoa/cocoaapplication.h +0 -21
  216. data/src/cocoa/cocoawindow.h +0 -46
  217. data/src/cocoa/cocoawindow.mm +0 -230
  218. data/src/cocoa/defs.h +0 -34
  219. data/src/cocoa/defs.mm +0 -87
  220. data/src/cocoa/window.mm +0 -148
  221. data/src/cocoa/windowdata.h +0 -56
  222. data/src/defs.cpp +0 -47
  223. data/src/helper.h +0 -12
  224. data/src/reflex.cpp +0 -43
  225. /data/{README → README.md} +0 -0
@@ -0,0 +1,146 @@
1
+ #include "reflex/ruby/event.h"
2
+
3
+
4
+ #include <rucy.h>
5
+ #include "rays/ruby/point.h"
6
+ #include "defs.h"
7
+
8
+
9
+ using namespace Rucy;
10
+
11
+ using Reflex::coord;
12
+
13
+
14
+ static Class cWheelEvent;
15
+
16
+ RUCY_DEFINE_VALUE_FROM_TO(Reflex::WheelEvent, cWheelEvent)
17
+
18
+ #define THIS to<Reflex::WheelEvent*>(self)
19
+
20
+ #define CHECK RUCY_CHECK_OBJ(Reflex::WheelEvent, cWheelEvent, self)
21
+
22
+
23
+ static
24
+ VALUE alloc(VALUE klass)
25
+ {
26
+ return new_type<Reflex::WheelEvent>(klass);
27
+ }
28
+
29
+ static
30
+ VALUE initialize(VALUE self)
31
+ {
32
+ CHECK;
33
+ check_arg_count(__FILE__, __LINE__, "WheelEvent#initialize", argc, 0, 1, 2, 3);
34
+
35
+ THIS->dx = (argc >= 1) ? to<coord>(argv[0]) : 0;
36
+ THIS->dy = (argc >= 2) ? to<coord>(argv[1]) : 0;
37
+ THIS->dz = (argc >= 3) ? to<coord>(argv[2]) : 0;
38
+
39
+ return rb_call_super(0, NULL);
40
+ }
41
+
42
+ static
43
+ VALUE initialize_copy(VALUE self, VALUE obj)
44
+ {
45
+ CHECK;
46
+ *THIS = to<Reflex::WheelEvent&>(obj);
47
+ return self;
48
+ }
49
+
50
+ static
51
+ VALUE dx(VALUE self)
52
+ {
53
+ CHECK;
54
+ return value(THIS->dx);
55
+ }
56
+
57
+ static
58
+ VALUE dy(VALUE self)
59
+ {
60
+ CHECK;
61
+ return value(THIS->dy);
62
+ }
63
+
64
+ static
65
+ VALUE dz(VALUE self)
66
+ {
67
+ CHECK;
68
+ return value(THIS->dz);
69
+ }
70
+
71
+ static
72
+ VALUE x(VALUE self)
73
+ {
74
+ CHECK;
75
+ return value(THIS->x);
76
+ }
77
+
78
+ static
79
+ VALUE y(VALUE self)
80
+ {
81
+ CHECK;
82
+ return value(THIS->y);
83
+ }
84
+
85
+ static
86
+ VALUE z(VALUE self)
87
+ {
88
+ CHECK;
89
+ return value(THIS->z);
90
+ }
91
+
92
+ static
93
+ VALUE modifiers(VALUE self)
94
+ {
95
+ CHECK;
96
+ return value(THIS->modifiers);
97
+ }
98
+
99
+ static
100
+ VALUE delta(VALUE self)
101
+ {
102
+ CHECK;
103
+ return value(Rays::Point(THIS->dx, THIS->dy, THIS->dz));
104
+ }
105
+
106
+ static
107
+ VALUE position(VALUE self)
108
+ {
109
+ CHECK;
110
+ return value(Rays::Point(THIS->x, THIS->y, THIS->z));
111
+ }
112
+
113
+
114
+ void
115
+ Init_wheel_event ()
116
+ {
117
+ Module mReflex = rb_define_module("Reflex");
118
+
119
+ cWheelEvent = mReflex.define_class("WheelEvent", Reflex::event_class());
120
+ rb_define_alloc_func(cWheelEvent, alloc);
121
+ rb_define_private_method(cWheelEvent, "initialize", RUBY_METHOD_FUNC(initialize), -1);
122
+ rb_define_private_method(cWheelEvent, "initialize_copy", RUBY_METHOD_FUNC(initialize_copy), 1);
123
+ rb_define_method(cWheelEvent, "dx", RUBY_METHOD_FUNC(dx), 0);
124
+ rb_define_method(cWheelEvent, "dy", RUBY_METHOD_FUNC(dy), 0);
125
+ rb_define_method(cWheelEvent, "dz", RUBY_METHOD_FUNC(dz), 0);
126
+ rb_define_method(cWheelEvent, "x", RUBY_METHOD_FUNC(x), 0);
127
+ rb_define_method(cWheelEvent, "y", RUBY_METHOD_FUNC(y), 0);
128
+ rb_define_method(cWheelEvent, "z", RUBY_METHOD_FUNC(z), 0);
129
+ rb_define_method(cWheelEvent, "modifiers", RUBY_METHOD_FUNC(modifiers), 0);
130
+ rb_define_method(cWheelEvent, "delta", RUBY_METHOD_FUNC(delta), 0);
131
+ rb_define_method(cWheelEvent, "position", RUBY_METHOD_FUNC(position), 0);
132
+ }
133
+
134
+
135
+ namespace Reflex
136
+ {
137
+
138
+
139
+ Class
140
+ wheel_event_class ()
141
+ {
142
+ return cWheelEvent;
143
+ }
144
+
145
+
146
+ }// Reflex
@@ -2,9 +2,9 @@
2
2
 
3
3
 
4
4
  #include <rucy.h>
5
+ #include <rays/ruby/bounds.h>
5
6
  #include <rays/ruby/painter.h>
6
- #include <reflex/ruby/view.h>
7
- #include "defs.h"
7
+ #include "reflex/ruby/view.h"
8
8
 
9
9
 
10
10
  using namespace Rucy;
@@ -14,43 +14,26 @@ using Reflex::coord;
14
14
 
15
15
  static Class cWindow;
16
16
 
17
-
18
- namespace Reflex
19
- {
20
-
21
-
22
- Class
23
- window_class ()
24
- {
25
- return cWindow;
26
- }
27
-
28
-
29
- }// Reflex
30
-
31
-
32
- typedef Reflex::RubyWindow<Reflex::Window> RubyWindow;
33
-
17
+ RUCY_DEFINE_WRAPPER_VALUE_FROM_TO(Reflex::Window, cWindow)
34
18
 
35
19
  #define THIS to<Reflex::Window*>(self)
36
20
 
37
- #define CHECK RUCY_CHECK_OBJECT(self, Reflex::Window, cWindow)
21
+ #define CHECK RUCY_CHECK_OBJECT(Reflex::Window, cWindow, self)
38
22
 
39
- #define CALL(fun) RUCY_WRAPPER_CALL(RubyWindow, THIS, fun)
23
+ #define CALL(fun) RUCY_WRAPPER_CALL(Reflex::Window, THIS, fun)
40
24
 
41
25
 
42
26
  static
43
27
  VALUE alloc(VALUE klass)
44
28
  {
45
- return value(new RubyWindow, klass);
29
+ return value(new Reflex::RubyWindow<Reflex::Window>, klass);
46
30
  }
47
31
 
48
32
  static
49
33
  VALUE close(VALUE self)
50
34
  {
51
35
  CHECK;
52
- if (!CALL(close()))
53
- system_error("failed to close window.");
36
+ CALL(close());
54
37
  return self;
55
38
  }
56
39
 
@@ -58,8 +41,7 @@ static
58
41
  VALUE show(VALUE self)
59
42
  {
60
43
  CHECK;
61
- if (!CALL(show()))
62
- system_error("failed to show window.");
44
+ CALL(show());
63
45
  return self;
64
46
  }
65
47
 
@@ -67,8 +49,7 @@ static
67
49
  VALUE hide(VALUE self)
68
50
  {
69
51
  CHECK;
70
- if (!CALL(hide()))
71
- system_error("failed to hide window.");
52
+ CALL(hide());
72
53
  return self;
73
54
  }
74
55
 
@@ -76,8 +57,7 @@ static
76
57
  VALUE redraw(VALUE self)
77
58
  {
78
59
  CHECK;
79
- if (!THIS->redraw())
80
- system_error("failed to redraw window.");
60
+ THIS->redraw();
81
61
  return self;
82
62
  }
83
63
 
@@ -85,8 +65,7 @@ static
85
65
  VALUE set_title(VALUE self, VALUE title)
86
66
  {
87
67
  CHECK;
88
- if (!THIS->set_title(title.c_str()))
89
- system_error("failed to set title of window.");
68
+ THIS->set_title(title.c_str());
90
69
  return title;
91
70
  }
92
71
 
@@ -94,28 +73,21 @@ static
94
73
  VALUE get_title(VALUE self)
95
74
  {
96
75
  CHECK;
97
- const char* s = THIS->title();
98
- if (!s) system_error("failed to get title of window.");
99
- return value(s);
76
+ return value(THIS->title());
100
77
  }
101
78
 
102
79
  static
103
- VALUE set_bounds(VALUE self, VALUE x, VALUE y, VALUE width, VALUE height)
80
+ VALUE set_frame(VALUE self, VALUE arg)
104
81
  {
105
82
  CHECK;
106
- if (!THIS->set_bounds(
107
- to<coord>(x), to<coord>(y), to<coord>(width), to<coord>(height)))
108
- {
109
- system_error("failed to set bounds of window.");
110
- }
111
- return value(THIS->bounds());
83
+ THIS->set_frame(to<Rays::Bounds>(arg));
112
84
  }
113
85
 
114
86
  static
115
- VALUE get_bounds(VALUE self)
87
+ VALUE get_frame(VALUE self)
116
88
  {
117
89
  CHECK;
118
- return value(THIS->bounds());
90
+ return value(THIS->frame());
119
91
  }
120
92
 
121
93
  static
@@ -132,6 +104,13 @@ VALUE root(VALUE self)
132
104
  return value(THIS->root());
133
105
  }
134
106
 
107
+ static
108
+ VALUE focus(VALUE self)
109
+ {
110
+ CHECK;
111
+ return value(THIS->focus());
112
+ }
113
+
135
114
  static
136
115
  VALUE painter(VALUE self)
137
116
  {
@@ -140,87 +119,92 @@ VALUE painter(VALUE self)
140
119
  }
141
120
 
142
121
  static
143
- VALUE update(VALUE self, VALUE dt)
122
+ VALUE on_update(VALUE self, VALUE event)
144
123
  {
145
124
  CHECK;
146
- CALL(update(to<float>(dt)));
147
- return self;
125
+ CALL(on_update(to<Reflex::UpdateEvent*>(event)));
148
126
  }
149
127
 
150
128
  static
151
- VALUE draw(VALUE self)
129
+ VALUE on_draw(VALUE self, VALUE event)
152
130
  {
153
131
  CHECK;
154
- CALL(draw());
155
- return self;
132
+ CALL(on_draw(to<Reflex::DrawEvent*>(event)));
156
133
  }
157
134
 
158
135
  static
159
- VALUE moved(VALUE self, VALUE x, VALUE y)
136
+ VALUE on_move(VALUE self, VALUE event)
160
137
  {
161
138
  CHECK;
162
- CALL(moved(to<coord>(x), to<coord>(y)));
163
- return self;
139
+ CALL(on_move(to<Reflex::FrameEvent*>(event)));
164
140
  }
165
141
 
166
142
  static
167
- VALUE resized(VALUE self, VALUE width, VALUE height)
143
+ VALUE on_resize(VALUE self, VALUE event)
168
144
  {
169
145
  CHECK;
170
- CALL(resized(to<coord>(width), to<coord>(height)));
171
- return self;
146
+ CALL(on_resize(to<Reflex::FrameEvent*>(event)));
172
147
  }
173
148
 
174
149
  static
175
- VALUE key_down(VALUE self, VALUE key)
150
+ VALUE on_key(VALUE self, VALUE event)
176
151
  {
177
152
  CHECK;
178
- Reflex::Key* k = to<Reflex::Key*>(key);
179
- if (!k) argument_error();
180
- CALL(key_down(*k));
181
- return self;
153
+ CALL(on_key(to<Reflex::KeyEvent*>(event)));
182
154
  }
183
155
 
184
156
  static
185
- VALUE key_up(VALUE self, VALUE key)
157
+ VALUE on_key_down(VALUE self, VALUE event)
186
158
  {
187
159
  CHECK;
188
- Reflex::Key* k = to<Reflex::Key*>(key);
189
- if (!k) argument_error();
190
- CALL(key_up(*k));
191
- return self;
160
+ CALL(on_key_down(to<Reflex::KeyEvent*>(event)));
192
161
  }
193
162
 
194
163
  static
195
- VALUE points_down(VALUE self, VALUE points)
164
+ VALUE on_key_up(VALUE self, VALUE event)
196
165
  {
197
166
  CHECK;
198
- Reflex::Points* p = to<Reflex::Points*>(points);
199
- if (!p) argument_error();
200
- CALL(points_down(*p));
201
- return self;
167
+ CALL(on_key_up(to<Reflex::KeyEvent*>(event)));
202
168
  }
203
169
 
204
170
  static
205
- VALUE points_up(VALUE self, VALUE points)
171
+ VALUE on_pointer(VALUE self, VALUE event)
206
172
  {
207
173
  CHECK;
208
- Reflex::Points* p = to<Reflex::Points*>(points);
209
- if (!p) argument_error();
210
- CALL(points_up(*p));
211
- return self;
174
+ CALL(on_pointer(to<Reflex::PointerEvent*>(event)));
212
175
  }
213
176
 
214
177
  static
215
- VALUE points_moved(VALUE self, VALUE points)
178
+ VALUE on_pointer_down(VALUE self, VALUE event)
216
179
  {
217
180
  CHECK;
218
- Reflex::Points* p = to<Reflex::Points*>(points);
219
- if (!p) argument_error();
220
- CALL(points_moved(*p));
221
- return self;
181
+ CALL(on_pointer_down(to<Reflex::PointerEvent*>(event)));
222
182
  }
223
183
 
184
+ static
185
+ VALUE on_pointer_up(VALUE self, VALUE event)
186
+ {
187
+ CHECK;
188
+ CALL(on_pointer_up(to<Reflex::PointerEvent*>(event)));
189
+ }
190
+
191
+ static
192
+ VALUE on_pointer_move(VALUE self, VALUE event)
193
+ {
194
+ CHECK;
195
+ CALL(on_pointer_move(to<Reflex::PointerEvent*>(event)));
196
+ }
197
+
198
+ static
199
+ VALUE on_wheel(VALUE self, VALUE event)
200
+ {
201
+ CHECK;
202
+ CALL(on_wheel(to<Reflex::WheelEvent*>(event)));
203
+ }
204
+
205
+ static
206
+ RUCY_DEF_clear_override_flags(cof, Reflex::Window, cWindow);
207
+
224
208
 
225
209
  void
226
210
  Init_window ()
@@ -235,18 +219,37 @@ Init_window ()
235
219
  rb_define_method(cWindow, "redraw", RUBY_METHOD_FUNC(redraw), 0);
236
220
  rb_define_method(cWindow, "title=", RUBY_METHOD_FUNC(set_title), 1);
237
221
  rb_define_method(cWindow, "title", RUBY_METHOD_FUNC(get_title), 0);
238
- rb_define_private_method(cWindow, "set_bounds", RUBY_METHOD_FUNC(set_bounds), 4);
239
- rb_define_private_method(cWindow, "get_bounds", RUBY_METHOD_FUNC(get_bounds), 0);
222
+ rb_define_private_method(cWindow, "set_frame", RUBY_METHOD_FUNC(set_frame), 1);
223
+ rb_define_private_method(cWindow, "get_frame", RUBY_METHOD_FUNC(get_frame), 0);
240
224
  rb_define_method(cWindow, "hidden", RUBY_METHOD_FUNC(hidden), 0);
241
225
  rb_define_method(cWindow, "root", RUBY_METHOD_FUNC(root), 0);
226
+ rb_define_method(cWindow, "focus", RUBY_METHOD_FUNC(focus), 0);
242
227
  rb_define_method(cWindow, "painter", RUBY_METHOD_FUNC(painter), 0);
243
- rb_define_method(cWindow, "update", RUBY_METHOD_FUNC(update), 1);
244
- rb_define_method(cWindow, "draw", RUBY_METHOD_FUNC(draw), 0);
245
- rb_define_method(cWindow, "moved", RUBY_METHOD_FUNC(moved), 2);
246
- rb_define_method(cWindow, "resized", RUBY_METHOD_FUNC(resized), 2);
247
- rb_define_method(cWindow, "key_down", RUBY_METHOD_FUNC(key_down), 1);
248
- rb_define_method(cWindow, "key_up", RUBY_METHOD_FUNC(key_up), 1);
249
- rb_define_method(cWindow, "points_down", RUBY_METHOD_FUNC(points_down), 1);
250
- rb_define_method(cWindow, "points_up", RUBY_METHOD_FUNC(points_up), 1);
251
- rb_define_method(cWindow, "points_moved", RUBY_METHOD_FUNC(points_moved), 1);
228
+ rb_define_method(cWindow, "on_update", RUBY_METHOD_FUNC(on_update), 1);
229
+ rb_define_method(cWindow, "on_draw", RUBY_METHOD_FUNC(on_draw), 1);
230
+ rb_define_method(cWindow, "on_move", RUBY_METHOD_FUNC(on_move), 1);
231
+ rb_define_method(cWindow, "on_resize", RUBY_METHOD_FUNC(on_resize), 1);
232
+ rb_define_method(cWindow, "on_key", RUBY_METHOD_FUNC(on_key), 1);
233
+ rb_define_method(cWindow, "on_key_down", RUBY_METHOD_FUNC(on_key_down), 1);
234
+ rb_define_method(cWindow, "on_key_up", RUBY_METHOD_FUNC(on_key_up), 1);
235
+ rb_define_method(cWindow, "on_pointer", RUBY_METHOD_FUNC(on_pointer), 1);
236
+ rb_define_method(cWindow, "on_pointer_down", RUBY_METHOD_FUNC(on_pointer_down), 1);
237
+ rb_define_method(cWindow, "on_pointer_up", RUBY_METHOD_FUNC(on_pointer_up), 1);
238
+ rb_define_method(cWindow, "on_pointer_move", RUBY_METHOD_FUNC(on_pointer_move), 1);
239
+ rb_define_method(cWindow, "on_wheel", RUBY_METHOD_FUNC(on_wheel), 1);
240
+
252
241
  }
242
+
243
+
244
+ namespace Reflex
245
+ {
246
+
247
+
248
+ Class
249
+ window_class ()
250
+ {
251
+ return cWindow;
252
+ }
253
+
254
+
255
+ }// Reflex
data/Rakefile CHANGED
@@ -1,8 +1,9 @@
1
1
  # -*- mode: ruby; coding: utf-8 -*-
2
2
 
3
3
 
4
- require 'xot/load_path'
5
- Xot::LoadPath.unshift File.expand_path('../lib', __FILE__)
4
+ %w[../xot ../rucy ../rays .]
5
+ .map {|s| File.expand_path "../#{s}/lib", __FILE__}
6
+ .each {|s| $:.unshift s if !$:.include?(s) && File.directory?(s)}
6
7
 
7
8
  require 'xot/rake'
8
9
  require 'xot/module'
@@ -13,9 +14,9 @@ require 'reflex/module'
13
14
  include Xot::Rake
14
15
 
15
16
 
16
- MODULE = Reflex
17
+ MODULES = [Xot, Rucy, Rays, Reflex].map {|m| m.const_get :Module}
18
+ MODULE = MODULES.last
17
19
  GEMNAME = 'reflexion'
18
- INCDIRS = [Reflex, Rays, Rucy, Xot].map {|m| m.include_dirs}.flatten
19
20
  TESTS_ALONE = ['test/test_reflex.rb']
20
21
 
21
22
 
@@ -24,4 +25,4 @@ task :default => :build
24
25
  task :build => :ext
25
26
 
26
27
 
27
- [Xot, Rucy, Rays, Reflex].each {|m| m.load_tasks}
28
+ MODULES.each {|m| m.load_tasks :lib, :ext, :test, :doc, :gem}
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.6
1
+ 0.1.7
@@ -10,94 +10,95 @@ using namespace Rucy;
10
10
 
11
11
  static Class cApplication;
12
12
 
13
-
14
- namespace Reflex
15
- {
16
-
17
-
18
- Class
19
- application_class ()
20
- {
21
- return cApplication;
22
- }
23
-
24
-
25
- }// Reflex
26
-
27
-
28
- typedef Reflex::RubyApplication<Reflex::Application> RubyApplication;
29
-
13
+ RUCY_DEFINE_WRAPPER_VALUE_FROM_TO(Reflex::Application, cApplication)
30
14
 
31
15
  #define THIS to<Reflex::Application*>(self)
32
16
 
33
- #define CHECK RUCY_CHECK_OBJECT(self, Reflex::Application, cApplication)
17
+ #define CHECK RUCY_CHECK_OBJECT(Reflex::Application, cApplication, self)
34
18
 
35
- #define CALL(fun) RUCY_WRAPPER_CALL(RubyApplication, THIS, fun)
19
+ #define CALL(fun) RUCY_WRAPPER_CALL(Reflex::Application, THIS, fun)
36
20
 
37
21
 
38
22
  static
39
- RUBY_DEF_ALLOC(alloc, klass)
23
+ RUCY_DEF_ALLOC(alloc, klass)
40
24
  {
41
- return value(new RubyApplication, klass);
25
+ return value(new Reflex::RubyApplication<Reflex::Application>, klass);
42
26
  }
43
- RUBY_END
27
+ RUCY_END
44
28
 
45
29
  static
46
- RUBY_DEF0(run)
30
+ RUCY_DEF0(start)
47
31
  {
48
32
  CHECK;
49
- if (!CALL(run()))
50
- system_error("failed to run application.");
33
+ CALL(start());
51
34
  return self;
52
35
  }
53
- RUBY_END
36
+ RUCY_END
54
37
 
55
38
  static
56
- RUBY_DEF0(quit)
39
+ RUCY_DEF0(quit)
57
40
  {
58
41
  CHECK;
59
- if (!CALL(quit()))
60
- system_error("failed to quit application.");
42
+ CALL(quit());
61
43
  return self;
62
44
  }
63
- RUBY_END
45
+ RUCY_END
64
46
 
65
47
  static
66
- RUBY_DEF0(about)
48
+ RUCY_DEF1(set_name, name)
67
49
  {
68
50
  CHECK;
69
- if (!CALL(about()))
70
- system_error("failed to show about application.");
71
- return self;
51
+ THIS->set_name(name.c_str());
52
+ return name;
72
53
  }
73
- RUBY_END
54
+ RUCY_END
74
55
 
75
56
  static
76
- RUBY_DEF1(set_name, name)
57
+ RUCY_DEF0(get_name)
77
58
  {
78
59
  CHECK;
79
- if (!THIS->set_name(name.c_str()))
80
- system_error("failed to set name of application.");
81
- return name;
60
+ return value(THIS->name());
61
+ }
62
+ RUCY_END
63
+
64
+ static
65
+ RUCY_DEF1(on_start, event)
66
+ {
67
+ CHECK;
68
+ CALL(on_start(to<Reflex::Event*>(event)));
82
69
  }
83
- RUBY_END
70
+ RUCY_END
84
71
 
85
72
  static
86
- RUBY_DEF0(get_name)
73
+ RUCY_DEF1(on_quit, event)
87
74
  {
88
75
  CHECK;
89
- const char* s = THIS->name();
90
- if (!s) system_error("failed to get name of application.");
91
- return value(s);
76
+ CALL(on_quit(to<Reflex::Event*>(event)));
92
77
  }
93
- RUBY_END
78
+ RUCY_END
94
79
 
95
80
  static
96
- RUBY_DEF0(instance)
81
+ RUCY_DEF1(on_preference, event)
82
+ {
83
+ CHECK;
84
+ CALL(on_preference(to<Reflex::Event*>(event)));
85
+ }
86
+ RUCY_END
87
+
88
+ static
89
+ RUCY_DEF1(on_about, event)
90
+ {
91
+ CHECK;
92
+ CALL(on_about(to<Reflex::Event*>(event)));
93
+ }
94
+ RUCY_END
95
+
96
+ static
97
+ RUCY_DEF0(instance)
97
98
  {
98
99
  return value(Reflex::app());
99
100
  }
100
- RUBY_END
101
+ RUCY_END
101
102
 
102
103
 
103
104
  void
@@ -107,10 +108,27 @@ Init_application ()
107
108
 
108
109
  cApplication = mReflex.define_class("Application");
109
110
  cApplication.define_alloc_func(alloc);
110
- cApplication.define_method("run", run);
111
+ cApplication.define_method("start", start);
111
112
  cApplication.define_method("quit", quit);
112
- cApplication.define_method("about", about);
113
113
  cApplication.define_method("name=", set_name);
114
114
  cApplication.define_method("name", get_name);
115
+ cApplication.define_method("on_start", on_start);
116
+ cApplication.define_method("on_quit", on_quit);
117
+ cApplication.define_method("on_preference", on_preference);
118
+ cApplication.define_method("on_about", on_about);
115
119
  cApplication.define_singleton_method("instance", instance);
116
120
  }
121
+
122
+
123
+ namespace Reflex
124
+ {
125
+
126
+
127
+ Class
128
+ application_class ()
129
+ {
130
+ return cApplication;
131
+ }
132
+
133
+
134
+ }// Reflex