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,151 +0,0 @@
1
- #include "reflex/ruby/points.h"
2
-
3
-
4
- #include <rucy.h>
5
- #include "defs.h"
6
-
7
-
8
- using namespace Rucy;
9
-
10
- using Reflex::coord;
11
-
12
-
13
- static Class cPoints;
14
-
15
-
16
- namespace Reflex
17
- {
18
-
19
-
20
- Class
21
- points_class ()
22
- {
23
- return cPoints;
24
- }
25
-
26
-
27
- }// Reflex
28
-
29
-
30
- namespace Rucy
31
- {
32
-
33
-
34
- Value
35
- value (const Reflex::Points& points)
36
- {
37
- return new_type(cPoints, new Reflex::Points(points));
38
- }
39
-
40
-
41
- }// Rucy
42
-
43
-
44
- #define THIS to<Reflex::Points*>(self)
45
-
46
- #define CHECK RUCY_CHECK_OBJ(self, Reflex::Points, cPoints)
47
-
48
-
49
- static
50
- VALUE alloc(VALUE klass)
51
- {
52
- return new_type<Reflex::Points>(klass);
53
- }
54
-
55
- static
56
- VALUE initialize(VALUE self)
57
- {
58
- RUCY_CHECK_OBJ(self, Reflex::Points, cPoints);
59
- if (argc < 0 || 6 < argc)
60
- arg_count_error("Points#initialize", argc, 0, 1, 2, 3, 4, 5, 6);
61
-
62
- THIS->type = (argc >= 1) ? to<int>(argv[0]) : Reflex::POINT_NONE;
63
- THIS->x = (argc >= 2) ? to<coord>(argv[1]) : 0;
64
- THIS->y = (argc >= 3) ? to<coord>(argv[2]) : 0;
65
- THIS->size = 1;
66
- THIS->modifiers = (argc >= 4) ? to<uint>(argv[3]) : (uint) Reflex::MOD_NONE;
67
- THIS->count = (argc >= 5) ? to<uint>(argv[4]) : 0;
68
- THIS->drag = (argc >= 6) ? to<bool>(argv[5]) : false;
69
-
70
- return self;
71
- }
72
-
73
- static
74
- VALUE initialize_copy(VALUE self, VALUE obj)
75
- {
76
- RUCY_CHECK_OBJ(self, Reflex::Points, cPoints);
77
-
78
- Reflex::Points* points = to<Reflex::Points*>(obj);
79
- if (!points) argument_error();
80
-
81
- *THIS = *points;
82
- return self;
83
- }
84
-
85
- static
86
- VALUE type(VALUE self)
87
- {
88
- CHECK;
89
- return value(THIS->type);
90
- }
91
-
92
- static
93
- VALUE x(VALUE self)
94
- {
95
- CHECK;
96
- return value(THIS->x);
97
- }
98
-
99
- static
100
- VALUE y(VALUE self)
101
- {
102
- CHECK;
103
- return value(THIS->y);
104
- }
105
-
106
- static
107
- VALUE size(VALUE self)
108
- {
109
- CHECK;
110
- return value(THIS->size);
111
- }
112
-
113
- static
114
- VALUE modifiers(VALUE self)
115
- {
116
- CHECK;
117
- return value(THIS->modifiers);
118
- }
119
-
120
- static
121
- VALUE count(VALUE self)
122
- {
123
- CHECK;
124
- return value(THIS->count);
125
- }
126
-
127
- static
128
- VALUE drag(VALUE self)
129
- {
130
- CHECK;
131
- return value(THIS->drag);
132
- }
133
-
134
-
135
- void
136
- Init_points ()
137
- {
138
- Module mReflex = rb_define_module("Reflex");
139
-
140
- cPoints = rb_define_class_under(mReflex, "Points", rb_cObject);
141
- rb_define_alloc_func(cPoints, alloc);
142
- rb_define_private_method(cPoints, "initialize", RUBY_METHOD_FUNC(initialize), -1);
143
- rb_define_private_method(cPoints, "initialize_copy", RUBY_METHOD_FUNC(initialize_copy), 1);
144
- rb_define_method(cPoints, "type", RUBY_METHOD_FUNC(type), 0);
145
- rb_define_method(cPoints, "x", RUBY_METHOD_FUNC(x), 0);
146
- rb_define_method(cPoints, "y", RUBY_METHOD_FUNC(y), 0);
147
- rb_define_method(cPoints, "size", RUBY_METHOD_FUNC(size), 0);
148
- rb_define_method(cPoints, "modifiers", RUBY_METHOD_FUNC(modifiers), 0);
149
- rb_define_method(cPoints, "count", RUBY_METHOD_FUNC(count), 0);
150
- rb_define_method(cPoints, "drag", RUBY_METHOD_FUNC(drag), 0);
151
- }
data/.gitignore DELETED
@@ -1,14 +0,0 @@
1
- *.o
2
- *.so
3
- *.bundle
4
- *.dll.a
5
- *.gem
6
- *.log
7
- *.rdoc.cpp
8
- *~
9
- lib/*.a
10
- .doc
11
- .yardoc
12
- .DS_Store
13
- Makefile
14
- depend.mf
data/ChangeLog DELETED
@@ -1,8 +0,0 @@
1
- 2011-08-28 snori <snori@xord.org>
2
-
3
- * v0.1.1
4
-
5
-
6
- 2011-06-03 snori <snori@xord.org>
7
-
8
- * delete Gemfile.
@@ -1,2 +0,0 @@
1
- hello
2
- hello.exe
@@ -1,41 +0,0 @@
1
- # -*- mode: ruby; coding: utf-8 -*-
2
- %w[../../../rucy/lib ../../../rays/lib ../../lib].each do |path|
3
- $: << File.expand_path(File.join File.dirname(__FILE__), *path.split('/'))
4
- end
5
- require 'rubygems'
6
- require 'reflex/reflex'
7
-
8
-
9
- OUT = 'hello'
10
- SRCS = Dir.glob('*.cpp')
11
-
12
- REFLEX = Reflex.name.downcase
13
- LIBREFLEX = File.join(Reflex.library_dirs[0], "lib#{REFLEX}.a")
14
-
15
- INCDIRS = %w[/opt/local/include /opt/include] + Reflex.include_dirs
16
- LIBDIRS = %w[] + Reflex.library_dirs
17
-
18
- LIBS = %w[stdc++ objc] + [REFLEX]
19
- FRAMEWORKS = %w[Cocoa]
20
-
21
- CFLAGS = INCDIRS.map{|s| "-I#{s}"}.join(' ')
22
- LDFLAGS = (
23
- LIBDIRS.map {|s| "-L#{s}"} +
24
- LIBS.map {|s| "-l#{s}"} +
25
- FRAMEWORKS.map {|s| "-framework #{s}"}
26
- ).join(' ')
27
-
28
-
29
- task :default => :run
30
-
31
- task :run => OUT do
32
- sh %( ./#{OUT} )
33
- end
34
-
35
- file OUT => [LIBREFLEX] + SRCS do
36
- sh %( gcc -o #{OUT} #{CFLAGS} #{LDFLAGS} #{SRCS.join ' '} )
37
- end
38
-
39
- task LIBREFLEX do
40
- sh %( cd #{Reflex.root_dir} && rake )
41
- end
@@ -1,18 +0,0 @@
1
- #include <reflex.h>
2
-
3
-
4
- using namespace Reflex;
5
-
6
-
7
- int
8
- main (int argc, char** argv)
9
- {
10
- init();
11
- Window win;
12
- win.set_title("Reflex Test Window");
13
- win.set_bounds(100, 100, 600, 500);
14
- win.show();
15
- run();
16
- fin();
17
- return EXIT_SUCCESS;
18
- }
data/examples/ruby/app.rb DELETED
@@ -1,13 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
-
3
-
4
- %w[xot rays reflex].product(%w[ext lib]).each do |paths|
5
- $: << File.expand_path(
6
- File.join File.dirname(__FILE__), *%w[.. .. ..], *paths)
7
- end
8
-
9
- require 'reflex'
10
-
11
-
12
- Reflex::Window.new(:bounds => [100, 100, 500, 500]).show
13
- Reflex.run "AppName"
@@ -1,41 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
-
3
-
4
- %w[xot rays reflex].product(%w[ext lib]).each do |paths|
5
- $: << File.expand_path(
6
- File.join File.dirname(__FILE__), *%w[.. .. ..], *paths)
7
- end
8
-
9
- require 'rubygems'
10
- require 'reflex'
11
-
12
-
13
- class CheckerWindow < Reflex::Window
14
-
15
- def initialize ()
16
- super
17
- set :title, "Hello Reflex!"
18
- set :bounds, 100, 100, 320, 240
19
- painter.font = Rays::Font.new nil, 32
20
- painter.background = 1
21
- end
22
-
23
- def draw ()
24
- count = 16
25
- size = 10
26
- paint do |p|
27
- count.times do |x|
28
- count.times do |y|
29
- next if (x + y) % 2 == 0
30
- p.fill = x.to_f / count, y.to_f / count, 1
31
- p.rect x * size, y * size, size - 1, size - 1
32
- end
33
- end
34
- end
35
- end
36
-
37
- end# CheckerWindow
38
-
39
-
40
- CheckerWindow.new.show
41
- Reflex.run
data/examples/ruby/fps.rb DELETED
@@ -1,49 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
-
3
-
4
- %w[xot rays reflex].product(%w[ext lib]).each do |paths|
5
- $: << File.expand_path(
6
- File.join File.dirname(__FILE__), *%w[.. .. ..], *paths)
7
- end
8
-
9
- require 'reflex'
10
-
11
-
12
- x = 0
13
- y = 0
14
- font = Rays::Font.new "Osaka", 32
15
- prev = Time.now
16
- fps = 0
17
-
18
- w = Reflex::Window
19
- .new(:title => "Reflex on Ruby", :bounds => [100, 100, 600, 400])
20
- .before(:close) {w.hide; sleep 1; w.show; sleep 1}
21
- .on(:moved) {|x, y| p [x, y]}
22
- .on(:resized) {|w, h| p [w, h]}
23
- .on(:update) {w.redraw}
24
- .on(:draw) do
25
- b = w.bounds 0
26
- w.paint do |p|
27
- p.fill = 1, 0.5, 0.5, 0.05
28
- #p.stroke = 0.5, 0.5, 1
29
- 100.times do
30
- n = rand * Math::PI * 2
31
- xx = x + Math.sin(n) * 50
32
- yy = y + Math.cos(n) * 50
33
- p.rect xx, yy, 50, 50
34
- end
35
- p.fill = 1
36
- p.text "hello Rays/Reflex!", x, y + 32, font
37
- x = (x + 1) % 100
38
- y = (y + 1) % 100
39
-
40
- now = Time.now
41
- fps = 1 / (now - prev) if x % 10 == 0
42
- p.fill = 1, 1, 1, 1
43
- p.text "#{fps.to_i} FPS", 0, b.bottom - font.height, font
44
- prev = now
45
- end
46
- end
47
-
48
- w.show
49
- Reflex.run
@@ -1,65 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
-
3
-
4
- %w[xot rays reflex].product(%w[ext lib]).each do |paths|
5
- $: << File.expand_path(
6
- File.join File.dirname(__FILE__), *%w[.. .. ..], *paths)
7
- end
8
-
9
- require 'rubygems'
10
- require 'reflex'
11
-
12
-
13
- Reflex::Window.new do
14
- set title: "Grid Test", bounds: [100, 100, 50, 50]
15
- painter.background 0
16
-
17
- on :draw do
18
- paint do |p|
19
- p.push_matrix
20
- p.push_attrs
21
-
22
- w, h = bounds.size.to_a
23
-
24
- p.fill 1, 0, 0
25
-
26
- p.rect 1, 1, 5, 5
27
-
28
- p.stroke 0.3, 0.4
29
- (0..bounds.width) .step(2).each {|x| p.line x, 0, x, h}
30
- (0..bounds.height).step(2).each {|y| p.line 0, y, w, y}
31
- p.stroke 0.5, 0.4
32
- (0..bounds.width) .step(10).each {|x| p.line x, 0, x, h}
33
- (0..bounds.height).step(10).each {|y| p.line 0, y, w, y}
34
-
35
- p.translate 3, 10, 0
36
- p.fill nil
37
- p.stroke 1
38
-
39
- p.line 0, 0, 5, 0
40
-
41
- p.translate 0, 10, 0
42
-
43
- p.rect 0, 0, 5, 5
44
-
45
- p.translate 0, 10, 0
46
- p.fill 0.5, 0.5, 1
47
- p.stroke nil
48
-
49
- p.rect 0, 0, 5, 5
50
-
51
- p.translate 0, 10, 0
52
- p.fill 0.5, 0.5, 1
53
- p.stroke 0.5, 1, 0.5
54
-
55
- p.rect 0, 0, 5, 5
56
-
57
- p.pop_attrs
58
- p.pop_matrix
59
- end
60
- end
61
-
62
- show
63
- end
64
-
65
- Reflex.run
@@ -1,88 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
-
3
-
4
- %w[xot rays reflex].product(%w[ext lib]).each do |paths|
5
- $: << File.expand_path(
6
- File.join File.dirname(__FILE__), *%w[.. .. ..], *paths)
7
- end
8
-
9
- require 'rubygems'
10
- require 'reflex'
11
-
12
-
13
- def View (&block)
14
- Reflex::View.new &block
15
- end
16
-
17
-
18
- Reflex::Window.new do
19
- set :title, "Views Sample"
20
- set :bounds, 100, 100, 300, 300
21
- @count = 0
22
-
23
- def count ()
24
- @count
25
- end
26
-
27
- def spawn (x, y)
28
- @count += 1
29
- add View {
30
- c = [rand, rand, rand]
31
- size = 16
32
- set :bounds, x - size, y - size, size * 2, size * 2
33
- @angle = 0
34
- @speed = (rand * 2 - 1) * 30
35
-
36
- on :update do
37
- move_by rand(5) - 2, rand(5) - 2
38
- @angle += @speed
39
- @angle %= 360
40
- redraw
41
- end
42
-
43
- on :draw do |p, b|
44
- p.fill *c
45
- #p.rect *b.to_a
46
- p.arc *b.to_a, @angle, @angle + 90
47
- p.arc *b.to_a, @angle + 180, @angle + 270
48
- end
49
- }
50
- end
51
-
52
- on :key_down do |key|
53
- p [key.chars, key.code, key.repeat, key.modifiers]
54
- close if key.code == 53
55
- end
56
-
57
- on :points_down do |ps|
58
- spawn ps.x, ps.y
59
- @spawning = true
60
- end
61
-
62
- on :points_up do |ps|
63
- @spawning = false
64
- end
65
-
66
- on :points_moved do |ps|
67
- spawn ps.x, ps.y if @spawning
68
- end
69
-
70
- add View {
71
- on :draw do |p, b|
72
- set :bounds, window.bounds.move_to(0)
73
- p.fill 1
74
- p.text "count: #{window.count}", 10, 10
75
- end
76
- }
77
-
78
- root.on :draw do |p, b|
79
- p.fill 1
80
- p.text "draw on root view.", 10, 30
81
- end
82
-
83
- #100.times {spawn *bounds.move_to(0).center.to_a}
84
- show
85
- end
86
-
87
-
88
- Reflex.run "Views"
@@ -1,27 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
-
3
-
4
- %w[xot rays reflex].product(%w[ext lib]).each do |paths|
5
- $: << File.expand_path(
6
- File.join File.dirname(__FILE__), *%w[.. .. ..], *paths)
7
- end
8
-
9
- require 'rubygems'
10
- require 'reflex'
11
-
12
-
13
- Reflex::Application.new :name => 'Visuals' do |app|
14
- Reflex::Window.new :title => app.name do |win|
15
- win.bounds = 100, 100, 600, 500
16
- win.painter.background = 0.8
17
- 10.times do |i|
18
- Reflex::Visuals::String.new :name => 'hello' do |v|
19
- v.data = 'HELLO WORLD!'
20
- v.move_to *([i * 5] * 2)
21
- win.add v
22
- end
23
- end
24
- win.show
25
- end
26
- app.run
27
- end
data/ext/reflex/defs.cpp DELETED
@@ -1,8 +0,0 @@
1
- #include "defs.h"
2
-
3
-
4
- #include <rucy/value.h>
5
- #include <reflex/defs.h>
6
-
7
-
8
- using namespace Rucy;
data/ext/reflex/key.cpp DELETED
@@ -1,129 +0,0 @@
1
- #include "reflex/ruby/key.h"
2
-
3
-
4
- #include <rucy.h>
5
- #include "defs.h"
6
-
7
-
8
- using namespace Rucy;
9
-
10
-
11
- static Class cKey;
12
-
13
-
14
- namespace Reflex
15
- {
16
-
17
-
18
- Class
19
- key_class ()
20
- {
21
- return cKey;
22
- }
23
-
24
-
25
- }// Reflex
26
-
27
-
28
- namespace Rucy
29
- {
30
-
31
-
32
- Value
33
- value (const Reflex::Key& key)
34
- {
35
- return new_type(cKey, new Reflex::Key(key));
36
- }
37
-
38
-
39
- }// Rucy
40
-
41
-
42
- #define THIS to<Reflex::Key*>(self)
43
-
44
- #define CHECK RUCY_CHECK_OBJ(self, Reflex::Key, cKey)
45
-
46
-
47
- static
48
- RUBY_DEF_ALLOC(alloc, klass)
49
- {
50
- return new_type<Reflex::Key>(klass);
51
- }
52
- RUBY_END
53
-
54
- static
55
- RUBY_DEFN(initialize)
56
- {
57
- RUCY_CHECK_OBJ(self, Reflex::Key, cKey);
58
- if (argc < 0 || 4 < argc)
59
- argument_error("Key#initialize", argc, 0, 1, 2);
60
-
61
- THIS->chars = (argc >= 1) ? argv[0].c_str() : NULL;
62
- THIS->code = (argc >= 2) ? to<int>(argv[1]) : Reflex::KEY_NONE;
63
- THIS->repeat = (argc >= 3) ? to<int>(argv[2]) : 1;
64
- THIS->modifiers = (argc >= 4) ? to<uint>(argv[3]) : (uint) Reflex::MOD_NONE;
65
-
66
- return self;
67
- }
68
- RUBY_END
69
-
70
- static
71
- RUBY_DEF1(initialize_copy, obj)
72
- {
73
- RUCY_CHECK_OBJ(self, Reflex::Key, cKey);
74
-
75
- Reflex::Key* key = to<Reflex::Key*>(obj);
76
- if (!key) argument_error();
77
-
78
- *THIS = *key;
79
- return self;
80
- }
81
- RUBY_END
82
-
83
- static
84
- RUBY_DEF0(chars)
85
- {
86
- CHECK;
87
- return value(THIS->chars.c_str());
88
- }
89
- RUBY_END
90
-
91
- static
92
- RUBY_DEF0(code)
93
- {
94
- CHECK;
95
- return value(THIS->code);
96
- }
97
- RUBY_END
98
-
99
- static
100
- RUBY_DEF0(repeat)
101
- {
102
- CHECK;
103
- return value(THIS->repeat);
104
- }
105
- RUBY_END
106
-
107
- static
108
- RUBY_DEF0(modifiers)
109
- {
110
- CHECK;
111
- return value(THIS->modifiers);
112
- }
113
- RUBY_END
114
-
115
-
116
- void
117
- Init_key ()
118
- {
119
- Module mReflex = define_module("Reflex");
120
-
121
- cKey = mReflex.define_class("Key");
122
- cKey.define_alloc_func(alloc);
123
- cKey.define_private_method("initialize", initialize);
124
- cKey.define_private_method("initialize_copy", initialize_copy);
125
- cKey.define_method("chars", chars);
126
- cKey.define_method("code", code);
127
- cKey.define_method("repeat", repeat);
128
- cKey.define_method("modifiers", modifiers);
129
- }