reflexion 0.1.6 → 0.1.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.
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
@@ -1,9 +1,13 @@
1
1
  #include "reflex/ruby/view.h"
2
2
 
3
3
 
4
+ #include <vector>
4
5
  #include <rucy.h>
5
- #include <reflex/ruby/window.h>
6
- #include "defs.h"
6
+ #include <rays/ruby/point.h>
7
+ #include <rays/ruby/bounds.h>
8
+ #include "reflex/ruby/window.h"
9
+ #include "reflex/ruby/selector.h"
10
+ #include "reflex/ruby/style.h"
7
11
 
8
12
 
9
13
  using namespace Rucy;
@@ -13,43 +17,36 @@ using Reflex::coord;
13
17
 
14
18
  static Class cView;
15
19
 
20
+ RUCY_DEFINE_WRAPPER_VALUE_FROM_TO(Reflex::View, cView)
16
21
 
17
- namespace Reflex
18
- {
19
-
20
-
21
- Class
22
- view_class ()
23
- {
24
- return cView;
25
- }
26
-
27
-
28
- }// Reflex
29
-
22
+ #define THIS to<Reflex::View*>(self)
30
23
 
31
- typedef Reflex::RubyView<Reflex::View> RubyView;
24
+ #define CHECK RUCY_CHECK_OBJECT(Reflex::View, cView, self)
32
25
 
26
+ #define CALL(fun) RUCY_WRAPPER_CALL(Reflex::View, THIS, fun)
33
27
 
34
- #define THIS to<Reflex::View*>(self)
35
28
 
36
- #define CHECK RUCY_CHECK_OBJECT(self, Reflex::View, cView)
37
-
38
- #define CALL(fun) RUCY_WRAPPER_CALL(RubyView, THIS, fun)
29
+ template <typename T>
30
+ static inline Value
31
+ array (T begin, T end)
32
+ {
33
+ std::vector<Value> v;
34
+ for (T it = begin; it != end; ++it) v.push_back(value(*it));
35
+ return value(v.size(), &v[0]);
36
+ }
39
37
 
40
38
 
41
39
  static
42
40
  VALUE alloc(VALUE klass)
43
41
  {
44
- return value(new RubyView, klass);
42
+ return value(new Reflex::RubyView<Reflex::View>, klass);
45
43
  }
46
44
 
47
45
  static
48
46
  VALUE show(VALUE self)
49
47
  {
50
48
  CHECK;
51
- if (!CALL(show()))
52
- reflex_error("failed to show view.");
49
+ CALL(show());
53
50
  return self;
54
51
  }
55
52
 
@@ -57,17 +54,22 @@ static
57
54
  VALUE hide(VALUE self)
58
55
  {
59
56
  CHECK;
60
- if (!CALL(hide()))
61
- reflex_error("failed to hide view.");
57
+ CALL(hide());
62
58
  return self;
63
59
  }
64
60
 
61
+ static
62
+ VALUE hidden(VALUE self)
63
+ {
64
+ CHECK;
65
+ return value(THIS->hidden());
66
+ }
67
+
65
68
  static
66
69
  VALUE redraw(VALUE self)
67
70
  {
68
71
  CHECK;
69
- if (!THIS->redraw())
70
- reflex_error("failed to redraw view.");
72
+ THIS->redraw();
71
73
  return self;
72
74
  }
73
75
 
@@ -75,145 +77,409 @@ static
75
77
  VALUE add_child(VALUE self, VALUE child)
76
78
  {
77
79
  CHECK;
80
+ THIS->add_child(to<Reflex::View*>(child));
81
+ return child;
82
+ }
83
+
84
+ static
85
+ VALUE remove_child(VALUE self, VALUE child)
86
+ {
87
+ CHECK;
88
+ THIS->remove_child(to<Reflex::View*>(child));
89
+ return child;
90
+ }
78
91
 
79
- Reflex::View* c = to<Reflex::View*>(child);
80
- if (!c) argument_error();
92
+ static
93
+ VALUE find_children(VALUE self)
94
+ {
95
+ CHECK;
96
+ check_arg_count(__FILE__, __LINE__, "View#find_children", argc, 1, 2);
81
97
 
82
- if (!THIS->add_child(c))
83
- reflex_error("failed to add child view.");
98
+ bool recursive = (argc >= 2) ? to<bool>(argv[1]) : false;
84
99
 
85
- return self;
100
+ Reflex::View::ChildList children;
101
+ THIS->find_children(&children, to<Reflex::Selector>(argv[0]), recursive);
102
+ return array(children.begin(), children.end());
86
103
  }
87
104
 
88
105
  static
89
- VALUE remove_child(VALUE self, VALUE child)
106
+ VALUE each_child(VALUE self)
90
107
  {
91
108
  CHECK;
92
109
 
93
- Reflex::View* c = to<Reflex::View*>(child);
94
- if (!c) argument_error();
110
+ Value ret;
111
+ Reflex::View::child_iterator end = THIS->child_end();
112
+ for (Reflex::View::child_iterator it = THIS->child_begin(); it != end; ++it)
113
+ ret = rb_yield(value(it->get()));
114
+ return ret;
115
+ }
116
+
117
+ static
118
+ VALUE add_style(VALUE self, VALUE style)
119
+ {
120
+ CHECK;
121
+ THIS->add_style(to<Reflex::Style&>(style));
122
+ return style;
123
+ }
124
+
125
+ static
126
+ VALUE remove_style(VALUE self, VALUE style)
127
+ {
128
+ CHECK;
129
+ THIS->remove_style(to<Reflex::Style&>(style));
130
+ return style;
131
+ }
132
+
133
+ static
134
+ VALUE get_style(VALUE self)
135
+ {
136
+ CHECK;
137
+ check_arg_count(__FILE__, __LINE__, "View#get_style", argc, 0, 1);
138
+
139
+ if (argc == 0)
140
+ return value(THIS->style());
141
+ else
142
+ return value(THIS->get_style(to<Reflex::Selector>(argv[0])));
143
+ }
144
+
145
+ static
146
+ VALUE find_styles(VALUE self)
147
+ {
148
+ CHECK;
149
+ check_arg_count(__FILE__, __LINE__, "View#find_styles", argc, 1, 2);
95
150
 
96
- if (!THIS->remove_child(c))
97
- reflex_error("failed to remove child view.");
151
+ bool recursive = (argc >= 2) ? to<bool>(argv[1]) : false;
98
152
 
153
+ Reflex::View::StyleList styles;
154
+ THIS->find_styles(&styles, to<Reflex::Selector>(argv[0]), recursive);
155
+ return array(styles.begin(), styles.end());
156
+ }
157
+
158
+ static
159
+ VALUE each_style(VALUE self)
160
+ {
161
+ CHECK;
162
+
163
+ Value ret;
164
+ Reflex::View::style_iterator end = THIS->style_end();
165
+ for (Reflex::View::style_iterator it = THIS->style_begin(); it != end; ++it)
166
+ ret = rb_yield(value(*it));
167
+ return ret;
168
+ }
169
+
170
+ static
171
+ VALUE focus(VALUE self)
172
+ {
173
+ CHECK;
174
+ check_arg_count(__FILE__, __LINE__, "View#focus", argc, 0, 1);
175
+
176
+ bool state = (argc >= 1) ? to<bool>(argv[0]) : true;
177
+
178
+ THIS->focus(state);
99
179
  return self;
100
180
  }
101
181
 
102
182
  static
103
- VALUE find_child(VALUE self)
183
+ VALUE blur(VALUE self)
104
184
  {
105
185
  CHECK;
106
- if (argc < 1 || 3 < argc)
107
- arg_count_error("View#find_child", argc, 1, 2, 3);
186
+ THIS->blur();
187
+ return self;
188
+ }
108
189
 
109
- const char* name = to<const char*>(argv[0]);
110
- size_t index = (argc >= 2) ? to<size_t>(argv[1]) : 0;
111
- bool recursive = (argc >= 3) ? to<bool>(argv[2]) : false;
190
+ static
191
+ VALUE has_focus(VALUE self)
192
+ {
193
+ CHECK;
194
+ return value(THIS->has_focus());
195
+ }
112
196
 
113
- Reflex::View* c = THIS->find_child(name, index, recursive);
114
- if (!c) return Qnil;
197
+ static
198
+ VALUE resize_to_fit(VALUE self)
199
+ {
200
+ CHECK;
201
+ THIS->resize_to_fit();
202
+ return self;
203
+ }
115
204
 
116
- return value(c);
205
+ static
206
+ VALUE content_size(VALUE self)
207
+ {
208
+ CHECK;
209
+ return value(THIS->content_size());
117
210
  }
118
211
 
119
212
  static
120
213
  VALUE set_name(VALUE self, VALUE name)
121
214
  {
122
215
  CHECK;
123
- if (!THIS->set_name(name.c_str()))
124
- reflex_error("failed to set the name of view.");
125
- return name;
216
+ THIS->set_name(name.is_nil() ? NULL : name.c_str());
126
217
  }
127
218
 
128
219
  static
129
220
  VALUE get_name(VALUE self)
130
221
  {
131
222
  CHECK;
132
- const char* s = THIS->name();
133
- if (!s) reflex_error("failed to get name of view.");
134
- return value(s);
223
+ return THIS->name() ? value(THIS->name()) : nil();
135
224
  }
136
225
 
137
226
  static
138
- VALUE set_bounds(VALUE self, VALUE x, VALUE y, VALUE width, VALUE height)
227
+ VALUE add_tag(VALUE self, VALUE tag)
139
228
  {
140
229
  CHECK;
141
- if (!THIS->set_bounds(
142
- to<coord>(x), to<coord>(y), to<coord>(width), to<coord>(height)))
230
+ THIS->add_tag(tag.c_str());
231
+ }
232
+
233
+ static
234
+ VALUE remove_tag(VALUE self, VALUE tag)
235
+ {
236
+ CHECK;
237
+ THIS->remove_tag(tag.c_str());
238
+ }
239
+
240
+ static
241
+ VALUE each_tag(VALUE self)
242
+ {
243
+ CHECK;
244
+
245
+ Value ret;
246
+ Reflex::View::tag_iterator end = THIS->tag_end();
247
+ for (Reflex::View::tag_iterator it = THIS->tag_begin(); it != end; ++it)
248
+ ret = rb_yield(value(*it));
249
+ return ret;
250
+ }
251
+
252
+ static
253
+ VALUE set_selector(VALUE self, VALUE selector)
254
+ {
255
+ CHECK;
256
+ THIS->set_selector(to<Reflex::Selector>(selector));
257
+ }
258
+
259
+ static
260
+ VALUE get_selector(VALUE self)
261
+ {
262
+ CHECK;
263
+ return value(THIS->selector());
264
+ }
265
+
266
+ static
267
+ VALUE set_frame(VALUE self, VALUE arg)
268
+ {
269
+ CHECK;
270
+ THIS->set_frame(to<Rays::Bounds>(arg));
271
+ }
272
+
273
+ static
274
+ VALUE get_frame(VALUE self)
275
+ {
276
+ CHECK;
277
+ return value(THIS->frame());
278
+ }
279
+
280
+ static
281
+ VALUE set_capture(VALUE self, VALUE types)
282
+ {
283
+ CHECK;
284
+ THIS->set_capture(to<uint>(types));
285
+ }
286
+
287
+ static
288
+ VALUE get_capture(VALUE self)
289
+ {
290
+ CHECK;
291
+ return value(THIS->capture());
292
+ }
293
+
294
+ static
295
+ VALUE scroll_to(VALUE self)
296
+ {
297
+ CHECK;
298
+ check_arg_count(__FILE__, __LINE__, "View#scroll_to", argc, 1, 2, 3);
299
+
300
+ if (argv[0].is_kind_of(Rays::point_class()))
301
+ THIS->scroll_to(to<Rays::Point&>(argv[0]));
302
+ else
143
303
  {
144
- reflex_error("failed to set the bounds of view.");
304
+ const Rays::Point& p = THIS->scroll();
305
+ coord x = (argc >= 1 && argv[0]) ? to<coord>(argv[0]) : p.x;
306
+ coord y = (argc >= 2 && argv[1]) ? to<coord>(argv[1]) : p.y;
307
+ coord z = (argc >= 3 && argv[2]) ? to<coord>(argv[2]) : p.z;
308
+ THIS->scroll_to(x, y, z);
145
309
  }
146
- return value(THIS->bounds());
310
+
311
+ return self;
147
312
  }
148
313
 
149
314
  static
150
- VALUE get_bounds(VALUE self)
315
+ VALUE scroll_by(VALUE self)
151
316
  {
152
317
  CHECK;
153
- return value(THIS->bounds());
318
+ check_arg_count(__FILE__, __LINE__, "View#scroll_by", argc, 1, 2, 3);
319
+
320
+ if (argv[0].is_kind_of(Rays::point_class()))
321
+ THIS->scroll_by(to<Rays::Point&>(argv[0]));
322
+ else
323
+ {
324
+ coord x = (argc >= 1 && argv[0]) ? to<coord>(argv[0]) : 0;
325
+ coord y = (argc >= 2 && argv[1]) ? to<coord>(argv[1]) : 0;
326
+ coord z = (argc >= 3 && argv[2]) ? to<coord>(argv[2]) : 0;
327
+ THIS->scroll_by(x, y, z);
328
+ }
329
+
330
+ return self;
154
331
  }
155
332
 
156
333
  static
157
- VALUE hidden(VALUE self)
334
+ VALUE get_scroll(VALUE self)
158
335
  {
159
336
  CHECK;
160
- return value(THIS->hidden());
337
+ return value(THIS->scroll());
161
338
  }
162
339
 
163
340
  static
164
341
  VALUE parent(VALUE self)
165
342
  {
166
343
  CHECK;
344
+ return value(THIS->parent());
345
+ }
167
346
 
168
- Reflex::View* v = THIS->parent();
169
- if (!v) return Qnil;
347
+ static
348
+ VALUE window(VALUE self)
349
+ {
350
+ CHECK;
351
+ return value(THIS->window());
352
+ }
170
353
 
171
- return value(v);
354
+ static
355
+ VALUE on_attach(VALUE self, VALUE event)
356
+ {
357
+ CHECK;
358
+ CALL(on_attach(to<Reflex::Event*>(event)));
172
359
  }
173
360
 
174
361
  static
175
- VALUE window(VALUE self)
362
+ VALUE on_detach(VALUE self, VALUE event)
176
363
  {
177
364
  CHECK;
365
+ CALL(on_detach(to<Reflex::Event*>(event)));
366
+ }
178
367
 
179
- Reflex::Window* w = THIS->window();
180
- if (!w) return Qnil;
368
+ static
369
+ VALUE on_update(VALUE self, VALUE event)
370
+ {
371
+ CHECK;
372
+ CALL(on_update(to<Reflex::UpdateEvent*>(event)));
373
+ }
374
+
375
+ static
376
+ VALUE on_draw(VALUE self, VALUE event)
377
+ {
378
+ CHECK;
379
+ CALL(on_draw(to<Reflex::DrawEvent*>(event)));
380
+ }
181
381
 
182
- return value(w);
382
+ static
383
+ VALUE on_move(VALUE self, VALUE event)
384
+ {
385
+ CHECK;
386
+ CALL(on_move(to<Reflex::FrameEvent*>(event)));
183
387
  }
184
388
 
185
389
  static
186
- VALUE update(VALUE self, VALUE dt)
390
+ VALUE on_resize(VALUE self, VALUE event)
187
391
  {
188
392
  CHECK;
189
- CALL(update(to<float>(dt)));
190
- return self;
393
+ CALL(on_resize(to<Reflex::FrameEvent*>(event)));
191
394
  }
192
395
 
193
396
  static
194
- VALUE draw(VALUE self, VALUE painter, VALUE bounds)
397
+ VALUE on_scroll(VALUE self, VALUE event)
195
398
  {
196
399
  CHECK;
197
- CALL(draw(to<Rays::Painter*>(painter), *to<Rays::Bounds*>(bounds)));
198
- return self;
400
+ CALL(on_scroll(to<Reflex::ScrollEvent*>(event)));
199
401
  }
200
402
 
201
403
  static
202
- VALUE moved(VALUE self, VALUE dx, VALUE dy)
404
+ VALUE on_focus(VALUE self, VALUE event)
203
405
  {
204
406
  CHECK;
205
- CALL(moved(to<coord>(dx), to<coord>(dy)));
206
- return self;
407
+ CALL(on_focus(to<Reflex::FocusEvent*>(event)));
207
408
  }
208
409
 
209
410
  static
210
- VALUE resized(VALUE self, VALUE dwidth, VALUE dheight)
411
+ VALUE on_blur(VALUE self, VALUE event)
211
412
  {
212
413
  CHECK;
213
- CALL(resized(to<coord>(dwidth), to<coord>(dheight)));
214
- return self;
414
+ CALL(on_blur(to<Reflex::FocusEvent*>(event)));
415
+ }
416
+
417
+ static
418
+ VALUE on_key(VALUE self, VALUE event)
419
+ {
420
+ CHECK;
421
+ CALL(on_key(to<Reflex::KeyEvent*>(event)));
422
+ }
423
+
424
+ static
425
+ VALUE on_key_down(VALUE self, VALUE event)
426
+ {
427
+ CHECK;
428
+ CALL(on_key_down(to<Reflex::KeyEvent*>(event)));
215
429
  }
216
430
 
431
+ static
432
+ VALUE on_key_up(VALUE self, VALUE event)
433
+ {
434
+ CHECK;
435
+ CALL(on_key_up(to<Reflex::KeyEvent*>(event)));
436
+ }
437
+
438
+ static
439
+ VALUE on_pointer(VALUE self, VALUE event)
440
+ {
441
+ CHECK;
442
+ CALL(on_pointer(to<Reflex::PointerEvent*>(event)));
443
+ }
444
+
445
+ static
446
+ VALUE on_pointer_down(VALUE self, VALUE event)
447
+ {
448
+ CHECK;
449
+ CALL(on_pointer_down(to<Reflex::PointerEvent*>(event)));
450
+ }
451
+
452
+ static
453
+ VALUE on_pointer_up(VALUE self, VALUE event)
454
+ {
455
+ CHECK;
456
+ CALL(on_pointer_up(to<Reflex::PointerEvent*>(event)));
457
+ }
458
+
459
+ static
460
+ VALUE on_pointer_move(VALUE self, VALUE event)
461
+ {
462
+ CHECK;
463
+ CALL(on_pointer_move(to<Reflex::PointerEvent*>(event)));
464
+ }
465
+
466
+ static
467
+ VALUE on_wheel(VALUE self, VALUE event)
468
+ {
469
+ CHECK;
470
+ CALL(on_wheel(to<Reflex::WheelEvent*>(event)));
471
+ }
472
+
473
+ static
474
+ VALUE on_capture(VALUE self, VALUE event)
475
+ {
476
+ CHECK;
477
+ CALL(on_capture(to<Reflex::CaptureEvent*>(event)));
478
+ }
479
+
480
+ static
481
+ RUCY_DEF_clear_override_flags(cof, Reflex::View, cView);
482
+
217
483
 
218
484
  void
219
485
  Init_view ()
@@ -224,19 +490,73 @@ Init_view ()
224
490
  rb_define_alloc_func(cView, alloc);
225
491
  rb_define_method(cView, "show", RUBY_METHOD_FUNC(show), 0);
226
492
  rb_define_method(cView, "hide", RUBY_METHOD_FUNC(hide), 0);
493
+ cView.define_method("hidden?", hidden);
227
494
  rb_define_method(cView, "redraw", RUBY_METHOD_FUNC(redraw), 0);
228
495
  rb_define_method(cView, "add_child", RUBY_METHOD_FUNC(add_child), 1);
229
496
  rb_define_method(cView, "remove_child", RUBY_METHOD_FUNC(remove_child), 1);
230
- rb_define_method(cView, "find_child", RUBY_METHOD_FUNC(find_child), -1);
497
+ rb_define_method(cView, "find_children", RUBY_METHOD_FUNC(find_children), -1);
498
+ rb_define_method(cView, "each_child", RUBY_METHOD_FUNC(each_child), 0);
499
+ rb_define_method(cView, "add_style", RUBY_METHOD_FUNC(add_style), 1);
500
+ rb_define_method(cView, "remove_style", RUBY_METHOD_FUNC(remove_style), 1);
501
+ rb_define_method(cView, "get_style", RUBY_METHOD_FUNC(get_style), -1);
502
+ rb_define_method(cView, "find_styles", RUBY_METHOD_FUNC(find_styles), -1);
503
+ rb_define_method(cView, "each_style", RUBY_METHOD_FUNC(each_style), 0);
504
+ rb_define_method(cView, "focus", RUBY_METHOD_FUNC(focus), -1);
505
+ rb_define_method(cView, "blur", RUBY_METHOD_FUNC(blur), 0);
506
+ cView.define_method("focus?", has_focus);
507
+ rb_define_method(cView, "resize_to_fit", RUBY_METHOD_FUNC(resize_to_fit), 0);
508
+ rb_define_method(cView, "content_size", RUBY_METHOD_FUNC(content_size), 0);
231
509
  rb_define_method(cView, "name=", RUBY_METHOD_FUNC(set_name), 1);
232
510
  rb_define_method(cView, "name", RUBY_METHOD_FUNC(get_name), 0);
233
- rb_define_private_method(cView, "set_bounds", RUBY_METHOD_FUNC(set_bounds), 4);
234
- rb_define_private_method(cView, "get_bounds", RUBY_METHOD_FUNC(get_bounds), 0);
235
- rb_define_method(cView, "hidden", RUBY_METHOD_FUNC(hidden), 0);
511
+ rb_define_method(cView, "add_tag", RUBY_METHOD_FUNC(add_tag), 1);
512
+ rb_define_method(cView, "remove_tag", RUBY_METHOD_FUNC(remove_tag), 1);
513
+ rb_define_method(cView, "each_tag", RUBY_METHOD_FUNC(each_tag), 0);
514
+ rb_define_method(cView, "selector=", RUBY_METHOD_FUNC(set_selector), 1);
515
+ rb_define_method(cView, "selector", RUBY_METHOD_FUNC(get_selector), 0);
516
+ rb_define_private_method(cView, "set_frame", RUBY_METHOD_FUNC(set_frame), 1);
517
+ rb_define_private_method(cView, "get_frame", RUBY_METHOD_FUNC(get_frame), 0);
518
+ rb_define_method(cView, "scroll_to", RUBY_METHOD_FUNC(scroll_to), -1);
519
+ rb_define_method(cView, "scroll_by", RUBY_METHOD_FUNC(scroll_by), -1);
520
+ rb_define_method(cView, "scroll", RUBY_METHOD_FUNC(get_scroll), 0);
521
+ rb_define_method(cView, "set_capture", RUBY_METHOD_FUNC(set_capture), 1);
522
+ rb_define_method(cView, "get_capture", RUBY_METHOD_FUNC(get_capture), 0);
236
523
  rb_define_method(cView, "parent", RUBY_METHOD_FUNC(parent), 0);
237
524
  rb_define_method(cView, "window", RUBY_METHOD_FUNC(window), 0);
238
- rb_define_method(cView, "update", RUBY_METHOD_FUNC(update), 1);
239
- rb_define_method(cView, "draw", RUBY_METHOD_FUNC(draw), 2);
240
- rb_define_method(cView, "moved", RUBY_METHOD_FUNC(moved), 2);
241
- rb_define_method(cView, "resized", RUBY_METHOD_FUNC(resized), 2);
525
+ rb_define_method(cView, "on_attach", RUBY_METHOD_FUNC(on_attach), 1);
526
+ rb_define_method(cView, "on_detach", RUBY_METHOD_FUNC(on_detach), 1);
527
+ rb_define_method(cView, "on_update", RUBY_METHOD_FUNC(on_update), 1);
528
+ rb_define_method(cView, "on_draw", RUBY_METHOD_FUNC(on_draw), 1);
529
+ rb_define_method(cView, "on_move", RUBY_METHOD_FUNC(on_move), 1);
530
+ rb_define_method(cView, "on_resize", RUBY_METHOD_FUNC(on_resize), 1);
531
+ rb_define_method(cView, "on_scroll", RUBY_METHOD_FUNC(on_scroll), 1);
532
+ rb_define_method(cView, "on_focus", RUBY_METHOD_FUNC(on_focus), 1);
533
+ rb_define_method(cView, "on_blur", RUBY_METHOD_FUNC(on_blur), 1);
534
+ rb_define_method(cView, "on_key", RUBY_METHOD_FUNC(on_key), 1);
535
+ rb_define_method(cView, "on_key_down", RUBY_METHOD_FUNC(on_key_down), 1);
536
+ rb_define_method(cView, "on_key_up", RUBY_METHOD_FUNC(on_key_up), 1);
537
+ rb_define_method(cView, "on_pointer", RUBY_METHOD_FUNC(on_pointer), 1);
538
+ rb_define_method(cView, "on_pointer_down", RUBY_METHOD_FUNC(on_pointer_down), 1);
539
+ rb_define_method(cView, "on_pointer_up", RUBY_METHOD_FUNC(on_pointer_up), 1);
540
+ rb_define_method(cView, "on_pointer_move", RUBY_METHOD_FUNC(on_pointer_move), 1);
541
+ rb_define_method(cView, "on_wheel", RUBY_METHOD_FUNC(on_wheel), 1);
542
+ rb_define_method(cView, "on_capture", RUBY_METHOD_FUNC(on_capture), 1);
543
+ cView.define_const("CAPTURE_NONE", Reflex::View::CAPTURE_NONE);
544
+ cView.define_const("CAPTURE_KEY", Reflex::View::CAPTURE_KEY);
545
+ cView.define_const("CAPTURE_POINTER", Reflex::View::CAPTURE_POINTER);
546
+ cView.define_const("CAPTURE_ALL", Reflex::View::CAPTURE_ALL);
547
+
242
548
  }
549
+
550
+
551
+ namespace Reflex
552
+ {
553
+
554
+
555
+ Class
556
+ view_class ()
557
+ {
558
+ return cView;
559
+ }
560
+
561
+
562
+ }// Reflex