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
@@ -1,12 +1,10 @@
1
1
  # -*- coding: utf-8 -*-
2
2
 
3
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
4
+ %w[xot rays reflex]
5
+ .map {|s| File.expand_path "../../../#{s}/lib", __FILE__}
6
+ .each {|s| $:.unshift s if !$:.include?(s) && File.directory?(s)}
8
7
 
9
- require 'rubygems'
10
8
  require 'reflex'
11
9
 
12
10
 
@@ -15,15 +13,14 @@ $text = $pos = ''
15
13
 
16
14
  w = Reflex::Window.new
17
15
  w.title = "Reflex Input Sample"
18
- w.bounds = 100, 100, 800, 300
16
+ w.frame = 100, 100, 800, 300
19
17
  w.painter.font = Rays::Font.new nil, 32
20
18
 
21
- w.on :draw do
22
- w.paint do |p|
23
- p.fill = 1
24
- p.text $text, 100, 100
25
- p.text $pos, 100, 150
26
- end
19
+ w.on :draw do |e|
20
+ p = e.painter
21
+ p.fill = 1
22
+ p.text $text, 100, 100
23
+ p.text $pos, 100, 150
27
24
  end
28
25
 
29
26
  w.on :key_down do |key|
@@ -34,11 +31,11 @@ w.on :key_down do |key|
34
31
  w.redraw
35
32
  end
36
33
 
37
- w.on :points_moved do |points|
34
+ w.on :pointer_move do |points|
38
35
  $pos = "#{points.x}, #{points.y}"
39
36
  p [points.type, points.x, points.y, points.size, points.modifiers, points.count, points.drag]
40
37
  w.redraw
41
38
  end
42
39
 
43
40
  w.show
44
- Reflex.run
41
+ Reflex.start
data/samples/layout.rb ADDED
@@ -0,0 +1,89 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+
4
+ %w[xot rays reflex]
5
+ .map {|s| File.expand_path "../../../#{s}/lib", __FILE__}
6
+ .each {|s| $:.unshift s if !$:.include?(s) && File.directory?(s)}
7
+
8
+ require 'reflex'
9
+ include Reflex
10
+
11
+
12
+ module Reflex
13
+ class View
14
+ def view (frame = [0, 0, rand(10..200), rand(10..200)], color = [rand, rand, rand], &block)
15
+ v = RectShape.new &block
16
+ v.set frame: frame, color: color
17
+ add v
18
+ v
19
+ end
20
+
21
+ alias text view
22
+ alias image view
23
+ alias button view
24
+ end
25
+ end
26
+
27
+ win = Window.new title: 'Layout Sample', frame: [100, 100, 500, 400] do
28
+ 20.times do
29
+ root.view
30
+ end
31
+ =begin
32
+ lock_screen = View.new do
33
+ view :header do
34
+ view :left do
35
+ text :dots
36
+ text :carrior
37
+ image :antenna
38
+ end
39
+ image :notifycation_pulltab
40
+ view :right do
41
+ iamge :blutooth
42
+ text :battery_percent
43
+ image :battery
44
+ end
45
+ end
46
+
47
+ view :passcode do
48
+ view :main do
49
+ end
50
+ view :footer do
51
+ button :emergency
52
+ button :cancel
53
+ end
54
+ end
55
+
56
+ view :slider do
57
+ view :clock
58
+ view :slide
59
+ end
60
+ end
61
+ add lock_screen
62
+
63
+ style :all do
64
+ padding 10
65
+ end
66
+
67
+ style :header do
68
+ margin 20, 10
69
+
70
+ #background gray|graya|rgb|rgba|hsv|hsva,image,bounds,repeat
71
+ #background_color gray|graya|rgb|rgba|hsv|hsva
72
+ #background_image image,bounds,repeat
73
+
74
+ #frame x,y,w,h
75
+ #x px|%
76
+ #y px|%
77
+ #width px|%
78
+ #height px|%
79
+ #left px|%
80
+ #top px|%
81
+ #right px|%
82
+ #bottom px|%
83
+ end
84
+ =end
85
+ show
86
+ end
87
+
88
+
89
+ Reflex.start
data/samples/model.rb ADDED
@@ -0,0 +1,86 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+
4
+ %w[xot rays reflex]
5
+ .map {|s| File.expand_path "../../../#{s}/lib", __FILE__}
6
+ .each {|s| $:.unshift s if !$:.include?(s) && File.directory?(s)}
7
+
8
+ require 'reflex'
9
+
10
+ include Reflex
11
+
12
+
13
+ class SliderView < View
14
+
15
+ has_model
16
+
17
+ def initialize ()
18
+ add @back = RectShape.new {set name: :back, border: :white, follow: :all}
19
+ add @knob = RectShape.new {set name: :knob, border: :white, follow: [:top, :bottom], color: :gray, width: 50, x: 50}
20
+
21
+ start = nil
22
+ @knob.on :pointer do |e|
23
+ case e.type
24
+ when :down
25
+ start = e.position
26
+ @knob.capture :pointer
27
+ when :up
28
+ start = nil
29
+ @knob.capture :none
30
+ when :move
31
+ self.data = (@knob.x + e.x - start.x) / knob_left_max.to_f if start
32
+ end
33
+ end
34
+
35
+ super
36
+ end
37
+
38
+ def on_data_update (e)
39
+ @knob.x = knob_left_max * data.to_f
40
+ super
41
+ end
42
+
43
+ private
44
+
45
+ def knob_left_max ()
46
+ width - @knob.width
47
+ end
48
+
49
+ end# SliderView
50
+
51
+
52
+ class LabelView < View
53
+
54
+ has_model
55
+
56
+ def on_draw (e)
57
+ e.painter.text data.to_s if data
58
+ end
59
+
60
+ end# LabelView
61
+
62
+
63
+ class ArrayView < View
64
+
65
+ has_model
66
+
67
+ def on_draw (e)
68
+ e.painter.text "[#{data.to_s.chars.map{|c| "'#{c}'"}.to_a.join(', ')}]" if data
69
+ end
70
+
71
+ end# ArrayView
72
+
73
+
74
+ win = Window.new do
75
+ add @slider = SliderView.new {set name: :slider, frame: [50, 50, 300, 30]}
76
+ add @text = LabelView.new {set name: :text, frame: [50, 150, 300, 30]}
77
+ add @array = ArrayView.new {set name: :array, frame: [50, 250, 300, 30]}
78
+
79
+ @slider.model = @text.model = @array.model = Model.new(0) {set minmax: 0..1}
80
+
81
+ set title: 'Model View Sample', frame: [100, 100, 500, 400]
82
+ show
83
+ end
84
+
85
+
86
+ Reflex.start
@@ -0,0 +1,58 @@
1
+ {
2
+ "images" : [
3
+ {
4
+ "idiom" : "mac",
5
+ "size" : "16x16",
6
+ "scale" : "1x"
7
+ },
8
+ {
9
+ "idiom" : "mac",
10
+ "size" : "16x16",
11
+ "scale" : "2x"
12
+ },
13
+ {
14
+ "idiom" : "mac",
15
+ "size" : "32x32",
16
+ "scale" : "1x"
17
+ },
18
+ {
19
+ "idiom" : "mac",
20
+ "size" : "32x32",
21
+ "scale" : "2x"
22
+ },
23
+ {
24
+ "idiom" : "mac",
25
+ "size" : "128x128",
26
+ "scale" : "1x"
27
+ },
28
+ {
29
+ "idiom" : "mac",
30
+ "size" : "128x128",
31
+ "scale" : "2x"
32
+ },
33
+ {
34
+ "idiom" : "mac",
35
+ "size" : "256x256",
36
+ "scale" : "1x"
37
+ },
38
+ {
39
+ "idiom" : "mac",
40
+ "size" : "256x256",
41
+ "scale" : "2x"
42
+ },
43
+ {
44
+ "idiom" : "mac",
45
+ "size" : "512x512",
46
+ "scale" : "1x"
47
+ },
48
+ {
49
+ "idiom" : "mac",
50
+ "size" : "512x512",
51
+ "scale" : "2x"
52
+ }
53
+ ],
54
+ "info" : {
55
+ "version" : 1,
56
+ "author" : "xcode"
57
+ }
58
+ }
@@ -0,0 +1,29 @@
1
+ {\rtf0\ansi{\fonttbl\f0\fswiss Helvetica;}
2
+ {\colortbl;\red255\green255\blue255;}
3
+ \paperw9840\paperh8400
4
+ \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural
5
+
6
+ \f0\b\fs24 \cf0 Engineering:
7
+ \b0 \
8
+ Some people\
9
+ \
10
+
11
+ \b Human Interface Design:
12
+ \b0 \
13
+ Some other people\
14
+ \
15
+
16
+ \b Testing:
17
+ \b0 \
18
+ Hopefully not nobody\
19
+ \
20
+
21
+ \b Documentation:
22
+ \b0 \
23
+ Whoever\
24
+ \
25
+
26
+ \b With special thanks to:
27
+ \b0 \
28
+ Mom\
29
+ }
@@ -0,0 +1,2 @@
1
+ /* Localized versions of Info.plist keys */
2
+
@@ -0,0 +1,32 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
+ <plist version="1.0">
4
+ <dict>
5
+ <key>CFBundleDevelopmentRegion</key>
6
+ <string>en</string>
7
+ <key>CFBundleExecutable</key>
8
+ <string>${EXECUTABLE_NAME}</string>
9
+ <key>CFBundleIconFile</key>
10
+ <string></string>
11
+ <key>CFBundleIdentifier</key>
12
+ <string>org.xord.${PRODUCT_NAME:rfc1034identifier}</string>
13
+ <key>CFBundleInfoDictionaryVersion</key>
14
+ <string>6.0</string>
15
+ <key>CFBundleName</key>
16
+ <string>${PRODUCT_NAME}</string>
17
+ <key>CFBundlePackageType</key>
18
+ <string>APPL</string>
19
+ <key>CFBundleShortVersionString</key>
20
+ <string>1.0</string>
21
+ <key>CFBundleSignature</key>
22
+ <string>????</string>
23
+ <key>CFBundleVersion</key>
24
+ <string>1</string>
25
+ <key>LSMinimumSystemVersion</key>
26
+ <string>${MACOSX_DEPLOYMENT_TARGET}</string>
27
+ <key>NSHumanReadableCopyright</key>
28
+ <string>Copyright © 2014年 xord.org. All rights reserved.</string>
29
+ <key>NSPrincipalClass</key>
30
+ <string>NSApplication</string>
31
+ </dict>
32
+ </plist>
@@ -0,0 +1,3 @@
1
+ #ifdef __OBJC__
2
+ #import <Cocoa/Cocoa.h>
3
+ #endif
@@ -0,0 +1,79 @@
1
+ #include <xot.h>
2
+ #include <rays.h>
3
+ #include <reflex.h>
4
+
5
+ using namespace Xot;
6
+ using namespace Rays;
7
+ using namespace Reflex;
8
+
9
+
10
+ class Win : public Window
11
+ {
12
+
13
+ typedef Window Super;
14
+
15
+ public:
16
+
17
+ void on_update (UpdateEvent* e)
18
+ {
19
+ redraw();
20
+ }
21
+
22
+ void on_draw (DrawEvent* e)
23
+ {
24
+ Super::on_draw(e);
25
+ e->painter->text(stringf("%f", e->fps), 10, 10);
26
+ }
27
+
28
+ };// Window
29
+
30
+
31
+ class App : public Application
32
+ {
33
+
34
+ public:
35
+
36
+ void on_start (Event* e)
37
+ {
38
+ Window* win = new Win();
39
+ win->set_title(app()->name());
40
+ win->set_frame(100, 100, 500, 500);
41
+ win->show();
42
+
43
+ Image image(32, 32);
44
+ Painter painter = image.painter();
45
+ painter.begin();
46
+ painter.no_stroke();
47
+ painter.set_fill(1, 1, 1);
48
+ painter.rect(0, 0, image.width(), image.height());
49
+ painter.set_fill(1, 0, 0);
50
+ painter.ellipse(0, 0, image.width(), image.height());
51
+ painter.end();
52
+
53
+ for (int i = 0; i < 2000; ++i)
54
+ {
55
+ ImageView* view = new ImageView();
56
+ view->set_image(image);
57
+ view->set_frame(0, 0, image.width(), image.height());
58
+
59
+ win->root()->add_child(view);
60
+ }
61
+ }
62
+
63
+ };// App
64
+
65
+
66
+ int main(int argc, const char** argv)
67
+ {
68
+ Rays::init();
69
+ Reflex::init();
70
+
71
+ Application* app = new App();
72
+ app->set_name("Hello Xcode!");
73
+ app->start();
74
+
75
+ Reflex::fin();
76
+ Rays::fin();
77
+
78
+ return 0;
79
+ }