limelight 0.2.1-java → 0.3.0-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (111) hide show
  1. data/bin/ll.bat +1 -1
  2. data/lib/i4jruntime.jar +0 -0
  3. data/lib/junit-4.4.jar +0 -0
  4. data/lib/limelight.jar +0 -0
  5. data/lib/limelight/animation.rb +3 -3
  6. data/lib/limelight/builtin/players.rb +2 -1
  7. data/lib/limelight/builtin/players/combo_box.rb +8 -2
  8. data/lib/limelight/builtin/players/image.rb +47 -0
  9. data/lib/limelight/builtin/styles.rb +1 -1
  10. data/lib/limelight/casting_director.rb +70 -39
  11. data/lib/limelight/commands/command.rb +150 -0
  12. data/lib/limelight/commands/create_command.rb +79 -0
  13. data/lib/limelight/commands/freeze_command.rb +113 -0
  14. data/lib/limelight/commands/open_command.rb +49 -0
  15. data/lib/limelight/commands/pack_command.rb +45 -0
  16. data/lib/limelight/dsl/build_exception.rb +51 -0
  17. data/lib/limelight/dsl/menu_bar.rb +71 -0
  18. data/lib/limelight/dsl/production_builder.rb +71 -0
  19. data/lib/limelight/dsl/prop_builder.rb +155 -0
  20. data/lib/limelight/dsl/stage_builder.rb +105 -0
  21. data/lib/limelight/dsl/styles_builder.rb +134 -0
  22. data/lib/limelight/file_loader.rb +46 -0
  23. data/lib/limelight/gems.rb +45 -0
  24. data/lib/limelight/java_couplings.rb +7 -2
  25. data/lib/limelight/java_util.rb +2 -15
  26. data/lib/limelight/main.rb +7 -5
  27. data/lib/limelight/producer.rb +87 -66
  28. data/lib/limelight/production.rb +42 -4
  29. data/lib/limelight/prop.rb +84 -70
  30. data/lib/limelight/scene.rb +75 -20
  31. data/lib/limelight/specs/spec_helper.rb +58 -0
  32. data/lib/limelight/stage.rb +11 -6
  33. data/lib/limelight/string.rb +35 -0
  34. data/lib/limelight/studio.rb +29 -0
  35. data/lib/limelight/templates/production_templater.rb +42 -0
  36. data/lib/limelight/templates/scene_templater.rb +41 -0
  37. data/lib/limelight/templates/sources/freezing/limelight_init.rb.template +5 -0
  38. data/lib/limelight/templates/sources/production/init.rb.template +15 -0
  39. data/lib/limelight/templates/sources/production/production.rb.template +9 -0
  40. data/lib/limelight/templates/sources/production/stages.rb.template +17 -0
  41. data/lib/limelight/templates/sources/production/styles.rb.template +12 -0
  42. data/lib/limelight/templates/sources/scene/props.rb.template +6 -0
  43. data/lib/limelight/templates/sources/scene/styles.rb.template +18 -0
  44. data/lib/limelight/templates/templater.rb +128 -0
  45. data/lib/limelight/templates/templater_logger.rb +36 -0
  46. data/lib/limelight/theater.rb +21 -7
  47. data/lib/limelight/util.rb +22 -6
  48. data/lib/limelight/version.rb +2 -2
  49. data/productions/examples/8thlight.com/styles.rb +1 -1
  50. data/productions/examples/langstons_ant/html_javascript/ant.html +1 -1
  51. data/productions/examples/langstons_ant/init.rb +1 -0
  52. data/productions/examples/langstons_ant/players/log.rb +2 -2
  53. data/productions/examples/langstons_ant/players/world.rb +0 -26
  54. data/productions/examples/sandbox.llp +0 -0
  55. data/productions/examples/sandbox/click_me/players/chromaton.rb +10 -4
  56. data/productions/examples/sandbox/floaters/players/floater.rb +4 -2
  57. data/productions/examples/sandbox/gradients/players/spinner.rb +5 -1
  58. data/productions/examples/sandbox/gradients/players/teaser.rb +2 -2
  59. data/productions/examples/sandbox/gradients/players/wave.rb +2 -2
  60. data/productions/examples/sandbox/gradients/players/waves.rb +2 -2
  61. data/productions/examples/sandbox/header.rb +1 -0
  62. data/productions/examples/sandbox/images/logo.png +0 -0
  63. data/productions/examples/sandbox/images_scene/props.rb +25 -0
  64. data/productions/examples/sandbox/images_scene/styles.rb +30 -0
  65. data/productions/examples/sandbox/inputs/styles.rb +1 -1
  66. data/productions/examples/sandbox/scrolling/props.rb +12 -12
  67. data/productions/examples/sandbox/teaser/players/fader.rb +2 -8
  68. data/productions/stage_composer/inspector/styles.rb +2 -2
  69. data/productions/startup/styles.rb +2 -2
  70. data/spec/builtin/players/button_spec.rb +0 -1
  71. data/spec/builtin/players/image_spec.rb +41 -0
  72. data/spec/casting_director_spec.rb +114 -44
  73. data/spec/commands/command_spec.rb +18 -0
  74. data/spec/commands/create_command_spec.rb +74 -0
  75. data/spec/commands/freeze_command_spec.rb +59 -0
  76. data/spec/commands/open_command_spec.rb +30 -0
  77. data/spec/commands/pack_command_spec.rb +23 -0
  78. data/spec/dsl/production_builder_spec.rb +46 -0
  79. data/spec/{prop_builder_spec.rb → dsl/prop_builder_spec.rb} +80 -24
  80. data/spec/{stage_builder_spec.rb → dsl/stage_builder_spec.rb} +4 -4
  81. data/spec/{styles_builder_spec.rb → dsl/styles_builder_spec.rb} +6 -6
  82. data/spec/{loaders/file_loader_spec.rb → file_loader_spec.rb} +4 -4
  83. data/spec/gems_spec.rb +83 -0
  84. data/spec/java_util_spec.rb +1 -17
  85. data/spec/main_spec.rb +17 -0
  86. data/spec/producer_spec.rb +89 -79
  87. data/spec/production_spec.rb +28 -3
  88. data/spec/prop_spec.rb +82 -16
  89. data/spec/scene_spec.rb +73 -3
  90. data/spec/spec_helper.rb +37 -1
  91. data/spec/stage_spec.rb +10 -1
  92. data/spec/string_spec.rb +35 -0
  93. data/spec/studio_spec.rb +14 -0
  94. data/spec/styles_spec.rb +14 -0
  95. data/spec/templates/production_templater_spec.rb +44 -0
  96. data/spec/templates/scene_templater_spec.rb +25 -0
  97. data/spec/templates/templater_logger_spec.rb +38 -0
  98. data/spec/templates/templater_spec.rb +104 -0
  99. data/spec/theater_spec.rb +12 -21
  100. metadata +75 -23
  101. data/bin/icons/splash.png +0 -0
  102. data/lib/limelight/build_exception.rb +0 -48
  103. data/lib/limelight/commands.rb +0 -52
  104. data/lib/limelight/loaders/file_scene_loader.rb +0 -49
  105. data/lib/limelight/menu_bar.rb +0 -68
  106. data/lib/limelight/production_builder.rb +0 -66
  107. data/lib/limelight/prop_builder.rb +0 -119
  108. data/lib/limelight/stage_builder.rb +0 -103
  109. data/lib/limelight/styles_builder.rb +0 -131
  110. data/spec/commands_spec.rb +0 -34
  111. data/spec/production_builder_spec.rb +0 -48
@@ -2,6 +2,7 @@
2
2
  #- Limelight and all included source files are distributed under terms of the GNU LGPL.
3
3
 
4
4
  require 'limelight/limelight_exception'
5
+ require 'limelight/file_loader'
5
6
 
6
7
  module Limelight
7
8
 
@@ -51,13 +52,13 @@ module Limelight
51
52
 
52
53
  end
53
54
 
54
- attr_reader :producer, :theater, :name
55
+ attr_reader :name, :root
56
+ attr_accessor :producer, :theater
55
57
 
56
58
  # Users typically need not create Production objects.
57
59
  #
58
- def initialize(producer, theater)
59
- @producer = producer
60
- @theater = theater
60
+ def initialize(path)
61
+ @root = FileLoader.for_root(path)
61
62
  self.class.index(self)
62
63
  end
63
64
 
@@ -67,6 +68,43 @@ module Limelight
67
68
  self.class.error_if_duplicate_name(value)
68
69
  @name = value
69
70
  end
71
+
72
+ # Return the path to the root directory of the production
73
+ #
74
+ def path
75
+ return @root.root
76
+ end
77
+
78
+ # Returns the path to the production's init file
79
+ #
80
+ def init_file
81
+ return @root.path_to("init.rb")
82
+ end
83
+
84
+ # Returns the path to the production's stages file
85
+ #
86
+ def stages_file
87
+ return @root.path_to("stages.rb")
88
+ end
89
+
90
+ # Returns the path to the production's styles file
91
+ #
92
+ def styles_file
93
+ return @root.path_to("styles.rb")
94
+ end
95
+
96
+ # Returns the path to the production's gems directory
97
+ #
98
+ def gems_directory
99
+ return @root.path_to("__resources/gems")
100
+ end
101
+
102
+ # Returns the path to the named Scene's directory within the Production
103
+ #
104
+ def scene_directory(name)
105
+ return @root.root if name == :root
106
+ return @root.path_to(name)
107
+ end
70
108
 
71
109
  end
72
110
 
@@ -16,7 +16,7 @@ module Limelight
16
16
  # the root Prop of a tree.
17
17
  #
18
18
  class Prop
19
-
19
+
20
20
  class << self
21
21
 
22
22
  def event(event_symbol)
@@ -29,14 +29,17 @@ module Limelight
29
29
  return @events
30
30
  end
31
31
 
32
+ def event2(event_symbol)
33
+ define_method("accepts_#{event_symbol}".to_sym) { return self.respond_to?(event_symbol) }
34
+ end
35
+
32
36
  end
33
-
37
+
34
38
  include UI::Api::Prop
35
-
39
+
36
40
  attr_reader :panel #:nodoc:
37
- attr_reader :style, :hover_style, :children, :scene, :parent, :name, :id, :players
38
- getters :panel, :style, :hover_style, :scene, :name, :text #:nodoc:
39
- setters :text #:nodoc:
41
+ attr_reader :style, :hover_style, :children, :parent, :name, :id, :players
42
+ getters :panel, :style, :hover_style, :name, :scene, :loader #:nodoc:
40
43
 
41
44
  # When creating a Prop, an optional Hash is accepted. These are called initialization options.
42
45
  # The key/value pairs in the initialiaztion options will be used to
@@ -48,6 +51,7 @@ module Limelight
48
51
  @children = []
49
52
  @style = Styles::ScreenableStyle.new
50
53
  @panel = UI::Model::Panel.new(self)
54
+ @illuminated = false
51
55
  end
52
56
 
53
57
  # Add a Prop as a child of this Prop.
@@ -77,8 +81,9 @@ module Limelight
77
81
  # end
78
82
  #
79
83
  def build(&block)
80
- require 'limelight/prop_builder'
81
- builder = Limelight::PropBuilder.new(self)
84
+ require 'limelight/dsl/prop_builder'
85
+ builder = Limelight::DSL::PropBuilder.new(self)
86
+ builder.__loader__ = scene.loader
82
87
  builder.instance_eval(&block)
83
88
  end
84
89
 
@@ -86,6 +91,7 @@ module Limelight
86
91
  #
87
92
  def remove(child)
88
93
  if children.delete(child)
94
+ scene.unindex_prop(child) if scene
89
95
  @panel.remove(child.panel)
90
96
  end
91
97
  end
@@ -94,6 +100,7 @@ module Limelight
94
100
  #
95
101
  def remove_all
96
102
  @panel.remove_all
103
+ @children.each { |child| scene.unindex_prop(child) } if scene
97
104
  @children = []
98
105
  end
99
106
 
@@ -102,18 +109,18 @@ module Limelight
102
109
  def include_player(player_module)
103
110
  extend player_module unless self.is_a?(player_module)
104
111
  end
105
-
112
+
106
113
  def update #:nodoc:
107
- return if(@scene.nil? || !@scene.visible)
114
+ return if (scene.nil? || !scene.visible)
108
115
  @panel.doLayout
109
116
  @panel.repaint
110
117
  end
111
-
118
+
112
119
  def update_now #:nodoc:
113
- return if(@scene.nil? || !@scene.visible)
120
+ return if (scene.nil? || !scene.visible)
114
121
  @panel.doLayout()
115
122
  @panel.paintImmediately(0, 0, @panel.width, @panel.height)
116
- end
123
+ end
117
124
 
118
125
  # A hook to invoke behavior after a Prop is painted.
119
126
  #
@@ -125,17 +132,6 @@ module Limelight
125
132
  end
126
133
  end
127
134
 
128
- # Searches all children for a Prop with the given id. Returns the desired Prop if found, nil otherwise.
129
- #
130
- def find(id)
131
- return self if @id == id
132
- @children.each do |child|
133
- result = child.find(id)
134
- return result if result
135
- end
136
- return nil
137
- end
138
-
139
135
  # Searches all children for Props with the specified name. Returns an Array of matching Props. Returns an
140
136
  # empty Array is none are found.
141
137
  #
@@ -157,10 +153,18 @@ module Limelight
157
153
  def text
158
154
  return panel.text
159
155
  end
160
-
161
- #TODO - MDM - DELETE ME
162
- def stage #:nodoc:
163
- return scene.stage
156
+
157
+ # Returns the scene to which this prop belongs to.
158
+ #
159
+ def scene
160
+ return nil if @parent.nil?
161
+ @scene = @parent.scene if @scene.nil?
162
+ return @scene
163
+ end
164
+
165
+ # TODO get rid of me.... The Java Prop interface declares this method.
166
+ def loader
167
+ return scene.production.root;
164
168
  end
165
169
 
166
170
  # Returns the current Production this Prop lives in.
@@ -168,27 +172,19 @@ module Limelight
168
172
  def production
169
173
  return scene.production
170
174
  end
171
-
175
+
172
176
  def to_s #:nodoc:
173
177
  return "#{self.class.name}[id: #{@id}, name: #{@name}]"
174
178
  end
175
-
179
+
176
180
  def inspect #:nodoc:
177
181
  return self.to_s
178
182
  end
179
-
183
+
180
184
  # unusual name because it's not part of public api
181
185
  def set_parent(parent) #:nodoc:
182
186
  @parent = parent
183
- set_scene parent.scene
184
- end
185
-
186
- # unusual name because it's not part of public api
187
- def set_scene(scene) #:nodoc:
188
- return if scene == @scene || scene.nil?
189
- @scene = scene
190
- illuminate
191
- children.each { |child| child.set_scene(scene) }
187
+ illuminate if @parent.illuminated?
192
188
  end
193
189
 
194
190
  # Allows the addition of extra initialization options. Will raise an exception if the Prop has already been
@@ -206,7 +202,7 @@ module Limelight
206
202
  # box.width, box.height # represents the Prop's dimensions
207
203
  #
208
204
  def area
209
- return panel.get_box.clone
205
+ return panel.get_bounding_box.clone
210
206
  end
211
207
 
212
208
  # Returns a Box representing the bounds inside the borders of the prop. If the Prop's style has no margin or
@@ -226,7 +222,7 @@ module Limelight
226
222
  # This filename should relative to the root directory of the current Production, or an absolute path.
227
223
  #
228
224
  def play_sound(filename)
229
- @panel.play_sound(@scene.loader.path_to(filename))
225
+ @panel.play_sound(scene.loader.path_to(filename))
230
226
  end
231
227
 
232
228
  # Initiate an animation loop. Options may include :name (string), :updates_per_second (int: defaults to 60)
@@ -245,14 +241,14 @@ module Limelight
245
241
  animation.start
246
242
  return animation
247
243
  end
248
-
244
+
249
245
  # GUI Events ##########################################
250
246
 
251
- event :mouse_clicked
247
+ event2 :mouse_clicked
252
248
  event :mouse_entered
253
249
  event :mouse_exited
254
- event :mouse_pressed
255
- event :mouse_released
250
+ event2 :mouse_pressed
251
+ event2 :mouse_released
256
252
  event :mouse_dragged
257
253
  event :mouse_moved
258
254
  event :key_typed
@@ -262,29 +258,47 @@ module Limelight
262
258
  event :focus_lost
263
259
  event :button_pressed
264
260
  event :value_changed
265
-
266
- private ###############################################
267
-
268
- def illuminate
261
+
262
+ # TODO Try to get me our of public scope
263
+ #
264
+ def illuminate #:nodoc:
269
265
  return if @options.nil?
270
266
 
271
- @id = @options.delete(:id)
267
+ set_id(@options.delete(:id))
272
268
  @name = @options.delete(:name)
273
269
  @players = @options.delete(:players)
274
270
  @additional_styles = @options.delete(:styles)
275
-
271
+
276
272
  inherit_styles
277
- @scene.casting_director.fill_cast(self)
273
+ scene.casting_director.fill_cast(self)
278
274
  apply_options
279
-
275
+
280
276
  @options = nil
277
+
278
+ @illuminated = true
279
+
280
+ children.each do |child|
281
+ child.illuminate unless child.illuminated?
282
+ end
283
+ end
284
+
285
+ def illuminated? #:nodoc:
286
+ return @illuminated
281
287
  end
282
-
288
+
289
+ private ###############################################
290
+
291
+ def set_id(id)
292
+ return if id.nil? || id.to_s.empty?
293
+ @id = id.to_s
294
+ scene.index_prop(self)
295
+ end
296
+
283
297
  def apply_options
284
298
  @options.each_pair do |key, value|
285
- setter_sym = "#{key.to_s}=".to_sym
299
+ setter_sym = "#{key.to_s}=".to_sym
286
300
  if self.respond_to?(setter_sym)
287
- self.send(setter_sym, value)
301
+ self.send(setter_sym, value)
288
302
  elsif self.style.respond_to?(setter_sym)
289
303
  self.style.send(setter_sym, value.to_s)
290
304
  elsif is_event_setter(key)
@@ -292,23 +306,23 @@ module Limelight
292
306
  end
293
307
  end
294
308
  end
295
-
309
+
296
310
  def is_event_setter(symbol)
297
311
  string_value = symbol.to_s
298
312
  return string_value[0..2] == "on_" and self.events.include?(string_value[3..-1].to_sym)
299
313
  end
300
-
314
+
301
315
  def define_event(symbol, value)
302
316
  event_name = symbol.to_s[3..-1]
303
317
  self.instance_eval "def #{event_name}(event); #{value}; end"
304
318
  end
305
-
319
+
306
320
  def inherit_styles
307
321
  style_names = []
308
322
  style_names << @name unless @name.nil?
309
323
  style_names += @additional_styles.gsub(',', ' ').split(' ') unless @additional_styles.nil?
310
- style_names.each do |style_name|
311
- new_style = @scene.styles[style_name]
324
+ style_names.each do |style_name|
325
+ new_style = scene.styles[style_name]
312
326
  @style.add_extension(new_style) if new_style
313
327
  new_hover_style = scene.styles["#{style_name}.hover"]
314
328
  if new_hover_style
@@ -321,13 +335,13 @@ module Limelight
321
335
  end
322
336
  end
323
337
 
324
- # Why is this method here? No one appears to use it.
325
- # def disinherit_styles
326
- # return if @name.nil?
327
- # old_style = @scene.styles[@name]
328
- # @style.remove_extension(old_style) if old_style
329
- # @hover_style = nil
330
- # end
331
-
338
+ # Why is this method here? No one appears to use it.
339
+ # def disinherit_styles
340
+ # return if @name.nil?
341
+ # old_style = scene.styles[@name]
342
+ # @style.remove_extension(old_style) if old_style
343
+ # @hover_style = nil
344
+ # end
345
+
332
346
  end
333
347
  end
@@ -4,6 +4,8 @@
4
4
  require 'limelight/java_util'
5
5
  require 'limelight/prop'
6
6
  require 'limelight/button_group_cache'
7
+ require 'limelight/limelight_exception'
8
+ require 'limelight/file_loader'
7
9
 
8
10
  module Limelight
9
11
 
@@ -11,31 +13,58 @@ module Limelight
11
13
  # few extra attributes and behaviors.
12
14
  #
13
15
  class Scene < Prop
14
-
16
+
15
17
  include UI::Api::Scene
16
-
17
- attr_reader :button_groups, :styles, :casting_director
18
- attr_accessor :stage, :loader, :visible, :path, :production
18
+
19
+ attr_reader :button_groups, :casting_director, :cast
20
+ attr_accessor :stage, :visible, :production, :styles
19
21
  getters :stage, :loader, :styles
20
22
  setters :stage
21
23
  event :scene_opened
22
-
24
+
23
25
  def initialize(options={})
26
+ path = options.delete(:path) || ""
27
+ @root = FileLoader.for_root(path)
24
28
  super(options)
25
- @scene = self
26
29
  @button_groups = ButtonGroupCache.new
27
- illuminate
30
+ @prop_index = {}
31
+ @cast = Module.new
32
+ # illuminate
33
+ end
34
+
35
+ # Returns self. A Scene is it's own scene.
36
+ #
37
+ def scene
38
+ return self
39
+ end
40
+
41
+ # Returns the path to the root directory of the Scene
42
+ #
43
+ def path
44
+ return @root.root
45
+ end
46
+
47
+ # Returns the path to the Scene's props file
48
+ #
49
+ def props_file
50
+ return @root.path_to("props.rb")
28
51
  end
29
-
30
- def add_options(options) #:nodoc:
31
- @options = options
32
- illuminate
52
+
53
+ # Returns the path to the Scene's props file
54
+ #
55
+ def styles_file
56
+ return @root.path_to("styles.rb")
33
57
  end
34
58
 
59
+ # def add_options(options) #:nodoc:
60
+ # @options = options
61
+ # illuminate
62
+ # end
63
+
35
64
  # Creates the menu bar for the Scene
36
65
  #
37
66
  def menu_bar
38
- return MenuBar.build(self) do
67
+ return DSL::MenuBar.build(self) do
39
68
  menu("File") do
40
69
  item("Open", :open_chosen_production)
41
70
  item("Refresh", :reload)
@@ -61,23 +90,49 @@ module Limelight
61
90
  producer.open
62
91
  end
63
92
 
64
- # Opens the specified Scene on the Stage currently occupied by this Scene.s
93
+ # Opens the specified Scene on the Stage currently occupied by this Scene.
94
+ # TODO It doesn't quite make sense that a scene loads other scene. It has to replace itself?
65
95
  #
66
96
  def load(scene_name)
67
97
  @production.producer.open_scene(scene_name, @stage)
68
98
  end
69
-
70
- private ###############################################
71
-
72
- def illuminate
99
+
100
+ # Add the Prop to the index. Provides fast lookup by id.
101
+ #
102
+ def index_prop(prop)
103
+ return if prop.id.nil? || prop.id.empty?
104
+ indexee = @prop_index[prop.id]
105
+ if indexee.nil?
106
+ @prop_index[prop.id] = prop
107
+ else
108
+ raise LimelightException.new("Duplicate id: #{prop.id}") if indexee != prop
109
+ end
110
+ end
111
+
112
+ # Removed the Prop from the index.
113
+ #
114
+ def unindex_prop(prop)
115
+ @prop_index.delete(prop.id) if prop.id
116
+ end
117
+
118
+ # Returns a Prop with the specified id. Returns nil id the Prop doesn't exist in the Scene.
119
+ #
120
+ def find(id)
121
+ return @prop_index[id.to_s]
122
+ end
123
+
124
+ def illuminate #:nodoc:
73
125
  @styles = @options.has_key?(:styles) ? @options.delete(:styles) : (@styles || {})
74
126
  @casting_director = @options.delete(:casting_director) if @options.has_key?(:casting_director)
127
+ @path = @options.delete(:path) if @options.has_key?(:path)
75
128
  super
76
129
  end
77
-
130
+
131
+ private ###############################################
132
+
78
133
  def reload
79
- load(@path)
134
+ load(File.basename(path))
80
135
  end
81
-
136
+
82
137
  end
83
138
  end