limelight 0.0.1-java
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/icons/icon.ico +0 -0
- data/bin/icons/icon_48.gif +0 -0
- data/bin/icons/limelight.icns +0 -0
- data/bin/icons/splash.png +0 -0
- data/bin/limelight +6 -0
- data/bin/ll +10 -0
- data/bin/ll.bat +5 -0
- data/lib/init.rb +11 -0
- data/lib/limelight/build_exception.rb +45 -0
- data/lib/limelight/button_group_cache.rb +11 -0
- data/lib/limelight/casting_director.rb +72 -0
- data/lib/limelight/commands.rb +66 -0
- data/lib/limelight/file_chooser.rb +55 -0
- data/lib/limelight/file_filter.rb +26 -0
- data/lib/limelight/java_util.rb +29 -0
- data/lib/limelight/limelight_exception.rb +9 -0
- data/lib/limelight/loaders/file_scene_loader.rb +48 -0
- data/lib/limelight/menu_bar.rb +49 -0
- data/lib/limelight/paint_action.rb +25 -0
- data/lib/limelight/pen.rb +53 -0
- data/lib/limelight/players/button.rb +29 -0
- data/lib/limelight/players/check_box.rb +38 -0
- data/lib/limelight/players/combo_box.rb +44 -0
- data/lib/limelight/players/radio_button.rb +47 -0
- data/lib/limelight/players/text_area.rb +25 -0
- data/lib/limelight/players/text_box.rb +25 -0
- data/lib/limelight/players.rb +9 -0
- data/lib/limelight/producer.rb +141 -0
- data/lib/limelight/production.rb +64 -0
- data/lib/limelight/production_builder.rb +49 -0
- data/lib/limelight/prop.rb +241 -0
- data/lib/limelight/prop_builder.rb +60 -0
- data/lib/limelight/scene.rb +75 -0
- data/lib/limelight/stage.rb +93 -0
- data/lib/limelight/stage_builder.rb +62 -0
- data/lib/limelight/styles.rb +37 -0
- data/lib/limelight/styles_builder.rb +61 -0
- data/lib/limelight/theater.rb +42 -0
- data/lib/limelight/util.rb +26 -0
- data/lib/limelight/version.rb +20 -0
- data/lib/limelight.jar +0 -0
- data/productions/examples/8thlight.com/about/about.txt +24 -0
- data/productions/examples/8thlight.com/about/props.rb +11 -0
- data/productions/examples/8thlight.com/about/styles.rb +2 -0
- data/productions/examples/8thlight.com/footer.rb +6 -0
- data/productions/examples/8thlight.com/home/props.rb +28 -0
- data/productions/examples/8thlight.com/home/styles.rb +2 -0
- data/productions/examples/8thlight.com/images/anvil.jpg +0 -0
- data/productions/examples/8thlight.com/images/bg.jpg +0 -0
- data/productions/examples/8thlight.com/images/botticelli.jpg +0 -0
- data/productions/examples/8thlight.com/images/button_bg.jpg +0 -0
- data/productions/examples/8thlight.com/images/canvas_bg.jpg +0 -0
- data/productions/examples/8thlight.com/images/footer_bg.jpg +0 -0
- data/productions/examples/8thlight.com/images/header.jpg +0 -0
- data/productions/examples/8thlight.com/images/moses.jpg +0 -0
- data/productions/examples/8thlight.com/images/statemachine_thumbnail.png +0 -0
- data/productions/examples/8thlight.com/images/thumbnail_book.jpg +0 -0
- data/productions/examples/8thlight.com/menu.rb +11 -0
- data/productions/examples/8thlight.com/services/props.rb +11 -0
- data/productions/examples/8thlight.com/services/services.txt +8 -0
- data/productions/examples/8thlight.com/services/styles.rb +2 -0
- data/productions/examples/8thlight.com/stages.rb +8 -0
- data/productions/examples/8thlight.com/styles.rb +205 -0
- data/productions/examples/calculator/players/button.rb +24 -0
- data/productions/examples/calculator/players/calculator.rb +15 -0
- data/productions/examples/calculator/players/calculator_model.rb +13 -0
- data/productions/examples/calculator/props.rb +23 -0
- data/productions/examples/calculator/styles.rb +38 -0
- data/productions/examples/langstons_ant/html_javascript/ant.css +39 -0
- data/productions/examples/langstons_ant/html_javascript/ant.html +22 -0
- data/productions/examples/langstons_ant/html_javascript/ant.js +23 -0
- data/productions/examples/langstons_ant/players/ant.rb +103 -0
- data/productions/examples/langstons_ant/players/log.rb +29 -0
- data/productions/examples/langstons_ant/players/start_stop_button.rb +37 -0
- data/productions/examples/langstons_ant/players/world.rb +61 -0
- data/productions/examples/langstons_ant/props.rb +22 -0
- data/productions/examples/langstons_ant/styles.rb +105 -0
- data/productions/examples/sandbox/click_me/players/chromaton.rb +47 -0
- data/productions/examples/sandbox/click_me/props.rb +8 -0
- data/productions/examples/sandbox/click_me/styles.rb +12 -0
- data/productions/examples/sandbox/floaters/players/floater.rb +92 -0
- data/productions/examples/sandbox/floaters/players/surface.rb +17 -0
- data/productions/examples/sandbox/floaters/props.rb +10 -0
- data/productions/examples/sandbox/floaters/styles.rb +25 -0
- data/productions/examples/sandbox/gradients/players/spinner.rb +23 -0
- data/productions/examples/sandbox/gradients/players/teaser.rb +26 -0
- data/productions/examples/sandbox/gradients/players/wave.rb +26 -0
- data/productions/examples/sandbox/gradients/players/waves.rb +26 -0
- data/productions/examples/sandbox/gradients/props.rb +13 -0
- data/productions/examples/sandbox/gradients/styles.rb +47 -0
- data/productions/examples/sandbox/header.rb +15 -0
- data/productions/examples/sandbox/homer/players/homer.rb +20 -0
- data/productions/examples/sandbox/homer/props.rb +10 -0
- data/productions/examples/sandbox/homer/styles.rb +17 -0
- data/productions/examples/sandbox/images/arch.jpg +0 -0
- data/productions/examples/sandbox/images/beach.jpg +0 -0
- data/productions/examples/sandbox/images/homer.jpg +0 -0
- data/productions/examples/sandbox/images/limelight_spotlight.jpg +0 -0
- data/productions/examples/sandbox/images/marilyn.jpg +0 -0
- data/productions/examples/sandbox/inputs/players/button_input.rb +48 -0
- data/productions/examples/sandbox/inputs/players/check_box_input.rb +40 -0
- data/productions/examples/sandbox/inputs/players/combo_box_input.rb +41 -0
- data/productions/examples/sandbox/inputs/players/radio_button_input.rb +43 -0
- data/productions/examples/sandbox/inputs/players/text_area_input.rb +36 -0
- data/productions/examples/sandbox/inputs/players/text_box_input.rb +36 -0
- data/productions/examples/sandbox/inputs/props.rb +40 -0
- data/productions/examples/sandbox/inputs/styles.rb +39 -0
- data/productions/examples/sandbox/players/sandbox.rb +11 -0
- data/productions/examples/sandbox/rounded_corners/players/box.rb +11 -0
- data/productions/examples/sandbox/rounded_corners/props.rb +22 -0
- data/productions/examples/sandbox/rounded_corners/styles.rb +18 -0
- data/productions/examples/sandbox/scrolling/players/cell.rb +16 -0
- data/productions/examples/sandbox/scrolling/props.rb +40 -0
- data/productions/examples/sandbox/scrolling/styles.rb +25 -0
- data/productions/examples/sandbox/sketching/players/sketchpad.rb +46 -0
- data/productions/examples/sandbox/sketching/props.rb +25 -0
- data/productions/examples/sandbox/sketching/styles.rb +36 -0
- data/productions/examples/sandbox/stages.rb +6 -0
- data/productions/examples/sandbox/styles.rb +37 -0
- data/productions/examples/sandbox/teaser/players/fader.rb +58 -0
- data/productions/examples/sandbox/teaser/props.rb +14 -0
- data/productions/examples/sandbox/teaser/styles.rb +22 -0
- data/productions/examples/tutorials/tutorial_1/players/sample.rb +11 -0
- data/productions/examples/tutorials/tutorial_1/props.rb +9 -0
- data/productions/examples/tutorials/tutorial_1/styles.rb +27 -0
- data/productions/stage_composer/init.rb +10 -0
- data/productions/stage_composer/inspector/players/inspector.rb +80 -0
- data/productions/stage_composer/inspector/players/prop_row.rb +12 -0
- data/productions/stage_composer/inspector/players/prop_tree.rb +33 -0
- data/productions/stage_composer/inspector/players/style_table.rb +12 -0
- data/productions/stage_composer/inspector/players/style_value.rb +16 -0
- data/productions/stage_composer/inspector/props.rb +19 -0
- data/productions/stage_composer/inspector/styles.rb +71 -0
- data/productions/stage_composer/lib/init.rb +5 -0
- data/productions/stage_composer/lib/limelight/composer/controller.rb +51 -0
- data/productions/stage_composer/lib/limelight/composer/lethargy.rb +24 -0
- data/productions/stage_composer/production.rb +6 -0
- data/productions/stage_composer/stages.rb +15 -0
- data/productions/startup/props.rb +5 -0
- data/spec/casting_director_spec.rb +94 -0
- data/spec/commands_spec.rb +33 -0
- data/spec/file_chooser_spec.rb +64 -0
- data/spec/file_filter_spec.rb +29 -0
- data/spec/java_util_spec.rb +53 -0
- data/spec/loaders/file_loader_spec.rb +28 -0
- data/spec/paint_action_spec.rb +30 -0
- data/spec/pen_spec.rb +62 -0
- data/spec/players/button_spec.rb +31 -0
- data/spec/players/check_box_spec.rb +40 -0
- data/spec/players/combo_box_spec.rb +39 -0
- data/spec/players/radio_button_spec.rb +75 -0
- data/spec/players/text_area_spec.rb +37 -0
- data/spec/players/text_box_spec.rb +37 -0
- data/spec/producer_spec.rb +157 -0
- data/spec/production_builder_spec.rb +48 -0
- data/spec/production_spec.rb +75 -0
- data/spec/prop_builder_spec.rb +178 -0
- data/spec/prop_spec.rb +216 -0
- data/spec/scene_spec.rb +34 -0
- data/spec/spec_helper.rb +18 -0
- data/spec/stage_builder_spec.rb +90 -0
- data/spec/stage_spec.rb +57 -0
- data/spec/styles_builder_spec.rb +123 -0
- data/spec/theater_spec.rb +66 -0
- metadata +275 -0
@@ -0,0 +1,47 @@
|
|
1
|
+
#- Copyright 2008 8th Light, Inc.
|
2
|
+
#- Limelight and all included source files are distributed under terms of the GNU LGPL.
|
3
|
+
|
4
|
+
module Limelight
|
5
|
+
module Players
|
6
|
+
|
7
|
+
module RadioButton
|
8
|
+
class << self
|
9
|
+
def extended(prop)
|
10
|
+
prop.panel.painters.clear
|
11
|
+
painter = Java.limelight.ui.painting.RadioButtonPainter.new(prop.panel)
|
12
|
+
prop.radio_button = painter.radio_button
|
13
|
+
prop.panel.painters << painter
|
14
|
+
prop.panel.clear_event_listeners
|
15
|
+
set_default_styles(prop)
|
16
|
+
end
|
17
|
+
|
18
|
+
def set_default_styles(prop)
|
19
|
+
prop.style.width = "22"
|
20
|
+
prop.style.height = "22"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
attr_accessor :radio_button
|
25
|
+
attr_reader :button_group
|
26
|
+
|
27
|
+
def group=(group_name)
|
28
|
+
@button_group = scene.button_groups[group_name]
|
29
|
+
@button_group.add(@radio_button)
|
30
|
+
end
|
31
|
+
|
32
|
+
def checked=(value)
|
33
|
+
@radio_button.selected = value
|
34
|
+
end
|
35
|
+
alias :selected= :checked=
|
36
|
+
|
37
|
+
def checked
|
38
|
+
return @radio_button.is_selected
|
39
|
+
end
|
40
|
+
alias :checked? :checked
|
41
|
+
alias :selected? :checked
|
42
|
+
alias :selected :checked
|
43
|
+
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
#- Copyright 2008 8th Light, Inc.
|
2
|
+
#- Limelight and all included source files are distributed under terms of the GNU LGPL.
|
3
|
+
|
4
|
+
module Limelight
|
5
|
+
module Players
|
6
|
+
|
7
|
+
module TextArea
|
8
|
+
class << self
|
9
|
+
def extended(prop)
|
10
|
+
prop.panel.painters.clear
|
11
|
+
prop.panel.painters << Java.limelight.ui.painting.TextAreaPainter.new(prop.panel)
|
12
|
+
prop.panel.clear_event_listeners
|
13
|
+
set_default_styles(prop)
|
14
|
+
end
|
15
|
+
|
16
|
+
def set_default_styles(prop)
|
17
|
+
prop.style.width ||= "240"
|
18
|
+
prop.style.height ||= "88"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
#- Copyright 2008 8th Light, Inc.
|
2
|
+
#- Limelight and all included source files are distributed under terms of the GNU LGPL.
|
3
|
+
|
4
|
+
module Limelight
|
5
|
+
module Players
|
6
|
+
|
7
|
+
module TextBox
|
8
|
+
class << self
|
9
|
+
def extended(prop)
|
10
|
+
prop.panel.painters.clear
|
11
|
+
prop.panel.painters << Java.limelight.ui.painting.TextBoxPainter.new(prop.panel)
|
12
|
+
prop.panel.clear_event_listeners
|
13
|
+
set_default_styles(prop)
|
14
|
+
end
|
15
|
+
|
16
|
+
def set_default_styles(prop)
|
17
|
+
prop.style.width = "120"
|
18
|
+
prop.style.height = "22"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
#- Copyright 2008 8th Light, Inc.
|
2
|
+
#- Limelight and all included source files are distributed under terms of the GNU LGPL.
|
3
|
+
|
4
|
+
require 'limelight/players/button'
|
5
|
+
require 'limelight/players/check_box'
|
6
|
+
require 'limelight/players/combo_box'
|
7
|
+
require 'limelight/players/radio_button'
|
8
|
+
require 'limelight/players/text_area'
|
9
|
+
require 'limelight/players/text_box'
|
@@ -0,0 +1,141 @@
|
|
1
|
+
#- Copyright 2008 8th Light, Inc.
|
2
|
+
#- Limelight and all included source files are distributed under terms of the GNU LGPL.
|
3
|
+
|
4
|
+
require 'limelight/loaders/file_scene_loader'
|
5
|
+
require 'limelight/prop_builder'
|
6
|
+
require 'limelight/styles_builder'
|
7
|
+
require 'limelight/stage_builder'
|
8
|
+
require 'limelight/production_builder'
|
9
|
+
require 'limelight/casting_director'
|
10
|
+
require 'limelight/stage'
|
11
|
+
require 'limelight/build_exception'
|
12
|
+
require 'limelight/theater'
|
13
|
+
require 'limelight/production'
|
14
|
+
|
15
|
+
module Limelight
|
16
|
+
|
17
|
+
class Producer
|
18
|
+
|
19
|
+
def self.open(production_name)
|
20
|
+
if(production_name[-4..-1] == ".llp")
|
21
|
+
production_name = unpack_production(production_name)
|
22
|
+
end
|
23
|
+
producer = new(production_name)
|
24
|
+
producer.open
|
25
|
+
end
|
26
|
+
|
27
|
+
attr_reader :loader, :theater, :production
|
28
|
+
|
29
|
+
def initialize(root_path, theater=nil, production=nil)
|
30
|
+
@loader = Loaders::FileSceneLoader.for_root(root_path)
|
31
|
+
@theater = theater.nil? ? Theater.new : theater
|
32
|
+
@production = production
|
33
|
+
end
|
34
|
+
|
35
|
+
def casting_director
|
36
|
+
@casting_director = CastingDirector.new(loader) if not @casting_director
|
37
|
+
return @casting_director
|
38
|
+
end
|
39
|
+
|
40
|
+
def open()
|
41
|
+
establish_production
|
42
|
+
Kernel.load(@loader.path_to("init.rb")) if @loader.exists?("init.rb")
|
43
|
+
if @loader.exists?("stages.rb")
|
44
|
+
load_stages.each { |stage| open_scene(stage.default_scene, stage) }
|
45
|
+
else
|
46
|
+
open_scene('.', @theater.default_stage)
|
47
|
+
end
|
48
|
+
@casting_director = nil
|
49
|
+
end
|
50
|
+
|
51
|
+
def open_scene(path, stage)
|
52
|
+
styles = load_styles(path)
|
53
|
+
merge_with_root_styles(styles)
|
54
|
+
|
55
|
+
scene = load_props(path, :styles => styles, :production => @production, :casting_director => casting_director, :loader => @loader, :path => path)
|
56
|
+
|
57
|
+
stage.open(scene)
|
58
|
+
end
|
59
|
+
|
60
|
+
def load_stages
|
61
|
+
content = @loader.load("stages.rb")
|
62
|
+
stages = Limelight.build_stages(@theater) do
|
63
|
+
begin
|
64
|
+
eval content
|
65
|
+
rescue Exception => e
|
66
|
+
raise BuildException.new("stages.rb", content, e)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
return stages
|
70
|
+
end
|
71
|
+
|
72
|
+
def load_props(path, options = {})
|
73
|
+
return Scene.new(options) if path.nil?
|
74
|
+
filename = File.join(path, "props.rb")
|
75
|
+
content = @loader.exists?(filename) ? @loader.load(filename) : ""
|
76
|
+
options[:build_loader] = @loader
|
77
|
+
return Limelight.build_scene(options) do
|
78
|
+
begin
|
79
|
+
eval content
|
80
|
+
rescue Exception => e
|
81
|
+
raise BuildException.new(filename, content, e)
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
def load_styles(path)
|
87
|
+
return {} if path.nil?
|
88
|
+
filename = File.join(path, "styles.rb")
|
89
|
+
return {} if not @loader.exists?(filename)
|
90
|
+
content = @loader.load(filename)
|
91
|
+
return Limelight.build_styles do
|
92
|
+
begin
|
93
|
+
eval content
|
94
|
+
rescue Exception => e
|
95
|
+
raise BuildException.new(filename, content, e)
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
def establish_production
|
101
|
+
return if @production
|
102
|
+
if @loader.exists?("production.rb")
|
103
|
+
content = @loader.load("production.rb")
|
104
|
+
@production = Limelight.build_production(self, @theater) do
|
105
|
+
begin
|
106
|
+
eval content
|
107
|
+
rescue Exception => e
|
108
|
+
raise BuildException.new("production.rb", content, e)
|
109
|
+
end
|
110
|
+
end
|
111
|
+
else
|
112
|
+
@production = Production.new(self, @theater)
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
def root_styles
|
117
|
+
return @root_syles if @root_syles
|
118
|
+
if @loader.exists?('styles.rb')
|
119
|
+
@root_styles = load_styles('.')
|
120
|
+
else
|
121
|
+
@root_styles = {}
|
122
|
+
end
|
123
|
+
return @root_styles
|
124
|
+
end
|
125
|
+
|
126
|
+
private ###############################################
|
127
|
+
|
128
|
+
def merge_with_root_styles(styles)
|
129
|
+
root_styles.each_pair do |key, value|
|
130
|
+
styles[key] = value if !styles.has_key?(key)
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
def self.unpack_production(production_name)
|
135
|
+
packer = Java::limelight::io.Packer.new()
|
136
|
+
return packer.unpack(production_name)
|
137
|
+
end
|
138
|
+
|
139
|
+
end
|
140
|
+
|
141
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
#- Copyright 2008 8th Light, Inc.
|
2
|
+
#- Limelight and all included source files are distributed under terms of the GNU LGPL.
|
3
|
+
|
4
|
+
require 'limelight/limelight_exception'
|
5
|
+
|
6
|
+
module Limelight
|
7
|
+
|
8
|
+
class Production
|
9
|
+
|
10
|
+
class << self
|
11
|
+
|
12
|
+
def index(production)
|
13
|
+
@index = [] if @index.nil?
|
14
|
+
if production.name.nil?
|
15
|
+
assign_name_to(production)
|
16
|
+
else
|
17
|
+
error_if_duplicate_name(production.name)
|
18
|
+
end
|
19
|
+
@index << production
|
20
|
+
end
|
21
|
+
|
22
|
+
def [](name)
|
23
|
+
return nil if @index.nil?
|
24
|
+
return @index.find { |production| production.name == name }
|
25
|
+
end
|
26
|
+
|
27
|
+
def assign_name_to(production)
|
28
|
+
count = @index.length + 1
|
29
|
+
while name_taken?(count.to_s)
|
30
|
+
count += 1
|
31
|
+
end
|
32
|
+
production.name = count.to_s
|
33
|
+
end
|
34
|
+
|
35
|
+
def name_taken?(name)
|
36
|
+
return self[name] != nil
|
37
|
+
end
|
38
|
+
|
39
|
+
def clear_index
|
40
|
+
@index = []
|
41
|
+
end
|
42
|
+
|
43
|
+
def error_if_duplicate_name(name)
|
44
|
+
raise Limelight::LimelightException.new("Production name '#{name}' is already taken") if name_taken?(name)
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
|
49
|
+
attr_reader :producer, :theater, :name
|
50
|
+
|
51
|
+
def initialize(producer, theater)
|
52
|
+
@producer = producer
|
53
|
+
@theater = theater
|
54
|
+
self.class.index(self)
|
55
|
+
end
|
56
|
+
|
57
|
+
def name=(value)
|
58
|
+
self.class.error_if_duplicate_name(value)
|
59
|
+
@name = value
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
#- Copyright 2008 8th Light, Inc.
|
2
|
+
#- Limelight and all included source files are distributed under terms of the GNU LGPL.
|
3
|
+
|
4
|
+
require 'limelight/production'
|
5
|
+
require 'limelight/limelight_exception'
|
6
|
+
|
7
|
+
module Limelight
|
8
|
+
|
9
|
+
def self.build_production(producer, theater, &block)
|
10
|
+
builder = ProductionBuilder.new(producer, theater)
|
11
|
+
builder.instance_eval(&block) if block
|
12
|
+
return builder.__production__
|
13
|
+
end
|
14
|
+
|
15
|
+
class ProductionBuilder
|
16
|
+
|
17
|
+
class << self
|
18
|
+
|
19
|
+
attr_accessor :current_attribute
|
20
|
+
|
21
|
+
end
|
22
|
+
|
23
|
+
attr_reader :__production__
|
24
|
+
|
25
|
+
def initialize(producer, theater)
|
26
|
+
@__production__ = Production.new(producer, theater)
|
27
|
+
end
|
28
|
+
|
29
|
+
def method_missing(sym, value)
|
30
|
+
setter_sym = "#{sym}=".to_s
|
31
|
+
raise ProductionBuilderException.new(sym) if !@__production__.respond_to?(setter_sym)
|
32
|
+
@__production__.send(setter_sym, value)
|
33
|
+
end
|
34
|
+
|
35
|
+
def attribute(sym)
|
36
|
+
ProductionBuilder.current_attribute = sym
|
37
|
+
class << @__production__
|
38
|
+
attr_accessor ProductionBuilder.current_attribute
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
class ProductionBuilderException < LimelightException
|
44
|
+
def initialize(name)
|
45
|
+
super("'#{name}' is not a valid production property")
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
@@ -0,0 +1,241 @@
|
|
1
|
+
#- Copyright 2008 8th Light, Inc.
|
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
|
+
|
8
|
+
module Limelight
|
9
|
+
class Prop
|
10
|
+
|
11
|
+
class << self
|
12
|
+
|
13
|
+
def event(*syms)
|
14
|
+
@events ||= []
|
15
|
+
syms.each do |sym|
|
16
|
+
@events << sym unless @events.include?(sym)
|
17
|
+
define_method(sym) { |event| } # do nothing by default
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def events
|
22
|
+
return @events
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
include Java::limelight.ui.Prop
|
28
|
+
|
29
|
+
attr_reader :panel, :style, :children, :scene, :parent
|
30
|
+
attr_reader :name, :id, :players
|
31
|
+
getters :panel, :style, :scene, :name, :text
|
32
|
+
setters :text
|
33
|
+
|
34
|
+
def initialize(hash = {})
|
35
|
+
@options = hash
|
36
|
+
@children = []
|
37
|
+
@panel = Java::limelight.ui.Panel.new(self)
|
38
|
+
@style = Java::limelight.ui.ScreenableStyle.new
|
39
|
+
end
|
40
|
+
|
41
|
+
def add(child)
|
42
|
+
@children << child
|
43
|
+
@panel.add(child.panel)
|
44
|
+
child.set_parent(self)
|
45
|
+
end
|
46
|
+
|
47
|
+
def <<(child)
|
48
|
+
add(child)
|
49
|
+
return self
|
50
|
+
end
|
51
|
+
|
52
|
+
def build(&block)
|
53
|
+
require 'limelight/prop_builder'
|
54
|
+
builder = Limelight::PropBuilder.new(self)
|
55
|
+
builder.instance_eval(&block)
|
56
|
+
end
|
57
|
+
|
58
|
+
def remove(child)
|
59
|
+
if children.delete(child)
|
60
|
+
@panel.remove(child.panel)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
def remove_all
|
65
|
+
@panel.remove_all
|
66
|
+
@children = []
|
67
|
+
end
|
68
|
+
|
69
|
+
def add_controller(controller_module)
|
70
|
+
extend controller_module unless self.is_a?(controller_module)
|
71
|
+
end
|
72
|
+
|
73
|
+
alias :include_player :add_controller
|
74
|
+
|
75
|
+
def update
|
76
|
+
return if(@scene.nil? || !@scene.visible)
|
77
|
+
@panel.doLayout
|
78
|
+
@panel.repaint
|
79
|
+
end
|
80
|
+
|
81
|
+
def update_now
|
82
|
+
return if(@scene.nil? || !@scene.visible)
|
83
|
+
@panel.doLayout()
|
84
|
+
@panel.paintImmediately(0, 0, @panel.width, @panel.height)
|
85
|
+
end
|
86
|
+
|
87
|
+
def after_painting(flag = true, &block)
|
88
|
+
if flag
|
89
|
+
@panel.after_paint_action = PaintAction.new(&block)
|
90
|
+
else
|
91
|
+
@panel.after_paint_action = nil
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
def find(id)
|
96
|
+
return self if @id == id
|
97
|
+
@children.each do |child|
|
98
|
+
result = child.find(id)
|
99
|
+
return result if result
|
100
|
+
end
|
101
|
+
return nil
|
102
|
+
end
|
103
|
+
|
104
|
+
def find_by_name(name, results = [])
|
105
|
+
results << self if @name == name
|
106
|
+
@children.each { |child| child.find_by_name(name, results) }
|
107
|
+
return results
|
108
|
+
end
|
109
|
+
|
110
|
+
def text=(value)
|
111
|
+
@panel.text_accessor.text = value
|
112
|
+
end
|
113
|
+
|
114
|
+
def text
|
115
|
+
return panel.text_accessor.text
|
116
|
+
end
|
117
|
+
|
118
|
+
#TODO - MDM - DELETE ME
|
119
|
+
def stage
|
120
|
+
return scene.stage
|
121
|
+
end
|
122
|
+
|
123
|
+
def production
|
124
|
+
return scene.production
|
125
|
+
end
|
126
|
+
|
127
|
+
def to_s
|
128
|
+
return "#{self.class.name}[id: #{@id}, name: #{@name}]"
|
129
|
+
end
|
130
|
+
|
131
|
+
def inspect
|
132
|
+
return self.to_s
|
133
|
+
end
|
134
|
+
|
135
|
+
# unusual name because it's not part of public api
|
136
|
+
def set_parent(parent)
|
137
|
+
@parent = parent
|
138
|
+
set_scene parent.scene
|
139
|
+
end
|
140
|
+
|
141
|
+
# unusual name because it's not part of public api
|
142
|
+
def set_scene(scene)
|
143
|
+
return if scene == @scene || scene.nil?
|
144
|
+
@scene = scene
|
145
|
+
illuminate
|
146
|
+
children.each { |child| child.set_scene(scene) }
|
147
|
+
end
|
148
|
+
|
149
|
+
def add_options(more_options)
|
150
|
+
raise "Too late to add options" if @options.nil?
|
151
|
+
@options.merge!(more_options)
|
152
|
+
end
|
153
|
+
|
154
|
+
def area
|
155
|
+
return panel.get_rectangle.clone
|
156
|
+
end
|
157
|
+
|
158
|
+
def bordered_area
|
159
|
+
return panel.get_rectangle_inside_borders.clone
|
160
|
+
end
|
161
|
+
|
162
|
+
def pen
|
163
|
+
return Pen.new(panel.getGraphics)
|
164
|
+
end
|
165
|
+
|
166
|
+
# GUI Events ##########################################
|
167
|
+
|
168
|
+
def hover_on
|
169
|
+
return nil if @hover_style.nil?
|
170
|
+
@panel.setCursor(java.awt.Cursor.new(java.awt.Cursor::HAND_CURSOR))
|
171
|
+
style.applyScreen(@hover_style)
|
172
|
+
update
|
173
|
+
end
|
174
|
+
|
175
|
+
def hover_off
|
176
|
+
return nil if @hover_style.nil?
|
177
|
+
@panel.setCursor(java.awt.Cursor.new(java.awt.Cursor::DEFAULT_CURSOR))
|
178
|
+
@style.removeScreen()
|
179
|
+
update
|
180
|
+
end
|
181
|
+
|
182
|
+
EVENTS = [:mouse_clicked, :mouse_entered, :mouse_exited, :mouse_pressed, :mouse_released, :mouse_dragged, :mouse_moved,
|
183
|
+
:key_typed, :key_pressed, :key_released, :focus_gained, :focus_lost, :state_changed, :button_pressed, :item_state_changed]
|
184
|
+
|
185
|
+
event *EVENTS
|
186
|
+
|
187
|
+
private ###############################################
|
188
|
+
|
189
|
+
def illuminate
|
190
|
+
return if @options.nil?
|
191
|
+
|
192
|
+
@id = @options.delete(:id)
|
193
|
+
@name = @options.delete(:name)
|
194
|
+
@players = @options.delete(:players)
|
195
|
+
|
196
|
+
inherit_styles
|
197
|
+
@scene.casting_director.fill_cast(self)
|
198
|
+
apply_options
|
199
|
+
|
200
|
+
@options = nil
|
201
|
+
end
|
202
|
+
|
203
|
+
def apply_options
|
204
|
+
@options.each_pair do |key, value|
|
205
|
+
setter_sym = "#{key.to_s}=".to_sym
|
206
|
+
if self.respond_to?(setter_sym)
|
207
|
+
self.send(setter_sym, value)
|
208
|
+
elsif self.style.respond_to?(setter_sym)
|
209
|
+
self.style.send(setter_sym, value)
|
210
|
+
elsif is_event_setter(key)
|
211
|
+
define_event(key, value)
|
212
|
+
end
|
213
|
+
end
|
214
|
+
end
|
215
|
+
|
216
|
+
def is_event_setter(symbol)
|
217
|
+
string_value = symbol.to_s
|
218
|
+
return string_value[0..2] == "on_" and self.events.include?(string_value[3..-1].to_sym)
|
219
|
+
end
|
220
|
+
|
221
|
+
def define_event(symbol, value)
|
222
|
+
event_name = symbol.to_s[3..-1]
|
223
|
+
self.instance_eval "def #{event_name}(event); #{value}; end"
|
224
|
+
end
|
225
|
+
|
226
|
+
def inherit_styles
|
227
|
+
return if @name.nil?
|
228
|
+
new_style = @scene.styles[@name]
|
229
|
+
@style.add_extension(new_style) if new_style
|
230
|
+
@hover_style = scene.styles["#{@name}.hover"]
|
231
|
+
end
|
232
|
+
|
233
|
+
def disinherit_styles
|
234
|
+
return if @name.nil?
|
235
|
+
old_style = @scene.styles[@name]
|
236
|
+
@style.remove_extension(old_style) if old_style
|
237
|
+
@hover_style = nil
|
238
|
+
end
|
239
|
+
|
240
|
+
end
|
241
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
#- Copyright 2008 8th Light, Inc.
|
2
|
+
#- Limelight and all included source files are distributed under terms of the GNU LGPL.
|
3
|
+
|
4
|
+
require 'limelight/prop'
|
5
|
+
require 'limelight/scene'
|
6
|
+
require 'limelight/build_exception'
|
7
|
+
|
8
|
+
module Limelight
|
9
|
+
|
10
|
+
def self.build_scene(options={}, &block)
|
11
|
+
loader = options.delete(:build_loader)
|
12
|
+
builder = SceneBuilder.new(options)
|
13
|
+
builder.__loader__ = loader
|
14
|
+
builder.instance_eval(&block) if block
|
15
|
+
return builder.__prop__
|
16
|
+
end
|
17
|
+
|
18
|
+
class PropBuilder
|
19
|
+
attr_reader :__prop__
|
20
|
+
attr_accessor :__loader__
|
21
|
+
|
22
|
+
def initialize(options)
|
23
|
+
if options.is_a?(Prop)
|
24
|
+
@__prop__ = options
|
25
|
+
else
|
26
|
+
@__prop__ = Prop.new(options)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def __(options)
|
31
|
+
@__prop__.add_options(options)
|
32
|
+
end
|
33
|
+
|
34
|
+
def __install(file)
|
35
|
+
raise "Cannot install external props because no loader was provided" if @__loader__.nil?
|
36
|
+
raise "External prop file: '#{file}' doesn't exist" if !@__loader__.exists?(file)
|
37
|
+
content = @__loader__.load(file)
|
38
|
+
begin
|
39
|
+
self.instance_eval(content)
|
40
|
+
rescue Exception => e
|
41
|
+
raise BuildException.new(file, content, e)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def method_missing(sym, options={}, &prop)
|
46
|
+
options[:name] ||= sym.to_s
|
47
|
+
builder = PropBuilder.new(options)
|
48
|
+
builder.__loader__ = @__loader__
|
49
|
+
builder.instance_eval(&prop) if prop
|
50
|
+
@__prop__.add(builder.__prop__)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
class SceneBuilder < PropBuilder
|
55
|
+
def initialize(options)
|
56
|
+
@__prop__ = Scene.new(options)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|