epall-limelight 0.5.0-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (282) hide show
  1. data/bin/icons/icon.ico +0 -0
  2. data/bin/icons/icon_48.gif +0 -0
  3. data/bin/icons/limelight.icns +0 -0
  4. data/bin/limelight +5 -0
  5. data/bin/ll +10 -0
  6. data/bin/ll.bat +5 -0
  7. data/lib/init.rb +16 -0
  8. data/lib/limelight.jar +0 -0
  9. data/lib/limelight/animation.rb +41 -0
  10. data/lib/limelight/builtin/players.rb +16 -0
  11. data/lib/limelight/builtin/players/button.rb +39 -0
  12. data/lib/limelight/builtin/players/check_box.rb +50 -0
  13. data/lib/limelight/builtin/players/combo_box.rb +89 -0
  14. data/lib/limelight/builtin/players/combo_box_popup_list.rb +19 -0
  15. data/lib/limelight/builtin/players/combo_box_popup_list_item.rb +21 -0
  16. data/lib/limelight/builtin/players/curtains.rb +23 -0
  17. data/lib/limelight/builtin/players/image.rb +54 -0
  18. data/lib/limelight/builtin/players/password_box.rb +34 -0
  19. data/lib/limelight/builtin/players/radio_button.rb +65 -0
  20. data/lib/limelight/builtin/players/stage_mover.rb +31 -0
  21. data/lib/limelight/builtin/players/stage_sizer.rb +34 -0
  22. data/lib/limelight/builtin/players/text_area.rb +34 -0
  23. data/lib/limelight/builtin/players/text_box.rb +34 -0
  24. data/lib/limelight/builtin/styles.rb +35 -0
  25. data/lib/limelight/builtin/utilities_production/alert/players/alert.rb +11 -0
  26. data/lib/limelight/builtin/utilities_production/alert/props.rb +8 -0
  27. data/lib/limelight/builtin/utilities_production/alert/styles.rb +14 -0
  28. data/lib/limelight/builtin/utilities_production/incompatible_version/props.rb +20 -0
  29. data/lib/limelight/builtin/utilities_production/incompatible_version/styles.rb +12 -0
  30. data/lib/limelight/builtin/utilities_production/production.rb +62 -0
  31. data/lib/limelight/builtin/utilities_production/stages.rb +12 -0
  32. data/lib/limelight/builtin/utilities_production/styles.rb +53 -0
  33. data/lib/limelight/button_group_cache.rb +11 -0
  34. data/lib/limelight/casting_director.rb +112 -0
  35. data/lib/limelight/client/playbills.rb +86 -0
  36. data/lib/limelight/commands/command.rb +168 -0
  37. data/lib/limelight/commands/create_command.rb +98 -0
  38. data/lib/limelight/commands/freeze_command.rb +131 -0
  39. data/lib/limelight/commands/help_command.rb +61 -0
  40. data/lib/limelight/commands/open_command.rb +60 -0
  41. data/lib/limelight/commands/pack_command.rb +45 -0
  42. data/lib/limelight/commands/unpack_command.rb +44 -0
  43. data/lib/limelight/commands/version_command.rb +31 -0
  44. data/lib/limelight/data.rb +37 -0
  45. data/lib/limelight/dsl/build_exception.rb +55 -0
  46. data/lib/limelight/dsl/menu_bar.rb +71 -0
  47. data/lib/limelight/dsl/prop_builder.rb +155 -0
  48. data/lib/limelight/dsl/stage_builder.rb +105 -0
  49. data/lib/limelight/dsl/styles_builder.rb +157 -0
  50. data/lib/limelight/file_chooser.rb +68 -0
  51. data/lib/limelight/file_filter.rb +33 -0
  52. data/lib/limelight/file_loader.rb +46 -0
  53. data/lib/limelight/gems.rb +51 -0
  54. data/lib/limelight/java_couplings.rb +66 -0
  55. data/lib/limelight/java_util.rb +49 -0
  56. data/lib/limelight/limelight_exception.rb +24 -0
  57. data/lib/limelight/main.rb +108 -0
  58. data/lib/limelight/paint_action.rb +27 -0
  59. data/lib/limelight/pen.rb +83 -0
  60. data/lib/limelight/producer.rb +179 -0
  61. data/lib/limelight/production.rb +169 -0
  62. data/lib/limelight/prop.rb +367 -0
  63. data/lib/limelight/scene.rb +151 -0
  64. data/lib/limelight/specs/spec_helper.rb +87 -0
  65. data/lib/limelight/specs/test_scene_opener.rb +60 -0
  66. data/lib/limelight/stage.rb +292 -0
  67. data/lib/limelight/string.rb +38 -0
  68. data/lib/limelight/studio.rb +185 -0
  69. data/lib/limelight/styles.rb +347 -0
  70. data/lib/limelight/templates/production_templater.rb +49 -0
  71. data/lib/limelight/templates/scene_templater.rb +47 -0
  72. data/lib/limelight/templates/sources/freezing/limelight_init.rb.template +5 -0
  73. data/lib/limelight/templates/sources/production/init.rb.template +15 -0
  74. data/lib/limelight/templates/sources/production/production.rb.template +49 -0
  75. data/lib/limelight/templates/sources/production/spec/spec_helper.rb.template +12 -0
  76. data/lib/limelight/templates/sources/production/stages.rb.template +17 -0
  77. data/lib/limelight/templates/sources/production/styles.rb.template +12 -0
  78. data/lib/limelight/templates/sources/scene/props.rb.template +6 -0
  79. data/lib/limelight/templates/sources/scene/styles.rb.template +18 -0
  80. data/lib/limelight/templates/sources/scene_spec/scene_spec.rb.template +13 -0
  81. data/lib/limelight/templates/templater.rb +131 -0
  82. data/lib/limelight/templates/templater_logger.rb +39 -0
  83. data/lib/limelight/theater.rb +77 -0
  84. data/lib/limelight/util.rb +65 -0
  85. data/lib/limelight/util/downloader.rb +115 -0
  86. data/lib/limelight/version.rb +20 -0
  87. data/productions/examples/8thlight.com/about/about.txt +24 -0
  88. data/productions/examples/8thlight.com/about/props.rb +11 -0
  89. data/productions/examples/8thlight.com/about/styles.rb +2 -0
  90. data/productions/examples/8thlight.com/footer.rb +6 -0
  91. data/productions/examples/8thlight.com/home/props.rb +28 -0
  92. data/productions/examples/8thlight.com/home/styles.rb +2 -0
  93. data/productions/examples/8thlight.com/images/anvil.jpg +0 -0
  94. data/productions/examples/8thlight.com/images/bg.jpg +0 -0
  95. data/productions/examples/8thlight.com/images/botticelli.jpg +0 -0
  96. data/productions/examples/8thlight.com/images/button_bg.jpg +0 -0
  97. data/productions/examples/8thlight.com/images/canvas_bg.jpg +0 -0
  98. data/productions/examples/8thlight.com/images/footer_bg.jpg +0 -0
  99. data/productions/examples/8thlight.com/images/header.jpg +0 -0
  100. data/productions/examples/8thlight.com/images/moses.jpg +0 -0
  101. data/productions/examples/8thlight.com/images/statemachine_thumbnail.png +0 -0
  102. data/productions/examples/8thlight.com/images/thumbnail_book.jpg +0 -0
  103. data/productions/examples/8thlight.com/menu.rb +11 -0
  104. data/productions/examples/8thlight.com/services/props.rb +11 -0
  105. data/productions/examples/8thlight.com/services/services.txt +8 -0
  106. data/productions/examples/8thlight.com/services/styles.rb +2 -0
  107. data/productions/examples/8thlight.com/stages.rb +8 -0
  108. data/productions/examples/8thlight.com/styles.rb +210 -0
  109. data/productions/examples/calculator/players/button.rb +24 -0
  110. data/productions/examples/calculator/players/calculator.rb +15 -0
  111. data/productions/examples/calculator/players/calculator_model.rb +13 -0
  112. data/productions/examples/calculator/props.rb +23 -0
  113. data/productions/examples/calculator/styles.rb +36 -0
  114. data/productions/examples/langstons_ant/html_javascript/ant.css +39 -0
  115. data/productions/examples/langstons_ant/html_javascript/ant.html +22 -0
  116. data/productions/examples/langstons_ant/html_javascript/ant.js +23 -0
  117. data/productions/examples/langstons_ant/init.rb +4 -0
  118. data/productions/examples/langstons_ant/players/ant.rb +103 -0
  119. data/productions/examples/langstons_ant/players/log.rb +29 -0
  120. data/productions/examples/langstons_ant/players/start_stop_button.rb +37 -0
  121. data/productions/examples/langstons_ant/players/world.rb +35 -0
  122. data/productions/examples/langstons_ant/props.rb +22 -0
  123. data/productions/examples/langstons_ant/styles.rb +104 -0
  124. data/productions/examples/sandbox/alerts/incompatible_production/default_scene/props.rb +10 -0
  125. data/productions/examples/sandbox/alerts/incompatible_production/default_scene/styles.rb +32 -0
  126. data/productions/examples/sandbox/alerts/incompatible_production/production.rb +52 -0
  127. data/productions/examples/sandbox/alerts/incompatible_production/spec/default_scene/default_scene_spec.rb +16 -0
  128. data/productions/examples/sandbox/alerts/incompatible_production/spec/spec_helper.rb +8 -0
  129. data/productions/examples/sandbox/alerts/incompatible_production/stages.rb +20 -0
  130. data/productions/examples/sandbox/alerts/incompatible_production/styles.rb +15 -0
  131. data/productions/examples/sandbox/alerts/players/alerts.rb +17 -0
  132. data/productions/examples/sandbox/alerts/props.rb +10 -0
  133. data/productions/examples/sandbox/alerts/styles.rb +46 -0
  134. data/productions/examples/sandbox/background_images/props.rb +22 -0
  135. data/productions/examples/sandbox/background_images/styles.rb +40 -0
  136. data/productions/examples/sandbox/click_me/players/chromaton.rb +52 -0
  137. data/productions/examples/sandbox/click_me/props.rb +8 -0
  138. data/productions/examples/sandbox/click_me/styles.rb +11 -0
  139. data/productions/examples/sandbox/floaters/players/floater.rb +108 -0
  140. data/productions/examples/sandbox/floaters/players/surface.rb +21 -0
  141. data/productions/examples/sandbox/floaters/props.rb +10 -0
  142. data/productions/examples/sandbox/floaters/styles.rb +24 -0
  143. data/productions/examples/sandbox/frameing/players/sandbox.rb +17 -0
  144. data/productions/examples/sandbox/frameing/props.rb +35 -0
  145. data/productions/examples/sandbox/frameing/styles.rb +45 -0
  146. data/productions/examples/sandbox/gradients/players/spinner.rb +20 -0
  147. data/productions/examples/sandbox/gradients/players/teaser.rb +19 -0
  148. data/productions/examples/sandbox/gradients/players/wave.rb +19 -0
  149. data/productions/examples/sandbox/gradients/players/waves.rb +19 -0
  150. data/productions/examples/sandbox/gradients/props.rb +13 -0
  151. data/productions/examples/sandbox/gradients/styles.rb +47 -0
  152. data/productions/examples/sandbox/header.rb +22 -0
  153. data/productions/examples/sandbox/homer/players/homer.rb +24 -0
  154. data/productions/examples/sandbox/homer/props.rb +10 -0
  155. data/productions/examples/sandbox/homer/styles.rb +16 -0
  156. data/productions/examples/sandbox/images/arch.jpg +0 -0
  157. data/productions/examples/sandbox/images/beach.jpg +0 -0
  158. data/productions/examples/sandbox/images/homer.jpg +0 -0
  159. data/productions/examples/sandbox/images/limelight_spotlight.jpg +0 -0
  160. data/productions/examples/sandbox/images/logo.png +0 -0
  161. data/productions/examples/sandbox/images/marilyn.jpg +0 -0
  162. data/productions/examples/sandbox/images/space.png +0 -0
  163. data/productions/examples/sandbox/images_scene/props.rb +36 -0
  164. data/productions/examples/sandbox/images_scene/styles.rb +34 -0
  165. data/productions/examples/sandbox/inputs/players/button_input.rb +48 -0
  166. data/productions/examples/sandbox/inputs/players/check_box_input.rb +40 -0
  167. data/productions/examples/sandbox/inputs/players/combo_box_input.rb +41 -0
  168. data/productions/examples/sandbox/inputs/players/radio_button_input.rb +43 -0
  169. data/productions/examples/sandbox/inputs/players/text_area_input.rb +36 -0
  170. data/productions/examples/sandbox/inputs/players/text_box_input.rb +36 -0
  171. data/productions/examples/sandbox/inputs/props.rb +40 -0
  172. data/productions/examples/sandbox/inputs/styles.rb +39 -0
  173. data/productions/examples/sandbox/kiosk/players/kiosk.rb +39 -0
  174. data/productions/examples/sandbox/kiosk/props.rb +9 -0
  175. data/productions/examples/sandbox/kiosk/styles.rb +37 -0
  176. data/productions/examples/sandbox/players/sandbox.rb +11 -0
  177. data/productions/examples/sandbox/rounded_corners/players/box.rb +11 -0
  178. data/productions/examples/sandbox/rounded_corners/props.rb +22 -0
  179. data/productions/examples/sandbox/rounded_corners/styles.rb +17 -0
  180. data/productions/examples/sandbox/scrolling/players/add_button.rb +19 -0
  181. data/productions/examples/sandbox/scrolling/players/cell.rb +15 -0
  182. data/productions/examples/sandbox/scrolling/props.rb +45 -0
  183. data/productions/examples/sandbox/scrolling/styles.rb +33 -0
  184. data/productions/examples/sandbox/sketching/players/sketchpad.rb +46 -0
  185. data/productions/examples/sandbox/sketching/props.rb +25 -0
  186. data/productions/examples/sandbox/sketching/styles.rb +35 -0
  187. data/productions/examples/sandbox/sounds/bird.au +0 -0
  188. data/productions/examples/sandbox/sounds/cat.au +0 -0
  189. data/productions/examples/sandbox/sounds/cow.au +0 -0
  190. data/productions/examples/sandbox/sounds/dog.au +0 -0
  191. data/productions/examples/sandbox/sounds/donkey.au +0 -0
  192. data/productions/examples/sandbox/sounds/duck.au +0 -0
  193. data/productions/examples/sandbox/sounds/players/clip.rb +10 -0
  194. data/productions/examples/sandbox/sounds/props.rb +10 -0
  195. data/productions/examples/sandbox/sounds/styles.rb +17 -0
  196. data/productions/examples/sandbox/spec/alerts/alerts_spec.rb +16 -0
  197. data/productions/examples/sandbox/stage_handles/players/sizer.rb +35 -0
  198. data/productions/examples/sandbox/stage_handles/props.rb +17 -0
  199. data/productions/examples/sandbox/stage_handles/styles.rb +58 -0
  200. data/productions/examples/sandbox/stages.rb +8 -0
  201. data/productions/examples/sandbox/styles.rb +35 -0
  202. data/productions/examples/sandbox/teaser/players/fader.rb +58 -0
  203. data/productions/examples/sandbox/teaser/props.rb +14 -0
  204. data/productions/examples/sandbox/teaser/styles.rb +21 -0
  205. data/productions/examples/tutorials/tutorial_1/players/sample.rb +11 -0
  206. data/productions/examples/tutorials/tutorial_1/props.rb +9 -0
  207. data/productions/examples/tutorials/tutorial_1/styles.rb +25 -0
  208. data/productions/playbills.lll +1 -0
  209. data/productions/stage_composer/init.rb +10 -0
  210. data/productions/stage_composer/inspector/players/inspector.rb +80 -0
  211. data/productions/stage_composer/inspector/players/prop_row.rb +12 -0
  212. data/productions/stage_composer/inspector/players/prop_tree.rb +33 -0
  213. data/productions/stage_composer/inspector/players/style_table.rb +12 -0
  214. data/productions/stage_composer/inspector/players/style_value.rb +16 -0
  215. data/productions/stage_composer/inspector/props.rb +19 -0
  216. data/productions/stage_composer/inspector/styles.rb +71 -0
  217. data/productions/stage_composer/lib/init.rb +5 -0
  218. data/productions/stage_composer/lib/limelight/composer/controller.rb +51 -0
  219. data/productions/stage_composer/lib/limelight/composer/lethargy.rb +24 -0
  220. data/productions/stage_composer/production.rb +6 -0
  221. data/productions/stage_composer/stages.rb +15 -0
  222. data/productions/startup/images/logo.png +0 -0
  223. data/productions/startup/images/splash.png +0 -0
  224. data/productions/startup/production.rb +52 -0
  225. data/productions/startup/spec/default_scene/default_scene_spec.rb +16 -0
  226. data/productions/startup/spec/spec_helper.rb +8 -0
  227. data/productions/startup/stages.rb +9 -0
  228. data/productions/startup/styles.rb +15 -0
  229. data/productions/startup/welcome/players/browse_button.rb +10 -0
  230. data/productions/startup/welcome/players/download_button.rb +17 -0
  231. data/productions/startup/welcome/players/sandbox_button.rb +11 -0
  232. data/productions/startup/welcome/props.rb +23 -0
  233. data/productions/startup/welcome/styles.rb +103 -0
  234. data/spec/limelight/builtin/players/button_spec.rb +20 -0
  235. data/spec/limelight/builtin/players/check_box_spec.rb +29 -0
  236. data/spec/limelight/builtin/players/combo_box_spec.rb +29 -0
  237. data/spec/limelight/builtin/players/image_spec.rb +43 -0
  238. data/spec/limelight/builtin/players/password_box_spec.rb +27 -0
  239. data/spec/limelight/builtin/players/radio_button_spec.rb +64 -0
  240. data/spec/limelight/builtin/players/stage_mover_spec.rb +36 -0
  241. data/spec/limelight/builtin/players/stage_sizer_spec.rb +40 -0
  242. data/spec/limelight/builtin/players/text_area_spec.rb +27 -0
  243. data/spec/limelight/builtin/players/text_box_spec.rb +27 -0
  244. data/spec/limelight/builtin/utilities_production/spec_helper.rb +7 -0
  245. data/spec/limelight/builtin/utilities_production/utilities_production_spec.rb +146 -0
  246. data/spec/limelight/casting_director_spec.rb +164 -0
  247. data/spec/limelight/client/playbills_spec.rb +79 -0
  248. data/spec/limelight/commands/command_spec.rb +26 -0
  249. data/spec/limelight/commands/create_command_spec.rb +108 -0
  250. data/spec/limelight/commands/freeze_command_spec.rb +143 -0
  251. data/spec/limelight/commands/help_command_spec.rb +42 -0
  252. data/spec/limelight/commands/open_command_spec.rb +52 -0
  253. data/spec/limelight/commands/pack_command_spec.rb +26 -0
  254. data/spec/limelight/commands/unpack_command_spec.rb +47 -0
  255. data/spec/limelight/data_spec.rb +36 -0
  256. data/spec/limelight/dsl/prop_builder_spec.rb +245 -0
  257. data/spec/limelight/dsl/stage_builder_spec.rb +90 -0
  258. data/spec/limelight/dsl/styles_builder_spec.rb +194 -0
  259. data/spec/limelight/file_chooser_spec.rb +64 -0
  260. data/spec/limelight/file_filter_spec.rb +29 -0
  261. data/spec/limelight/file_loader_spec.rb +28 -0
  262. data/spec/limelight/gems_spec.rb +92 -0
  263. data/spec/limelight/java_util_spec.rb +37 -0
  264. data/spec/limelight/main_spec.rb +40 -0
  265. data/spec/limelight/paint_action_spec.rb +30 -0
  266. data/spec/limelight/pen_spec.rb +62 -0
  267. data/spec/limelight/producer_spec.rb +210 -0
  268. data/spec/limelight/production_spec.rb +100 -0
  269. data/spec/limelight/prop_spec.rb +431 -0
  270. data/spec/limelight/scene_spec.rb +173 -0
  271. data/spec/limelight/stage_spec.rb +202 -0
  272. data/spec/limelight/string_spec.rb +38 -0
  273. data/spec/limelight/studio_spec.rb +157 -0
  274. data/spec/limelight/styles_spec.rb +53 -0
  275. data/spec/limelight/templates/production_templater_spec.rb +66 -0
  276. data/spec/limelight/templates/scene_templater_spec.rb +51 -0
  277. data/spec/limelight/templates/templater_logger_spec.rb +41 -0
  278. data/spec/limelight/templates/templater_spec.rb +107 -0
  279. data/spec/limelight/theater_spec.rb +72 -0
  280. data/spec/limelight/util/downloader_spec.rb +92 -0
  281. data/spec/spec_helper.rb +70 -0
  282. metadata +335 -0
@@ -0,0 +1,367 @@
1
+ #- Copyright � 2008-2009 8th Light, Inc. All Rights Reserved.
2
+ #- Limelight and all included source files are distributed under terms of the GNU LGPL.
3
+
4
+ require 'limelight/java_util'
5
+ require 'limelight/pen'
6
+ require 'limelight/paint_action'
7
+ require 'limelight/animation'
8
+
9
+ module Limelight
10
+
11
+ # Prop is the fundamental building block of a scene. A prop represents a rectangular area in the scene, of almost any dimension.
12
+ # It may have borders, backgrounds, margin, padding, and it may contain other props or text. However it is the props'
13
+ # Styles that determine their size and appearance.
14
+ #
15
+ # A Prop may have one parent and many children. Hense, when put together, they form a tree structure. The Scene is
16
+ # the root Prop of a tree.
17
+ #
18
+ class Prop
19
+
20
+ class << self
21
+
22
+ def event(event_symbol)
23
+ @events ||= []
24
+ @events << event_symbol unless @events.include?(event_symbol)
25
+ define_method(event_symbol) { |event| } # do nothing by default
26
+ end
27
+
28
+ def events
29
+ return @events
30
+ end
31
+
32
+ def event2(event_symbol)
33
+ @events ||= []
34
+ @events << event_symbol unless @events.include?(event_symbol)
35
+ define_method("accepts_#{event_symbol}".to_sym) { return self.respond_to?(event_symbol) }
36
+ end
37
+
38
+ end
39
+
40
+ include UI::Api::Prop
41
+
42
+ attr_accessor :style, :hover_style
43
+ attr_reader :panel #:nodoc:
44
+ attr_reader :children, :parent, :name, :id, :players
45
+ getters :panel, :style, :hover_style, :name, :scene, :loader #:nodoc:
46
+
47
+ # When creating a Prop, an optional Hash is accepted. These are called initialization options.
48
+ # The key/value pairs in the initialiaztion options will be used to
49
+ # set properties on the Prop, it Style, or included Player properties. These properties are not set
50
+ # until the prop is added to a Prop tree with a Scene.
51
+ #
52
+ def initialize(hash = {})
53
+ @options = hash || {}
54
+ @children = []
55
+ @style = Styles::ScreenableStyle.new
56
+ @panel = UI::Model::Panel.new(self)
57
+ end
58
+
59
+ # Add a Prop as a child of this Prop.
60
+ #
61
+ def add(child)
62
+ child.set_parent(self)
63
+ @children << child
64
+ @panel.add(child.panel)
65
+ end
66
+
67
+ # Same as add. Returns self so adding may be chained.
68
+ #
69
+ # prop << child1 << child2 << child3
70
+ #
71
+ def <<(child)
72
+ add(child)
73
+ return self
74
+ end
75
+
76
+ # Allows the adding of child Props using the PropBuilder DSL.
77
+ #
78
+ # prop.build do
79
+ # child1 do
80
+ # grand_child
81
+ # end
82
+ # child2
83
+ # end
84
+ #
85
+ def build(options = {}, &block)
86
+ require 'limelight/dsl/prop_builder'
87
+ builder = Limelight::DSL::PropBuilder.new(self)
88
+ builder.__install_instance_variables(options)
89
+ builder.__loader__ = scene.loader
90
+ builder.instance_eval(&block)
91
+ end
92
+
93
+ # Removes a child Prop. The child Prop will be parentless after removal.
94
+ #
95
+ def remove(child)
96
+ if children.delete(child)
97
+ scene.unindex_prop(child) if scene
98
+ @panel.remove(child.panel)
99
+ end
100
+ end
101
+
102
+ # Removes all child Props.
103
+ #
104
+ def remove_all
105
+ @panel.remove_all
106
+ @children.each { |child| scene.unindex_prop(child) } if scene
107
+ @children = []
108
+ end
109
+
110
+ # Injects the behavior of the specified Player into the Prop. The Player must be a Module.
111
+ #
112
+ def include_player(player_module)
113
+ unless self.is_a?(player_module)
114
+ extend player_module
115
+ self.casted if player_module.instance_methods.include?("casted")
116
+ end
117
+ end
118
+
119
+ def update #:nodoc:
120
+ return if (scene.nil? || !scene.visible)
121
+ @panel.doLayout
122
+ @panel.repaint
123
+ end
124
+
125
+ def update_now #:nodoc:
126
+ return if (scene.nil? || !scene.visible)
127
+ @panel.doLayout()
128
+ @panel.paintImmediately(0, 0, @panel.width, @panel.height)
129
+ end
130
+
131
+ # A hook to invoke behavior after a Prop is painted.
132
+ #
133
+ def after_painting(flag = true, &block)
134
+ if flag
135
+ @panel.after_paint_action = PaintAction.new(&block)
136
+ else
137
+ @panel.after_paint_action = nil
138
+ end
139
+ end
140
+
141
+ # Searches all descendant of the Prop (including itself) for Props with the specified name.
142
+ # Returns an Array of matching Props. Returns an empty Array if none are found.
143
+ #
144
+ def find_by_name(name, results = [])
145
+ results << self if @name == name
146
+ @children.each { |child| child.find_by_name(name, results) }
147
+ return results
148
+ end
149
+
150
+ # Sets the text of this Prop. If a prop is given text, it will become sterilized (it may not have any more children).
151
+ # Some Players such as text_box, will cause the text to appear in the text_box.
152
+ #
153
+ def text=(value)
154
+ @panel.text = value.to_s
155
+ end
156
+
157
+ # Returns the text of the Prop.
158
+ #
159
+ def text
160
+ return panel.text
161
+ end
162
+
163
+ # Returns the scene to which this prop belongs to.
164
+ #
165
+ def scene
166
+ return nil if @parent.nil?
167
+ @scene = @parent.scene if @scene.nil?
168
+ return @scene
169
+ end
170
+
171
+ # TODO get rid of me.... The Java Prop interface declares this method.
172
+ def loader
173
+ return scene.production.root;
174
+ end
175
+
176
+ # Returns the current Production this Prop lives in.
177
+ #
178
+ def production
179
+ return scene.production
180
+ end
181
+
182
+ def to_s #:nodoc:
183
+ return "#{self.class.name}[id: #{@id}, name: #{@name}]"
184
+ end
185
+
186
+ def inspect #:nodoc:
187
+ return self.to_s
188
+ end
189
+
190
+ # unusual name because it's not part of public api
191
+ def set_parent(parent) #:nodoc:
192
+ @parent = parent
193
+ if @parent.illuminated?
194
+ illuminate
195
+ end
196
+ end
197
+
198
+ # Allows the addition of extra initialization options. Will raise an exception if the Prop has already been
199
+ # illuminated (added to a scene).
200
+ #
201
+ def add_options(more_options)
202
+ raise "Too late to add options" if illuminated?
203
+ @options.merge!(more_options)
204
+ end
205
+
206
+ # Returns a Box representing the relative bounds of the Prop. Is useful with usign the Pen.
207
+ #
208
+ # box = prop.area
209
+ # box.x, box.y # represents the Prop's location within its parent Prop
210
+ # box.width, box.height # represents the Prop's dimensions
211
+ #
212
+ def area
213
+ return panel.get_bounding_box.clone
214
+ end
215
+
216
+ # Returns a Box representing the bounds inside the borders of the prop. If the Prop's style has no margin or
217
+ # border_width, then this will be equivalant to area.
218
+ #
219
+ def bordered_area
220
+ return panel.get_box_inside_borders.clone
221
+ end
222
+
223
+ # Returns a Box representing the bounds inside the padding of the prop. This is the area where child props may
224
+ # be located
225
+ #
226
+ def child_area
227
+ return panel.getChildConsumableArea().clone
228
+ end
229
+
230
+ # Returns a Pen object. Pen objects allow to you to draw directly on the screen, withing to bounds of this Prop.
231
+ #
232
+ def pen
233
+ return Pen.new(panel.getGraphics)
234
+ end
235
+
236
+ # Initiate an animation loop. Options may include :name (string), :updates_per_second (int: defaults to 60)
237
+ # An Animation object is returned.
238
+ # The provided block will be invoked :updates_per_second times per second until the Animation is stopped.
239
+ #
240
+ # @animation = prop.animate(:updates_per_second => 20) do
241
+ # prop.style.border_width = (prop.style.top_border_width.to_i + 1).to_s
242
+ # @animation.stop if prop.style.top_border_width.to_i > 60
243
+ # end
244
+ #
245
+ # This above example will cause the Prop's border to grow until it is 60 pixels wide.
246
+ #
247
+ def animate(options={}, &block)
248
+ animation = Animation.new(self, block, options)
249
+ animation.start
250
+ return animation
251
+ end
252
+
253
+ # Plays a sound on the computers audio output. The parameter is the filename of a .au sound file.
254
+ # This filename should relative to the root directory of the current Production, or an absolute path.
255
+ #
256
+ def play_sound(filename)
257
+ @panel.play_sound(scene.loader.path_to(filename))
258
+ end
259
+
260
+ # Luanches the spcified URL using the OS's default handlers. For example, opening a URL in a browser:
261
+ #
262
+ # launch('http://www.google.com')
263
+ #
264
+ # To create a link prop add an accessor on the player (say url) and use that in the prop definition
265
+ # Ex:
266
+ #
267
+ # link :text => "I am a link", :url => "http://www.8thlight.com"
268
+ def launch(url)
269
+ Context.instance.os.launch(url)
270
+ end
271
+
272
+ # GUI Events ##########################################
273
+
274
+ # TODO MDM - This may be very inefficient. If seems like these methods are generated for each instance of prop.
275
+ event2 :mouse_clicked
276
+ event :mouse_entered
277
+ event :mouse_exited
278
+ event2 :mouse_pressed
279
+ event2 :mouse_released
280
+ event :mouse_dragged
281
+ event :mouse_moved
282
+ event :key_typed
283
+ event :key_pressed
284
+ event :key_released
285
+ event :focus_gained
286
+ event :focus_lost
287
+ event :button_pressed
288
+ event :value_changed
289
+
290
+ # TODO Try to get me out of public scope
291
+ #
292
+ def illuminate #:nodoc:
293
+ if illuminated?
294
+ scene.index_prop(self) if @id
295
+ else
296
+ set_id(@options.delete(:id))
297
+ @name = @options.delete(:name)
298
+ @players = @options.delete(:players)
299
+ @additional_styles = @options.delete(:styles)
300
+
301
+ inherit_styles
302
+ scene.casting_director.fill_cast(self)
303
+ apply_options
304
+
305
+ @options = nil
306
+ end
307
+
308
+ children.each do |child|
309
+ child.illuminate
310
+ end
311
+ end
312
+
313
+ def illuminated? #:nodoc:
314
+ return @options.nil?
315
+ end
316
+
317
+ private ###############################################
318
+
319
+ def set_id(id)
320
+ return if id.nil? || id.to_s.empty?
321
+ @id = id.to_s
322
+ scene.index_prop(self)
323
+ end
324
+
325
+ def apply_options
326
+ @options.each_pair do |key, value|
327
+ setter_sym = "#{key.to_s}=".to_sym
328
+ if self.respond_to?(setter_sym)
329
+ self.send(setter_sym, value)
330
+ elsif self.style.respond_to?(setter_sym)
331
+ self.style.send(setter_sym, value.to_s)
332
+ elsif is_event_setter(key)
333
+ define_event(key, value)
334
+ end
335
+ end
336
+ end
337
+
338
+ def is_event_setter(symbol)
339
+ string_value = symbol.to_s
340
+ return string_value[0..2] == "on_" && self.class.events.include?(string_value[3..-1].to_sym)
341
+ end
342
+
343
+ def define_event(symbol, value)
344
+ event_name = symbol.to_s[3..-1]
345
+ self.instance_eval "def #{event_name}(event); #{value}; end"
346
+ end
347
+
348
+ def inherit_styles
349
+ style_names = []
350
+ style_names << @name unless @name.nil?
351
+ style_names += @additional_styles.gsub(',', ' ').split(' ') unless @additional_styles.nil?
352
+ style_names.each do |style_name|
353
+ new_style = scene.styles[style_name]
354
+ @style.add_extension(new_style) if new_style
355
+ new_hover_style = scene.styles["#{style_name}.hover"]
356
+ if new_hover_style
357
+ if @hover_style.nil?
358
+ @hover_style = new_hover_style
359
+ else
360
+ @hover_style.add_extension(new_hover_style)
361
+ end
362
+ end
363
+ end
364
+ end
365
+
366
+ end
367
+ end
@@ -0,0 +1,151 @@
1
+ #- Copyright � 2008-2009 8th Light, Inc. All Rights Reserved.
2
+ #- Limelight and all included source files are distributed under terms of the GNU LGPL.
3
+
4
+ require 'limelight/java_util'
5
+ require 'limelight/prop'
6
+ require 'limelight/button_group_cache'
7
+ require 'limelight/limelight_exception'
8
+ require 'limelight/file_loader'
9
+
10
+
11
+ module Limelight
12
+
13
+ # A Scene is a root Prop. Scenes may be loaded onto a Stage. In addition to being a Prop object, Scenes have a
14
+ # few extra attributes and behaviors.
15
+ #
16
+ class Scene < Prop
17
+ include UI::Api::Scene
18
+
19
+ attr_reader :button_groups, :casting_director, :cast
20
+ attr_accessor :stage, :visible, :production, :styles
21
+ getters :stage, :loader, :styles
22
+ setters :stage
23
+ event :scene_opened
24
+
25
+ alias :visible? :visible
26
+
27
+ def initialize(options={})
28
+ path = options.delete(:path) || ""
29
+ @root = FileLoader.for_root(path)
30
+ super(options)
31
+ @button_groups = ButtonGroupCache.new
32
+ @prop_index = {}
33
+ @cast = Module.new
34
+ # illuminate
35
+ end
36
+
37
+ # Returns self. A Scene is it's own scene.
38
+ #
39
+ def scene
40
+ return self
41
+ end
42
+
43
+ # Returns the path to the root directory of the Scene
44
+ #
45
+ def path
46
+ return @root.root
47
+ end
48
+
49
+ # Returns the path to the Scene's props file
50
+ #
51
+ def props_file
52
+ return @root.path_to("props.rb")
53
+ end
54
+
55
+ # Returns the path to the Scene's props file
56
+ #
57
+ def styles_file
58
+ return @root.path_to("styles.rb")
59
+ end
60
+
61
+ # def add_options(options) #:nodoc:
62
+ # @options = options
63
+ # illuminate
64
+ # end
65
+
66
+ # Creates the menu bar for the Scene
67
+ #
68
+ def menu_bar
69
+ return DSL::MenuBar.build(self) do
70
+ menu("File") do
71
+ item("Open", :open_chosen_production)
72
+ item("Refresh", :reload)
73
+ end
74
+ end
75
+ end
76
+
77
+ # Opens a FileChooser for a new Production. Loads the chosen Production.
78
+ #
79
+ def open_chosen_production
80
+ options = { :title => "Open New Limelight Production", :description => "Limelight Production", :directory => @directory }
81
+ chosen_file = stage.choose_file(options) { |file| Util.is_limelight_scene?(file) || Util.is_limelight_production?(file) }
82
+ if chosen_file
83
+ @directory = File.dirname(chosen_file)
84
+ open_production(chosen_file)
85
+ end
86
+ end
87
+
88
+ # Creates a new Producer to open the specified Production.
89
+ #
90
+ def open_production(production_path)
91
+ Thread.new { Studio.open(production_path) }
92
+ end
93
+
94
+ # Opens the specified Scene on the Stage currently occupied by this Scene.
95
+ # TODO It doesn't quite make sense that a scene loads other scene. It has to replace itself?
96
+ #
97
+ def load(scene_name)
98
+ @production.producer.open_scene(scene_name, @stage)
99
+ end
100
+
101
+ # Add the Prop to the index. Provides fast lookup by id.
102
+ #
103
+ def index_prop(prop)
104
+ return if prop.id.nil? || prop.id.empty?
105
+ indexee = @prop_index[prop.id]
106
+ if indexee.nil?
107
+ @prop_index[prop.id] = prop
108
+ else
109
+ raise LimelightException.new("Duplicate id: #{prop.id}") if indexee != prop
110
+ end
111
+ end
112
+
113
+ # Removed the Prop from the index.
114
+ #
115
+ def unindex_prop(prop)
116
+ unindex_child_props(prop)
117
+ @prop_index.delete(prop.id) if prop.id
118
+ end
119
+
120
+ # Returns a Prop with the specified id. Returns nil id the Prop doesn't exist in the Scene.
121
+ #
122
+ def find(id)
123
+ return @prop_index[id.to_s]
124
+ end
125
+
126
+ def illuminate #:nodoc:
127
+ @styles = @options.delete(:styles_hash) || @styles || {}
128
+ @casting_director = @options.delete(:casting_director) if @options.has_key?(:casting_director)
129
+ @path = @options.delete(:path) if @options.has_key?(:path)
130
+ @production = @options.delete(:production) if @options.has_key?(:production)
131
+ super
132
+ end
133
+
134
+ private ###############################################
135
+
136
+ def unindex_child_props(prop)
137
+ prop.children.each do |child|
138
+ if child.children.empty?
139
+ @prop_index.delete(child.id)
140
+ else
141
+ unindex_prop(child)
142
+ end
143
+ end
144
+ end
145
+
146
+ def reload
147
+ load(File.basename(path))
148
+ end
149
+
150
+ end
151
+ end