limelight 0.2.0-java → 0.2.1-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. data/bin/limelight +2 -3
  2. data/lib/limelight.jar +0 -0
  3. data/lib/limelight/animation.rb +32 -12
  4. data/lib/limelight/build_exception.rb +3 -0
  5. data/lib/limelight/builtin/players/button.rb +17 -2
  6. data/lib/limelight/builtin/players/check_box.rb +21 -2
  7. data/lib/limelight/builtin/players/combo_box.rb +31 -3
  8. data/lib/limelight/builtin/players/combo_box_popup_list.rb +1 -1
  9. data/lib/limelight/builtin/players/combo_box_popup_list_item.rb +1 -1
  10. data/lib/limelight/builtin/players/curtains.rb +1 -1
  11. data/lib/limelight/builtin/players/radio_button.rb +27 -3
  12. data/lib/limelight/builtin/players/text_area.rb +11 -2
  13. data/lib/limelight/builtin/players/text_box.rb +11 -2
  14. data/lib/limelight/button_group_cache.rb +2 -2
  15. data/lib/limelight/casting_director.rb +6 -1
  16. data/lib/limelight/commands.rb +10 -24
  17. data/lib/limelight/file_chooser.rb +16 -3
  18. data/lib/limelight/file_filter.rb +10 -3
  19. data/lib/limelight/java_couplings.rb +11 -10
  20. data/lib/limelight/java_util.rb +36 -3
  21. data/lib/limelight/limelight_exception.rb +3 -1
  22. data/lib/limelight/loaders/file_scene_loader.rb +1 -1
  23. data/lib/limelight/main.rb +108 -0
  24. data/lib/limelight/menu_bar.rb +31 -12
  25. data/lib/limelight/paint_action.rb +4 -2
  26. data/lib/limelight/pen.rb +39 -9
  27. data/lib/limelight/producer.rb +35 -7
  28. data/lib/limelight/production.rb +18 -9
  29. data/lib/limelight/production_builder.rb +22 -5
  30. data/lib/limelight/prop.rb +127 -45
  31. data/lib/limelight/prop_builder.rb +70 -11
  32. data/lib/limelight/scene.rb +25 -21
  33. data/lib/limelight/stage.rb +68 -18
  34. data/lib/limelight/stage_builder.rb +68 -27
  35. data/lib/limelight/styles.rb +327 -30
  36. data/lib/limelight/styles_builder.rb +91 -21
  37. data/lib/limelight/theater.rb +23 -11
  38. data/lib/limelight/util.rb +28 -6
  39. data/lib/limelight/version.rb +1 -1
  40. data/productions/startup/players/browse_button.rb +1 -1
  41. data/spec/builtin/players/check_box_spec.rb +1 -1
  42. data/spec/builtin/players/radio_button_spec.rb +2 -2
  43. data/spec/builtin/players/text_area_spec.rb +1 -1
  44. data/spec/builtin/players/text_box_spec.rb +1 -1
  45. data/spec/commands_spec.rb +4 -3
  46. data/spec/prop_builder_spec.rb +40 -29
  47. data/spec/prop_spec.rb +5 -1
  48. data/spec/stage_spec.rb +15 -15
  49. data/spec/styles_spec.rb +36 -0
  50. data/spec/theater_spec.rb +8 -8
  51. metadata +6 -3
@@ -4,7 +4,9 @@
4
4
  require 'limelight/limelight_exception'
5
5
 
6
6
  module Limelight
7
-
7
+
8
+ # A Theater represents a group of Stages. Productions require a Theater in which to open.
9
+ #
8
10
  class Theater
9
11
 
10
12
  include UI::Api::Theater
@@ -12,26 +14,36 @@ module Limelight
12
14
  attr_reader :active_stage
13
15
 
14
16
  def initialize
15
- @stages = {}
17
+ @__stages__ = {}
16
18
  end
17
-
19
+
20
+ # Returns an Array of Stages that belong to this Theater.
21
+ #
18
22
  def stages
19
- return @stages.values
23
+ return @__stages__.values
20
24
  end
21
-
25
+
26
+ # Returns the Stage with the spcified name, nil if none exist with the specified name.
27
+ #
22
28
  def [](stage_name)
23
- return @stages[stage_name]
29
+ return @__stages__[stage_name]
24
30
  end
25
-
31
+
32
+ # Adds a Stage to the Theater. Raises an exception is the name of the Stage is duplicated.
33
+ #
26
34
  def add_stage(stage)
27
- raise LimelightException.new("Duplicate stage name: '#{stage.name}'") if @stages[stage.name]
28
- @stages[stage.name] = stage
35
+ raise LimelightException.new("Duplicate stage name: '#{stage.name}'") if @__stages__[stage.name]
36
+ @__stages__[stage.name] = stage
29
37
  end
30
-
38
+
39
+ # Lets the Theater know which stage has the limelight (currently active).
40
+ #
31
41
  def stage_activated(stage)
32
42
  @active_stage = stage
33
43
  end
34
-
44
+
45
+ # If no Stages are added, the Theater will provide a default Stage named "Limelight".
46
+ #
35
47
  def default_stage
36
48
  add_stage(Stage.new(self, "Limelight")) if self["Limelight"].nil?
37
49
  return self["Limelight"]
@@ -2,17 +2,25 @@
2
2
  #- Limelight and all included source files are distributed under terms of the GNU LGPL.
3
3
 
4
4
  module Limelight
5
-
5
+
6
+ # Utility methods for Limelight
7
+ #
6
8
  module Util
7
-
9
+
10
+ # Returns true if the specified file is a directory and has the structure of a Scene.
11
+ #
8
12
  def self.is_limelight_scene?(file)
9
13
  return is_directory_containing_file?(file, "props.rb")
10
14
  end
11
-
15
+
16
+ # Returns true if the specified file is a directory and has the structure of a Production.
17
+ #
12
18
  def self.is_limelight_production?(file)
13
19
  return is_directory_containing_file?(file, "stages.rb")
14
20
  end
15
-
21
+
22
+ # Returns true of the file is a directory containing an entry named file_name.
23
+ #
16
24
  def self.is_directory_containing_file?(file, file_name)
17
25
  if file.is_a? String
18
26
  return File.directory?(file) && File.exists?(File.join(file, file_name))
@@ -20,7 +28,21 @@ module Limelight
20
28
  return file.isDirectory() && File.exists?(File.join(file.absolute_path, file_name))
21
29
  end
22
30
  end
23
-
31
+
32
+ # Removed all methods from a class except instance_eval and methods starting with __.
33
+ # This is used by the DSL Builder classes to minimize reserved keywords.
34
+ #
35
+ def self.lobotomize(klass)
36
+ klass.methods.each do |method_name|
37
+ unless method_name[0..1] == "__" || method_name == "instance_eval"
38
+ begin
39
+ klass.instance_eval "undef_method :#{method_name}"
40
+ rescue Exception => e
41
+ end
42
+ end
43
+ end
44
+ end
45
+
24
46
  end
25
-
47
+
26
48
  end
@@ -6,7 +6,7 @@ module Limelight
6
6
  unless defined? MAJOR
7
7
  MAJOR = 0
8
8
  MINOR = 2
9
- TINY = 0
9
+ TINY = 1
10
10
 
11
11
  STRING = [MAJOR, MINOR, TINY].join('.')
12
12
  TAG = "REL_" + [MAJOR, MINOR, TINY].join('_')
@@ -4,7 +4,7 @@
4
4
  module BrowseButton
5
5
 
6
6
  def mouse_clicked(e)
7
- scene.open_chosen_scene
7
+ scene.open_chosen_production
8
8
  end
9
9
 
10
10
  end
@@ -9,7 +9,7 @@ describe Limelight::Builtin::Players::CheckBox do
9
9
 
10
10
  before(:each) do
11
11
  @prop = Limelight::Prop.new
12
- @prop.add_controller(Limelight::Builtin::Players::CheckBox)
12
+ @prop.include_player(Limelight::Builtin::Players::CheckBox)
13
13
  end
14
14
 
15
15
  it "should have a TextField" do
@@ -38,12 +38,12 @@ describe Limelight::Builtin::Players::RadioButton do
38
38
 
39
39
  prop2 = Limelight::Prop.new
40
40
  @scene << prop2
41
- prop2.add_controller(Limelight::Builtin::Players::RadioButton)
41
+ prop2.include_player(Limelight::Builtin::Players::RadioButton)
42
42
  prop2.group = "group 1"
43
43
 
44
44
  prop3 = Limelight::Prop.new
45
45
  @scene << prop3
46
- prop3.add_controller(Limelight::Builtin::Players::RadioButton)
46
+ prop3.include_player(Limelight::Builtin::Players::RadioButton)
47
47
  prop3.group = "group 2"
48
48
 
49
49
  group1 = @scene.button_groups["group 1"]
@@ -9,7 +9,7 @@ describe Limelight::Builtin::Players::TextArea do
9
9
 
10
10
  before(:each) do
11
11
  @prop = Limelight::Prop.new
12
- @prop.add_controller(Limelight::Builtin::Players::TextArea)
12
+ @prop.include_player(Limelight::Builtin::Players::TextArea)
13
13
  end
14
14
 
15
15
  it "should have a JTextArea" do
@@ -9,7 +9,7 @@ describe Limelight::Builtin::Players::TextBox do
9
9
 
10
10
  before(:each) do
11
11
  @prop = Limelight::Prop.new
12
- @prop.add_controller(Limelight::Builtin::Players::TextBox)
12
+ @prop.include_player(Limelight::Builtin::Players::TextBox)
13
13
  end
14
14
 
15
15
  it "should have a TextField" do
@@ -4,6 +4,7 @@
4
4
  require File.expand_path(File.dirname(__FILE__) + "/spec_helper")
5
5
  require 'limelight/commands'
6
6
  require 'limelight/producer'
7
+ require 'limelight/main'
7
8
 
8
9
  describe Limelight::Commands do
9
10
 
@@ -13,13 +14,13 @@ describe Limelight::Commands do
13
14
  it "should open a production" do
14
15
  args = ["open", "production_name"]
15
16
  Limelight::Producer.should_receive(:open).with("production_name")
16
- Limelight::Commands.run(args)
17
+ Limelight::Main.run(args)
17
18
  end
18
19
 
19
20
  it "should open the default production" do
20
21
  args = ["open"]
21
22
  Limelight::Producer.should_receive(:open).with(Limelight::DEFAULT_PRODUCTION)
22
- Limelight::Commands.run(args)
23
+ Limelight::Main.run(args)
23
24
  end
24
25
 
25
26
  it "should pack a production" do
@@ -27,7 +28,7 @@ describe Limelight::Commands do
27
28
  Limelight::Util::Packer.should_receive(:new).and_return(mock_packer)
28
29
  mock_packer.should_receive(:pack).with("production_to_pack")
29
30
 
30
- Limelight::Commands.run(["pack", "production_to_pack"])
31
+ Limelight::Main.run(["pack", "production_to_pack"])
31
32
  end
32
33
 
33
34
  end
@@ -10,21 +10,21 @@ describe Limelight::SceneBuilder do
10
10
  @caster = make_mock("caster", :fill_cast => nil)
11
11
  @options = { :name => "root", :casting_director => @caster}
12
12
  end
13
-
13
+
14
14
  it "should build root" do
15
15
  root = Limelight.build_scene(@options)
16
-
16
+
17
17
  root.class.should == Limelight::Scene
18
18
  root.name.should == "root"
19
19
  root.panel.should_not == nil
20
20
  root.children.size.should == 0
21
21
  end
22
-
22
+
23
23
  it "should build one child prop" do
24
24
  root = Limelight::build_scene(@options) do
25
25
  child
26
26
  end
27
-
27
+
28
28
  root.children.size.should == 1
29
29
  child = root.children[0]
30
30
  child.class.should == Limelight::Prop
@@ -32,13 +32,13 @@ describe Limelight::SceneBuilder do
32
32
  child.panel.should_not == nil
33
33
  child.children.size.should == 0
34
34
  end
35
-
35
+
36
36
  it "should allow multiple children" do
37
37
  root = Limelight::build_scene(@options) do
38
38
  child1
39
39
  child2
40
40
  end
41
-
41
+
42
42
  root.children.size.should == 2
43
43
  root.children[0].name.should == "child1"
44
44
  root.children[1].name.should == "child2"
@@ -56,54 +56,54 @@ describe Limelight::SceneBuilder do
56
56
  root.children[0].children.size.should == 1
57
57
  root.children[0].children[0].name.should == "grandchild"
58
58
  end
59
-
59
+
60
60
  it "should be able to set the id" do
61
61
  root = Limelight::build_scene(@options) do
62
62
  child :id => "child_1", :players => "x, y, z"
63
63
  end
64
-
64
+
65
65
  child = root.children[0]
66
66
  child.id.should == "child_1"
67
67
  child.players.should == "x, y, z"
68
68
  end
69
-
69
+
70
70
  it "should allow setting styles" do
71
71
  root = Limelight::build_scene(@options) do
72
72
  child :width => "100", :font_size => "10", :top_border_color => "blue"
73
73
  end
74
-
74
+
75
75
  child = root.children[0]
76
76
  child.style.width.should == "100"
77
77
  child.style.font_size.should == "10"
78
78
  child.style.top_border_color.should == "blue"
79
79
  end
80
-
80
+
81
81
  it "should allow defining events through constructor" do
82
82
  root = Limelight::build_scene(@options) do
83
83
  child :on_mouse_entered => "return [self, event]"
84
- end
85
-
84
+ end
85
+
86
86
  child = root.children[0]
87
87
  child.mouse_entered("blah").should == [child, "blah"]
88
88
  end
89
-
89
+
90
90
  it "should allow scene configuration" do
91
91
  root = Limelight::build_scene(@options) do
92
92
  __ :name => "root", :id => "123"
93
93
  end
94
-
94
+
95
95
  root.children.size.should == 0
96
96
  root.name.should == "root"
97
97
  root.id.should == "123"
98
98
  end
99
-
99
+
100
100
  it "should give every prop their scene" do
101
101
  root = Limelight::build_scene(@options) do
102
102
  child do
103
103
  grandchild
104
104
  end
105
105
  end
106
-
106
+
107
107
  root.scene.should == root
108
108
  root.children[0].scene.should == root
109
109
  root.children[0].children[0].scene.should == root
@@ -112,18 +112,18 @@ describe Limelight::SceneBuilder do
112
112
  it "should install external props" do
113
113
  loader = make_mock("loader", :exists? => true)
114
114
  loader.should_receive(:load).with("external.rb").and_return("child :id => 123")
115
-
115
+
116
116
  root = Limelight::build_scene(:id => 321, :build_loader => loader, :casting_director => @caster) do
117
117
  __install "external.rb"
118
- end
119
-
118
+ end
119
+
120
120
  root.id.should == 321
121
121
  root.children.size.should == 1
122
122
  child = root.children[0]
123
123
  child.name.should == "child"
124
124
  child.id.should == 123
125
125
  end
126
-
126
+
127
127
  it "should fail if no loader is provided" do
128
128
  begin
129
129
  root = Limelight::build_scene(@options.merge(:id => 321, :build_loader => nil)) do
@@ -134,11 +134,11 @@ describe Limelight::SceneBuilder do
134
134
  e.message.should == "Cannot install external props because no loader was provided"
135
135
  end
136
136
  end
137
-
137
+
138
138
  it "should fail when the external file doesn't exist" do
139
139
  loader = make_mock("loader")
140
140
  loader.should_receive(:exists?).with("external.rb").and_return(false)
141
-
141
+
142
142
  begin
143
143
  root = Limelight::build_scene(@options.merge(:id => 321, :build_loader => loader)) do
144
144
  __install "external.rb"
@@ -147,32 +147,43 @@ describe Limelight::SceneBuilder do
147
147
  e.message.should == "External prop file: 'external.rb' doesn't exist"
148
148
  end
149
149
  end
150
-
150
+
151
151
  it "should fail with PropException when there's problem in the external file" do
152
152
  loader = make_mock("loader", :exists? => true)
153
153
  loader.should_receive(:load).with("external.rb").and_return("+")
154
-
154
+
155
155
  begin
156
156
  root = Limelight::build_scene(@options.merge(:id => 321, :build_loader => loader)) do
157
157
  __install "external.rb"
158
- end
158
+ end
159
159
  rescue Limelight::BuildException => e
160
160
  e.message.should include("external.rb:1: (eval):1: , unexpected end-of-file")
161
161
  end
162
162
  end
163
-
163
+
164
164
  it "should build onto an existing block" do
165
165
  prop = Limelight::Prop.new
166
166
  prop.set_scene(Limelight::Scene.new(:casting_director => make_mock(:casting_director, :fill_cast => nil)))
167
167
  builder = Limelight::PropBuilder.new(prop)
168
168
  block = Proc.new { one; two { three } }
169
169
  builder.instance_eval(&block)
170
-
170
+
171
171
  prop.children.length.should == 2
172
172
  prop.children[0].name.should == "one"
173
173
  prop.children[1].name.should == "two"
174
174
  prop.children[1].children.length.should == 1
175
175
  prop.children[1].children[0].name.should == "three"
176
176
  end
177
-
177
+
178
+ it "should not crash with prop named display" do
179
+ root = Limelight::build_scene(@options) do
180
+ display :id => "display"
181
+ end
182
+
183
+ root.children.size.should == 1
184
+ display = root.children[0]
185
+ display.name.should == "display"
186
+ display.id.should == "display"
187
+ end
188
+
178
189
  end
data/spec/prop_spec.rb CHANGED
@@ -40,7 +40,7 @@ describe Limelight::Prop do
40
40
  end
41
41
  end
42
42
 
43
- @prop.add_controller(TestController)
43
+ @prop.include_player(TestController)
44
44
 
45
45
  TestController.extended_prop.should == @prop
46
46
  @prop.respond_to?(:test_method).should == true
@@ -85,6 +85,10 @@ describe Limelight::Prop do
85
85
  it "should get and set text" do
86
86
  @prop.text = "blah"
87
87
  @prop.text.should == "blah"
88
+ @prop.text = 123
89
+ @prop.text.should == "123"
90
+ @prop.text = nil
91
+ @prop.text.should == ""
88
92
  end
89
93
 
90
94
  it "should have controllers" do
data/spec/stage_spec.rb CHANGED
@@ -8,7 +8,7 @@ describe Limelight::Stage do
8
8
 
9
9
  before(:each) do
10
10
  @theater = make_mock("theater")
11
- @stage = Limelight::Stage.new(@theater, "George")
11
+ @__stage__ = Limelight::Stage.new(@theater, "George")
12
12
  end
13
13
 
14
14
  it "should have a name" do
@@ -18,40 +18,40 @@ describe Limelight::Stage do
18
18
  end
19
19
 
20
20
  it "should have a title which default to it's name" do
21
- @stage.title.should == "George"
21
+ @__stage__.title.should == "George"
22
22
 
23
- @stage.title = "Once Upon a Test"
23
+ @__stage__.title = "Once Upon a Test"
24
24
 
25
- @stage.title.should == "Once Upon a Test"
25
+ @__stage__.title.should == "Once Upon a Test"
26
26
  end
27
27
 
28
28
  it "should have size" do
29
- @stage.size.should == [800, 800]
29
+ @__stage__.size.should == [800, 800]
30
30
 
31
- @stage.size = 123, 456
31
+ @__stage__.size = 123, 456
32
32
 
33
- @stage.size.should == [123, 456]
33
+ @__stage__.size.should == [123, 456]
34
34
  end
35
35
 
36
- it "should have size" do
37
- @stage.location.should == [200, 25]
36
+ it "should have location" do
37
+ @__stage__.location.should == [200, 25]
38
38
 
39
- @stage.location = 123, 456
39
+ @__stage__.location = 123, 456
40
40
 
41
- @stage.location.should == [123, 456]
41
+ @__stage__.location.should == [123, 456]
42
42
  end
43
43
 
44
44
  it "should not allow name changes" do
45
- lambda { @stage.name = "new name" }.should raise_error
45
+ lambda { @__stage__.name = "new name" }.should raise_error
46
46
  end
47
47
 
48
48
  it "should call scene.scene_opened at the end of opening a scene" do
49
49
  scene = make_mock("scene", :visible= => nil)
50
50
  scene.should_receive(:scene_opened)
51
51
 
52
- @stage.frame.stub!(:open)
53
- @stage.stub!(:load_scene)
54
- @stage.open(scene)
52
+ @__stage__.frame.stub!(:open)
53
+ @__stage__.stub!(:load_scene)
54
+ @__stage__.open(scene)
55
55
  end
56
56
 
57
57
  end