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.
- data/bin/limelight +2 -3
- data/lib/limelight.jar +0 -0
- data/lib/limelight/animation.rb +32 -12
- data/lib/limelight/build_exception.rb +3 -0
- data/lib/limelight/builtin/players/button.rb +17 -2
- data/lib/limelight/builtin/players/check_box.rb +21 -2
- data/lib/limelight/builtin/players/combo_box.rb +31 -3
- data/lib/limelight/builtin/players/combo_box_popup_list.rb +1 -1
- data/lib/limelight/builtin/players/combo_box_popup_list_item.rb +1 -1
- data/lib/limelight/builtin/players/curtains.rb +1 -1
- data/lib/limelight/builtin/players/radio_button.rb +27 -3
- data/lib/limelight/builtin/players/text_area.rb +11 -2
- data/lib/limelight/builtin/players/text_box.rb +11 -2
- data/lib/limelight/button_group_cache.rb +2 -2
- data/lib/limelight/casting_director.rb +6 -1
- data/lib/limelight/commands.rb +10 -24
- data/lib/limelight/file_chooser.rb +16 -3
- data/lib/limelight/file_filter.rb +10 -3
- data/lib/limelight/java_couplings.rb +11 -10
- data/lib/limelight/java_util.rb +36 -3
- data/lib/limelight/limelight_exception.rb +3 -1
- data/lib/limelight/loaders/file_scene_loader.rb +1 -1
- data/lib/limelight/main.rb +108 -0
- data/lib/limelight/menu_bar.rb +31 -12
- data/lib/limelight/paint_action.rb +4 -2
- data/lib/limelight/pen.rb +39 -9
- data/lib/limelight/producer.rb +35 -7
- data/lib/limelight/production.rb +18 -9
- data/lib/limelight/production_builder.rb +22 -5
- data/lib/limelight/prop.rb +127 -45
- data/lib/limelight/prop_builder.rb +70 -11
- data/lib/limelight/scene.rb +25 -21
- data/lib/limelight/stage.rb +68 -18
- data/lib/limelight/stage_builder.rb +68 -27
- data/lib/limelight/styles.rb +327 -30
- data/lib/limelight/styles_builder.rb +91 -21
- data/lib/limelight/theater.rb +23 -11
- data/lib/limelight/util.rb +28 -6
- data/lib/limelight/version.rb +1 -1
- data/productions/startup/players/browse_button.rb +1 -1
- data/spec/builtin/players/check_box_spec.rb +1 -1
- data/spec/builtin/players/radio_button_spec.rb +2 -2
- data/spec/builtin/players/text_area_spec.rb +1 -1
- data/spec/builtin/players/text_box_spec.rb +1 -1
- data/spec/commands_spec.rb +4 -3
- data/spec/prop_builder_spec.rb +40 -29
- data/spec/prop_spec.rb +5 -1
- data/spec/stage_spec.rb +15 -15
- data/spec/styles_spec.rb +36 -0
- data/spec/theater_spec.rb +8 -8
- metadata +6 -3
@@ -4,21 +4,63 @@
|
|
4
4
|
require 'limelight/prop'
|
5
5
|
require 'limelight/scene'
|
6
6
|
require 'limelight/build_exception'
|
7
|
+
require 'limelight/util'
|
7
8
|
|
8
9
|
module Limelight
|
9
|
-
|
10
|
+
|
11
|
+
# A trigger to build a Limelight::Scene using the PropBuilder DSL.
|
12
|
+
#
|
13
|
+
# See Limelight::PropBuilder
|
14
|
+
#
|
10
15
|
def self.build_scene(options={}, &block)
|
11
16
|
loader = options.delete(:build_loader)
|
12
17
|
builder = SceneBuilder.new(options)
|
13
18
|
builder.__loader__ = loader
|
14
|
-
builder.instance_eval(&block) if block
|
19
|
+
builder.instance_eval(&block) if block
|
15
20
|
return builder.__prop__
|
16
21
|
end
|
17
|
-
|
18
|
-
|
22
|
+
|
23
|
+
# The basis of the DSL for building Limelight::Prop objects.
|
24
|
+
#
|
25
|
+
# Sample usage:
|
26
|
+
#
|
27
|
+
# builder = Limelight::PropBuilder.new(a_prop)
|
28
|
+
# builder.instance_eval(&block)
|
29
|
+
#
|
30
|
+
# The prop passed into the constructor will be the root of the contructed Prop tree.
|
31
|
+
# The block passed into instance_eval contains the DSL for building props.
|
32
|
+
#
|
33
|
+
# Example block/DSL:
|
34
|
+
#
|
35
|
+
# parent :id => "the_parent" do
|
36
|
+
# child_one do
|
37
|
+
# grand_child_one :id => "gc_1", :styles => "grand_child"
|
38
|
+
# grand_child_two :id => "gc_2", :styles => "grand_child"
|
39
|
+
# end
|
40
|
+
# child_two
|
41
|
+
# end
|
42
|
+
#
|
43
|
+
# The above example will create a Limelight::Prop named 'parent' and add it to the root prop passed into the builder.
|
44
|
+
# The 'parent' prop will contain two props named 'child_one' and 'child_two'. 'child_one' will contain two props named
|
45
|
+
# 'grand_child_one' and 'grand_child_two'. 'child_two' has no child props nor do 'grand_child_one' or 'grand_child_two'.
|
46
|
+
#
|
47
|
+
# An options Hash may be passed into each prop. The key, value pairs in the hash will be used to set properties on the prop
|
48
|
+
# when it is added to a Limelight::Scene.
|
49
|
+
#
|
50
|
+
# See Limelight::Prop
|
51
|
+
#
|
52
|
+
class PropBuilder
|
53
|
+
|
54
|
+
Limelight::Util.lobotomize(self)
|
55
|
+
|
56
|
+
# Returns the root prop either passed in or created by this builder.
|
57
|
+
#
|
19
58
|
attr_reader :__prop__
|
20
59
|
attr_accessor :__loader__
|
21
|
-
|
60
|
+
|
61
|
+
# Creates a new builder. If a prop is passed it, it will be the root on which props are created.
|
62
|
+
# If the paramter is a Hash, the Hash will be used to construct a prop that will be used as the root.
|
63
|
+
#
|
22
64
|
def initialize(options)
|
23
65
|
if options.is_a?(Prop)
|
24
66
|
@__prop__ = options
|
@@ -26,11 +68,27 @@ module Limelight
|
|
26
68
|
@__prop__ = Prop.new(options)
|
27
69
|
end
|
28
70
|
end
|
29
|
-
|
71
|
+
|
72
|
+
# Add extra initialization options to the prop currently under construction.
|
73
|
+
#
|
74
|
+
# tree :id => "stump" do
|
75
|
+
# __ :height => "100%", :width => "30", :background_color => :brown
|
76
|
+
# branch :height => "100", :width => "20"
|
77
|
+
# branch do
|
78
|
+
# __ :height => "100", :width => "20"
|
79
|
+
# end
|
80
|
+
# end
|
81
|
+
#
|
82
|
+
# In the above example, the 'tree' prop has the following initialization options: id, height, width, background_color.
|
83
|
+
# The two 'branch' child props are identical.
|
84
|
+
#
|
30
85
|
def __(options)
|
31
86
|
@__prop__.add_options(options)
|
32
87
|
end
|
33
|
-
|
88
|
+
|
89
|
+
# Installs props from another file using the prop DSL. The path will be relative to the
|
90
|
+
# root directory of the current production.
|
91
|
+
#
|
34
92
|
def __install(file)
|
35
93
|
raise "Cannot install external props because no loader was provided" if @__loader__.nil?
|
36
94
|
raise "External prop file: '#{file}' doesn't exist" if !@__loader__.exists?(file)
|
@@ -41,8 +99,9 @@ module Limelight
|
|
41
99
|
raise BuildException.new(file, content, e)
|
42
100
|
end
|
43
101
|
end
|
44
|
-
|
45
|
-
|
102
|
+
|
103
|
+
|
104
|
+
def method_missing(sym, options={}, &prop) # :nodoc:
|
46
105
|
options[:name] ||= sym.to_s
|
47
106
|
builder = PropBuilder.new(options)
|
48
107
|
builder.__loader__ = @__loader__
|
@@ -50,8 +109,8 @@ module Limelight
|
|
50
109
|
@__prop__.add(builder.__prop__)
|
51
110
|
end
|
52
111
|
end
|
53
|
-
|
54
|
-
class SceneBuilder < PropBuilder
|
112
|
+
|
113
|
+
class SceneBuilder < PropBuilder # :nodoc:
|
55
114
|
def initialize(options)
|
56
115
|
@__prop__ = Scene.new(options)
|
57
116
|
end
|
data/lib/limelight/scene.rb
CHANGED
@@ -6,6 +6,10 @@ require 'limelight/prop'
|
|
6
6
|
require 'limelight/button_group_cache'
|
7
7
|
|
8
8
|
module Limelight
|
9
|
+
|
10
|
+
# A Scene is a root Prop. Scenes may be loaded onto a Stage. In addition to being a Prop object, Scenes have a
|
11
|
+
# few extra attributes and behaviors.
|
12
|
+
#
|
9
13
|
class Scene < Prop
|
10
14
|
|
11
15
|
include UI::Api::Scene
|
@@ -23,32 +27,26 @@ module Limelight
|
|
23
27
|
illuminate
|
24
28
|
end
|
25
29
|
|
26
|
-
def add_options(options)
|
30
|
+
def add_options(options) #:nodoc:
|
27
31
|
@options = options
|
28
32
|
illuminate
|
29
33
|
end
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
@casting_director = @options.delete(:casting_director) if @options.has_key?(:casting_director)
|
34
|
-
super
|
35
|
-
end
|
36
|
-
|
37
|
-
def has_static_size?
|
38
|
-
return is_static?(style.get_width) && is_static?(style.get_height)
|
39
|
-
end
|
40
|
-
|
34
|
+
|
35
|
+
# Creates the menu bar for the Scene
|
36
|
+
#
|
41
37
|
def menu_bar
|
42
38
|
return MenuBar.build(self) do
|
43
39
|
menu("File") do
|
44
|
-
item("Open", :
|
40
|
+
item("Open", :open_chosen_production)
|
45
41
|
item("Refresh", :reload)
|
46
42
|
end
|
47
43
|
end
|
48
44
|
end
|
49
|
-
|
50
|
-
|
51
|
-
|
45
|
+
|
46
|
+
# Opens a FileChooser for a new Production. Loads the chosen Production.
|
47
|
+
#
|
48
|
+
def open_chosen_production
|
49
|
+
options = { :title => "Open New Limelight Production", :description => "Limelight Production", :directory => @directory }
|
52
50
|
chosen_file = stage.choose_file(options) { |file| Util.is_limelight_scene?(file) || Util.is_limelight_production?(file) }
|
53
51
|
if chosen_file
|
54
52
|
@directory = File.dirname(chosen_file)
|
@@ -56,19 +54,25 @@ module Limelight
|
|
56
54
|
end
|
57
55
|
end
|
58
56
|
|
57
|
+
# Creates a new Producer to open the specified Production.
|
58
|
+
#
|
59
59
|
def open_production(production_path)
|
60
60
|
producer = Producer.new(production_path, @production.theater)
|
61
61
|
producer.open
|
62
62
|
end
|
63
|
-
|
64
|
-
|
65
|
-
|
63
|
+
|
64
|
+
# Opens the specified Scene on the Stage currently occupied by this Scene.s
|
65
|
+
#
|
66
|
+
def load(scene_name)
|
67
|
+
@production.producer.open_scene(scene_name, @stage)
|
66
68
|
end
|
67
69
|
|
68
70
|
private ###############################################
|
69
71
|
|
70
|
-
def
|
71
|
-
|
72
|
+
def illuminate
|
73
|
+
@styles = @options.has_key?(:styles) ? @options.delete(:styles) : (@styles || {})
|
74
|
+
@casting_director = @options.delete(:casting_director) if @options.has_key?(:casting_director)
|
75
|
+
super
|
72
76
|
end
|
73
77
|
|
74
78
|
def reload
|
data/lib/limelight/stage.rb
CHANGED
@@ -8,76 +8,118 @@ require 'limelight/file_chooser'
|
|
8
8
|
require 'limelight/util'
|
9
9
|
|
10
10
|
module Limelight
|
11
|
-
|
11
|
+
|
12
|
+
# In the metephorical sense, a Stage is a platform which may hold a scene. In a more, to-the-point sence, a Stage
|
13
|
+
# represents a window on the computer screen. The Stage objects within a Production are configured by the StagesBuilder.
|
14
|
+
# By default a Production will have one Stage. A Stage may open any number of Scenes but it may only have one current
|
15
|
+
# scene loaded at a time.
|
16
|
+
#
|
12
17
|
class Stage
|
13
18
|
attr_accessor :default_scene
|
14
19
|
attr_reader :frame, :current_scene, :name, :theater
|
15
20
|
|
16
21
|
include UI::Api::Stage
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
+
|
23
|
+
# To create a new Stage, it be given a Theater to which it belongs, and the name is optional. If no name is provided
|
24
|
+
# it will default to 'default'. A stage name must be unique, so it is recommended you provide a name.
|
25
|
+
#
|
22
26
|
def initialize(theater, name="default")
|
23
27
|
@theater = theater
|
24
28
|
@name = name
|
25
29
|
build_frame
|
26
30
|
self.title = @name
|
27
31
|
end
|
28
|
-
|
32
|
+
|
33
|
+
# Returns the title that is displayed at the top of the window that this stage represents.
|
34
|
+
#
|
29
35
|
def title
|
30
36
|
return @frame.title
|
31
37
|
end
|
32
|
-
|
38
|
+
|
39
|
+
# Sets the title that is displayed at the top of the window that this stage represents.
|
40
|
+
#
|
33
41
|
def title=(value)
|
34
42
|
@frame.title = value
|
35
43
|
end
|
36
|
-
|
44
|
+
|
45
|
+
# Returns the width and height of the Stage.
|
46
|
+
#
|
47
|
+
# width, height = stage.size
|
48
|
+
#
|
37
49
|
def size
|
38
50
|
return @frame.width, @frame.height
|
39
51
|
end
|
40
|
-
|
52
|
+
|
53
|
+
# Sets the width and height of the Stage. The dimensions are passed in as an array.
|
54
|
+
#
|
55
|
+
# state.size = [100, 200]
|
56
|
+
#
|
41
57
|
def size=(values)
|
42
58
|
@frame.set_size(values[0], values[1])
|
43
59
|
end
|
44
|
-
|
60
|
+
|
61
|
+
# The location of the Stage on the screen.
|
62
|
+
#
|
63
|
+
# x, y = stage.location
|
64
|
+
#
|
45
65
|
def location
|
46
66
|
return @frame.location.x, @frame.location.y
|
47
67
|
end
|
48
|
-
|
68
|
+
|
69
|
+
# Sets the location of the Stage on the screen.
|
70
|
+
#
|
71
|
+
# stage.location = [500, 200]
|
72
|
+
#
|
49
73
|
def location= values
|
50
74
|
@frame.set_location(values[0], values[1])
|
51
75
|
end
|
52
|
-
|
76
|
+
|
77
|
+
# Opens the Stage and loads the provided Scene.
|
78
|
+
#
|
79
|
+
# See load_scene
|
80
|
+
#
|
53
81
|
def open(scene)
|
54
82
|
load_scene(scene)
|
55
83
|
@frame.open
|
56
84
|
scene.visible = true
|
57
85
|
scene.scene_opened(self)
|
58
86
|
end
|
59
|
-
|
87
|
+
|
88
|
+
# Closes the Stage. It's window will no longer be displayed on the screen.
|
89
|
+
#
|
60
90
|
def close
|
61
91
|
@frame.close
|
62
92
|
end
|
63
|
-
|
93
|
+
|
94
|
+
# Loads a scene on the Stage. If the Stage is currently hosting a Scene, the original Scene will be removed and
|
95
|
+
# the new Scene will replace it.
|
96
|
+
#
|
64
97
|
def load_scene(scene)
|
65
98
|
@frame.setJMenuBar(scene.menu_bar)
|
66
99
|
@frame.load(scene.panel)
|
67
100
|
scene.stage = self
|
68
101
|
scene.panel.snap_to_size
|
69
|
-
if(scene.
|
70
|
-
@frame.set_size(scene.panel.width, scene.panel.height)
|
102
|
+
if(has_static_size?(scene.style))
|
103
|
+
@frame.set_size(scene.panel.width + @frame.getHorizontalInsetWidth, scene.panel.height + @frame.getVerticalInsetWidth)
|
71
104
|
end
|
72
105
|
@current_scene = scene
|
73
106
|
end
|
74
|
-
|
107
|
+
|
108
|
+
# Opens a file chooser window to select a file on the file system. Options may include:
|
109
|
+
# * :description => a string describing the desired file
|
110
|
+
# * :directory => starting directory
|
111
|
+
# * :title => title of the window
|
112
|
+
# * :directories_only => boolean, true if the user must select a directory
|
113
|
+
# * :files_only => boolean, true if the user must select a file
|
114
|
+
#
|
75
115
|
def choose_file(options={}, &block)
|
76
116
|
options[:parent] = @frame
|
77
117
|
chooser = FileChooser.new(options, &block)
|
78
118
|
return chooser.choose_file
|
79
119
|
end
|
80
120
|
|
121
|
+
# Pops up a simple modal dialog with the provided message.
|
122
|
+
#
|
81
123
|
def alert(message)
|
82
124
|
frame.alert(message)
|
83
125
|
end
|
@@ -90,6 +132,14 @@ module Limelight
|
|
90
132
|
@frame.set_location(200, 25)
|
91
133
|
@frame.title = title
|
92
134
|
end
|
135
|
+
|
136
|
+
def has_static_size?(style)
|
137
|
+
return is_static?(style.get_width) && is_static?(style.get_height)
|
138
|
+
end
|
139
|
+
|
140
|
+
def is_static?(value)
|
141
|
+
return !(value.to_s.include?("%")) && !(value.to_s == "auto")
|
142
|
+
end
|
93
143
|
|
94
144
|
end
|
95
145
|
|
@@ -5,58 +5,99 @@ require 'limelight/stage'
|
|
5
5
|
require 'limelight/limelight_exception'
|
6
6
|
|
7
7
|
module Limelight
|
8
|
-
|
8
|
+
|
9
|
+
# A trigger to build/configure Stage objects using the StageBuilder DSL.
|
10
|
+
#
|
11
|
+
# See Limelight::Stagesbuilder, Limelight::Stagebuilder
|
12
|
+
#
|
9
13
|
def self.build_stages(theater, &block)
|
10
14
|
builder = StagesBuilder.new(theater)
|
11
15
|
builder.instance_eval(&block) if block
|
12
|
-
return builder.
|
16
|
+
return builder.__stages__
|
13
17
|
end
|
14
|
-
|
18
|
+
|
19
|
+
# The basis of the DSL for building Stage objects.
|
20
|
+
#
|
21
|
+
# stage "inspector" do
|
22
|
+
# default_scene "inspector"
|
23
|
+
# title "Limelight Composer Inspector"
|
24
|
+
# location [0, 0]
|
25
|
+
# size [300, 800]
|
26
|
+
# end
|
27
|
+
#
|
28
|
+
# stage "viewer" do
|
29
|
+
# title "Limelight Composer Viewer"
|
30
|
+
# location [350, 0]
|
31
|
+
# size [800, 800]
|
32
|
+
# end
|
33
|
+
#
|
34
|
+
# In this example above, two stages are created for the production. One is named 'inspector' and the other is named
|
35
|
+
# 'viewer'. 'inspector' has a default scene that will be loaded on startup. 'viewer' will not contain any scene
|
36
|
+
# on startup. Using the DSL, each stage can be configured to set the title, location, size, or any other attribute
|
37
|
+
# of a stage.
|
38
|
+
#
|
39
|
+
# See Limelight::Stage
|
40
|
+
#
|
15
41
|
class StagesBuilder
|
16
|
-
|
17
|
-
|
18
|
-
|
42
|
+
|
43
|
+
Limelight::Util.lobotomize(self)
|
44
|
+
|
45
|
+
attr_reader :__stages__
|
46
|
+
|
47
|
+
# Constructs a new StagesBuilder. A Theater object is required as a parameter. Each stages created will belong
|
48
|
+
# to the Theater passed in.
|
49
|
+
#
|
19
50
|
def initialize(theater)
|
20
|
-
@
|
21
|
-
@
|
51
|
+
@__theater__ = theater
|
52
|
+
@__stages__ = []
|
22
53
|
end
|
23
|
-
|
54
|
+
|
55
|
+
# Creates a new stage with the provided name. The block will contain StageBuilder DSL to configure the stage.
|
56
|
+
#
|
24
57
|
def stage(name, &block)
|
25
|
-
stage_builder = StageBuilder.new(@
|
58
|
+
stage_builder = StageBuilder.new(@__theater__, name)
|
26
59
|
stage_builder.instance_eval(&block) if block
|
27
|
-
@
|
60
|
+
@__stages__ << stage_builder.__stage__
|
28
61
|
end
|
29
|
-
|
62
|
+
|
30
63
|
end
|
31
|
-
|
64
|
+
|
65
|
+
# The basis of the DSL for configuring a Stage object.
|
66
|
+
#
|
32
67
|
class StageBuilder
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
68
|
+
|
69
|
+
Limelight::Util.lobotomize(self)
|
70
|
+
|
71
|
+
attr_reader :__stage__
|
72
|
+
|
73
|
+
def initialize(theater, name) #:nodoc:
|
37
74
|
if theater[name]
|
38
|
-
@
|
75
|
+
@__stage__ = theater[name]
|
39
76
|
else
|
40
|
-
@
|
41
|
-
theater.add_stage(@
|
77
|
+
@__stage__ = Stage.new(theater, name)
|
78
|
+
theater.add_stage(@__stage__)
|
42
79
|
end
|
43
80
|
end
|
44
|
-
|
81
|
+
|
82
|
+
# Specifies the scene that will be displayed on the stage upon opening of the production.
|
83
|
+
#
|
45
84
|
def default_scene(scene_name)
|
46
|
-
@
|
85
|
+
@__stage__.default_scene = scene_name
|
47
86
|
end
|
48
|
-
|
49
|
-
def method_missing(sym, value)
|
87
|
+
|
88
|
+
def method_missing(sym, value) #:nodoc:
|
50
89
|
setter_sym = "#{sym}=".to_s
|
51
|
-
raise StageBuilderException.new(sym) if !@
|
52
|
-
@
|
90
|
+
raise StageBuilderException.new(sym) if !@__stage__.respond_to?(setter_sym)
|
91
|
+
@__stage__.send(setter_sym, value)
|
53
92
|
end
|
54
93
|
end
|
55
94
|
|
95
|
+
# Exception thrown by StageBuilder in the event of an invalid configuration.
|
96
|
+
#
|
56
97
|
class StageBuilderException < LimelightException
|
57
98
|
def initialize(name)
|
58
99
|
super("'#{name}' is not a valid stage property")
|
59
100
|
end
|
60
101
|
end
|
61
|
-
|
102
|
+
|
62
103
|
end
|