limelight 0.4.0-java → 0.5.0-java
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/limelight.jar +0 -0
- data/lib/limelight/animation.rb +4 -3
- data/lib/limelight/builtin/players.rb +3 -1
- data/lib/limelight/builtin/players/image.rb +4 -0
- data/lib/limelight/builtin/players/stage_mover.rb +31 -0
- data/lib/limelight/builtin/players/stage_sizer.rb +34 -0
- data/lib/limelight/builtin/utilities_production/alert/players/alert.rb +11 -0
- data/lib/limelight/builtin/utilities_production/alert/props.rb +3 -0
- data/lib/limelight/builtin/utilities_production/alert/styles.rb +7 -0
- data/lib/limelight/builtin/utilities_production/incompatible_version/props.rb +3 -0
- data/lib/limelight/builtin/utilities_production/incompatible_version/styles.rb +3 -0
- data/lib/limelight/builtin/utilities_production/production.rb +3 -0
- data/lib/limelight/builtin/utilities_production/stages.rb +3 -0
- data/lib/limelight/builtin/utilities_production/styles.rb +3 -0
- data/lib/limelight/casting_director.rb +1 -1
- data/lib/limelight/commands/create_command.rb +33 -19
- data/lib/limelight/commands/freeze_command.rb +20 -5
- data/lib/limelight/commands/open_command.rb +2 -1
- data/lib/limelight/dsl/styles_builder.rb +40 -18
- data/lib/limelight/file_loader.rb +1 -1
- data/lib/limelight/gems.rb +3 -1
- data/lib/limelight/java_couplings.rb +1 -0
- data/lib/limelight/producer.rb +4 -47
- data/lib/limelight/production.rb +20 -0
- data/lib/limelight/prop.rb +32 -32
- data/lib/limelight/scene.rb +2 -1
- data/lib/limelight/specs/spec_helper.rb +24 -22
- data/lib/limelight/specs/test_scene_opener.rb +60 -0
- data/lib/limelight/string.rb +1 -1
- data/lib/limelight/studio.rb +28 -9
- data/lib/limelight/templates/production_templater.rb +5 -2
- data/lib/limelight/templates/scene_templater.rb +7 -6
- data/lib/limelight/templates/sources/production/production.rb.template +1 -1
- data/lib/limelight/templates/sources/production/spec/spec_helper.rb.template +8 -1
- data/lib/limelight/version.rb +1 -1
- data/productions/examples/sandbox/alerts/incompatible_production/default_scene/props.rb +3 -0
- data/productions/examples/sandbox/alerts/incompatible_production/default_scene/styles.rb +3 -0
- data/productions/examples/sandbox/alerts/incompatible_production/production.rb +3 -0
- data/productions/examples/sandbox/alerts/incompatible_production/spec/default_scene/default_scene_spec.rb +3 -0
- data/productions/examples/sandbox/alerts/incompatible_production/spec/spec_helper.rb +3 -0
- data/productions/examples/sandbox/alerts/incompatible_production/stages.rb +3 -0
- data/productions/examples/sandbox/alerts/incompatible_production/styles.rb +3 -0
- data/productions/examples/sandbox/alerts/players/alerts.rb +3 -0
- data/productions/examples/sandbox/alerts/props.rb +3 -0
- data/productions/examples/sandbox/alerts/styles.rb +3 -0
- data/productions/examples/sandbox/background_images/props.rb +3 -0
- data/productions/examples/sandbox/header.rb +1 -0
- data/productions/examples/sandbox/images_scene/props.rb +8 -0
- data/productions/examples/sandbox/kiosk/players/kiosk.rb +3 -0
- data/productions/examples/sandbox/kiosk/props.rb +3 -0
- data/productions/examples/sandbox/kiosk/styles.rb +3 -0
- data/productions/examples/sandbox/spec/alerts/alerts_spec.rb +3 -0
- data/productions/examples/sandbox/stage_handles/players/sizer.rb +35 -0
- data/productions/examples/sandbox/stage_handles/props.rb +17 -0
- data/productions/examples/sandbox/stage_handles/styles.rb +58 -0
- data/productions/playbills.lll +1 -0
- data/productions/startup/production.rb +3 -0
- data/productions/startup/spec/default_scene/default_scene_spec.rb +3 -0
- data/productions/startup/spec/spec_helper.rb +3 -0
- data/productions/startup/styles.rb +3 -0
- data/spec/{builtin → limelight/builtin}/players/button_spec.rb +1 -1
- data/spec/{builtin → limelight/builtin}/players/check_box_spec.rb +1 -1
- data/spec/{builtin → limelight/builtin}/players/combo_box_spec.rb +1 -1
- data/spec/{builtin → limelight/builtin}/players/image_spec.rb +1 -2
- data/spec/{builtin → limelight/builtin}/players/password_box_spec.rb +1 -1
- data/spec/{builtin → limelight/builtin}/players/radio_button_spec.rb +1 -1
- data/spec/limelight/builtin/players/stage_mover_spec.rb +36 -0
- data/spec/limelight/builtin/players/stage_sizer_spec.rb +40 -0
- data/spec/{builtin → limelight/builtin}/players/text_area_spec.rb +1 -1
- data/spec/{builtin → limelight/builtin}/players/text_box_spec.rb +1 -1
- data/spec/limelight/builtin/utilities_production/spec_helper.rb +7 -0
- data/spec/{builtin → limelight/builtin}/utilities_production/utilities_production_spec.rb +3 -0
- data/spec/{casting_director_spec.rb → limelight/casting_director_spec.rb} +1 -1
- data/spec/{client → limelight/client}/playbills_spec.rb +1 -1
- data/spec/{commands → limelight/commands}/command_spec.rb +1 -1
- data/spec/{commands → limelight/commands}/create_command_spec.rb +23 -19
- data/spec/limelight/commands/freeze_command_spec.rb +143 -0
- data/spec/{commands → limelight/commands}/help_command_spec.rb +1 -1
- data/spec/{commands → limelight/commands}/open_command_spec.rb +1 -1
- data/spec/{commands → limelight/commands}/pack_command_spec.rb +1 -1
- data/spec/{commands → limelight/commands}/unpack_command_spec.rb +1 -1
- data/spec/{data_spec.rb → limelight/data_spec.rb} +1 -1
- data/spec/{dsl → limelight/dsl}/prop_builder_spec.rb +1 -1
- data/spec/{dsl → limelight/dsl}/stage_builder_spec.rb +1 -1
- data/spec/{dsl → limelight/dsl}/styles_builder_spec.rb +52 -13
- data/spec/{file_chooser_spec.rb → limelight/file_chooser_spec.rb} +1 -1
- data/spec/{file_filter_spec.rb → limelight/file_filter_spec.rb} +1 -1
- data/spec/{file_loader_spec.rb → limelight/file_loader_spec.rb} +1 -1
- data/spec/{gems_spec.rb → limelight/gems_spec.rb} +10 -4
- data/spec/{java_util_spec.rb → limelight/java_util_spec.rb} +1 -1
- data/spec/{main_spec.rb → limelight/main_spec.rb} +1 -1
- data/spec/{paint_action_spec.rb → limelight/paint_action_spec.rb} +1 -1
- data/spec/{pen_spec.rb → limelight/pen_spec.rb} +1 -1
- data/spec/{producer_spec.rb → limelight/producer_spec.rb} +4 -12
- data/spec/{production_spec.rb → limelight/production_spec.rb} +32 -11
- data/spec/{prop_spec.rb → limelight/prop_spec.rb} +30 -2
- data/spec/{scene_spec.rb → limelight/scene_spec.rb} +28 -2
- data/spec/{stage_spec.rb → limelight/stage_spec.rb} +1 -1
- data/spec/{string_spec.rb → limelight/string_spec.rb} +1 -1
- data/spec/{studio_spec.rb → limelight/studio_spec.rb} +16 -1
- data/spec/{styles_spec.rb → limelight/styles_spec.rb} +1 -1
- data/spec/{templates → limelight/templates}/production_templater_spec.rb +17 -6
- data/spec/{templates → limelight/templates}/scene_templater_spec.rb +15 -4
- data/spec/{templates → limelight/templates}/templater_logger_spec.rb +1 -1
- data/spec/{templates → limelight/templates}/templater_spec.rb +1 -1
- data/spec/{theater_spec.rb → limelight/theater_spec.rb} +1 -1
- data/spec/{util → limelight/util}/downloader_spec.rb +1 -1
- data/spec/spec_helper.rb +11 -0
- metadata +62 -70
- data/lib/limelight/dsl/production_builder.rb +0 -71
- data/spec/builtin/utilities_production/spec_helper.rb +0 -4
- data/spec/commands/freeze_command_spec.rb +0 -62
- data/spec/dsl/production_builder_spec.rb +0 -46
data/lib/limelight.jar
CHANGED
Binary file
|
data/lib/limelight/animation.rb
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
|
4
4
|
module Limelight
|
5
5
|
|
6
|
-
# An object to manage a seqeunce of changes,
|
6
|
+
# An object to manage a seqeunce of changes, assumedly to a prop. The Animation object is constructed with options
|
7
7
|
# and a block. Once the Animation is started, the block is invoked repeatedly until the Animation is stopped.
|
8
8
|
#
|
9
9
|
# Although, this object does not update the screen, it provides a means to perform sequential updates in evenly
|
@@ -11,8 +11,9 @@ module Limelight
|
|
11
11
|
#
|
12
12
|
class Animation < Limelight::Background::Animation
|
13
13
|
|
14
|
-
# A Prop and block are required to construct an Animation. Options may include
|
15
|
-
#
|
14
|
+
# A Prop and block are required to construct an Animation. Options may include
|
15
|
+
# 1. :name (string)
|
16
|
+
# 2. :updates_per_second (int defaults to 60)
|
16
17
|
#
|
17
18
|
# animation = Animation.new(prop, Proc.new { "do something"}, :updates_per_second => 20)
|
18
19
|
# animation.start
|
@@ -11,4 +11,6 @@ require 'limelight/builtin/players/combo_box_popup_list_item'
|
|
11
11
|
require 'limelight/builtin/players/combo_box_popup_list'
|
12
12
|
require 'limelight/builtin/players/curtains'
|
13
13
|
require 'limelight/builtin/players/image'
|
14
|
-
require "limelight/builtin/players/password_box"
|
14
|
+
require "limelight/builtin/players/password_box"
|
15
|
+
require "limelight/builtin/players/stage_mover"
|
16
|
+
require "limelight/builtin/players/stage_sizer"
|
@@ -0,0 +1,31 @@
|
|
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
|
+
module Limelight
|
5
|
+
module Builtin
|
6
|
+
module Players
|
7
|
+
|
8
|
+
module StageMover
|
9
|
+
|
10
|
+
def mouse_pressed(e)
|
11
|
+
@drag_reference_x = e.x
|
12
|
+
@drag_reference_y = e.y
|
13
|
+
end
|
14
|
+
|
15
|
+
def mouse_dragged(e)
|
16
|
+
dx = e.x - @drag_reference_x
|
17
|
+
dy = e.y - @drag_reference_y
|
18
|
+
|
19
|
+
frame = scene.stage.frame
|
20
|
+
location = frame.location
|
21
|
+
|
22
|
+
location.x += dx
|
23
|
+
location.y += dy
|
24
|
+
frame.location = location
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,34 @@
|
|
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
|
+
module Limelight
|
5
|
+
module Builtin
|
6
|
+
module Players
|
7
|
+
|
8
|
+
module StageSizer
|
9
|
+
|
10
|
+
def mouse_pressed(e)
|
11
|
+
@sizer_reference_x = e.x
|
12
|
+
@sizer_reference_y = e.y
|
13
|
+
@sizer_frame = scene.stage.frame
|
14
|
+
@sizer_reference_size = @sizer_frame.size
|
15
|
+
end
|
16
|
+
|
17
|
+
def mouse_dragged(e)
|
18
|
+
return unless @sizer_frame
|
19
|
+
dx = e.x - @sizer_reference_x
|
20
|
+
dy = e.y - @sizer_reference_y
|
21
|
+
|
22
|
+
@sizer_reference_x = e.x
|
23
|
+
@sizer_reference_y = e.y
|
24
|
+
|
25
|
+
@sizer_reference_size.width += dx
|
26
|
+
@sizer_reference_size.height += dy
|
27
|
+
@sizer_frame.size = @sizer_reference_size
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -1,7 +1,14 @@
|
|
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
|
+
|
1
4
|
alert {
|
2
5
|
background_color "#b2db5b"
|
3
6
|
secondary_background_color "#8fc927"
|
4
7
|
gradient :on
|
5
8
|
gradient_angle 270
|
6
9
|
padding 20
|
10
|
+
}
|
11
|
+
|
12
|
+
advise {
|
13
|
+
max_height 500
|
7
14
|
}
|
@@ -1,3 +1,6 @@
|
|
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
|
+
|
1
4
|
title :text => "Incompatible Version"
|
2
5
|
label :text => "Production:"
|
3
6
|
bold_label :id => "production_name_label", :text => @production_name
|
@@ -89,7 +89,7 @@ module Limelight
|
|
89
89
|
private ###############################################
|
90
90
|
|
91
91
|
def locate_player
|
92
|
-
player_filename = File.join(@prop.scene.path.to_s, "players", "#{@player_name}.rb")
|
92
|
+
player_filename = File.join(@prop.scene.path.to_s, "players", "#{@player_name}.rb")
|
93
93
|
if !@loader.exists?(player_filename)
|
94
94
|
if @prop.scene.production && @prop.scene.path != @prop.scene.production.path
|
95
95
|
player_filename = File.join(@prop.scene.production.path.to_s, "players", "#{@player_name}.rb")
|
@@ -8,17 +8,19 @@ module Limelight
|
|
8
8
|
|
9
9
|
# See the following usages summary
|
10
10
|
#
|
11
|
-
#
|
12
|
-
#
|
13
|
-
#
|
14
|
-
#
|
15
|
-
#
|
11
|
+
# Usage: limelight create [options] <production|scene> <path>
|
12
|
+
# Creates the directories and files for a production and/or scene.
|
13
|
+
# options:
|
14
|
+
# -h, --help Prints this usage summary.
|
15
|
+
# -s, --scene=<name> Name of scene when creating a production. Defaults to 'default_scene'.
|
16
|
+
# -p, --production_path=<path> Path of production to contain scene. Defaults to '.'.
|
17
|
+
# -S, --spec_path=<path> Path to spec directory, relative to <production_path>. Defaults to 'spec'.
|
16
18
|
#
|
17
19
|
# Assume you wanted to create a new production named "love_story" containing two scenes, "midnight_romance" and
|
18
20
|
# "happily_ever_after". The following commands would created all the needed files.
|
19
21
|
#
|
20
22
|
# $ jruby -S limelight create -s midnight_romance production love_story
|
21
|
-
# $ jruby -S limelight create scene
|
23
|
+
# $ jruby -S limelight create -p love_story scene happily_ever_after
|
22
24
|
#
|
23
25
|
class CreateCommand < Command
|
24
26
|
|
@@ -28,33 +30,30 @@ module Limelight
|
|
28
30
|
return "Creates the directories and files for a production and/or scene."
|
29
31
|
end
|
30
32
|
|
31
|
-
attr_reader :template_type, :
|
33
|
+
attr_reader :template_type, :scene_name, :production_path, :spec_path #:nodoc:
|
32
34
|
|
33
35
|
protected ###########################################
|
34
36
|
|
35
37
|
def initialize #:nodoc:
|
36
38
|
@scene_name = "default_scene"
|
37
39
|
@production_path = "."
|
38
|
-
@actions = {}
|
39
|
-
@actions["production"] = :create_production
|
40
|
-
@actions["scene"] = :create_scene
|
41
40
|
end
|
42
41
|
|
43
42
|
def process #:nodoc:
|
44
|
-
|
45
|
-
self.send
|
43
|
+
create_method = "create_#{@template_type}".to_s
|
44
|
+
self.send create_method
|
46
45
|
end
|
47
46
|
|
48
47
|
def parameter_description #:nodoc:
|
49
|
-
return "[options] <production|scene> <
|
48
|
+
return "[options] <production|scene> <path>"
|
50
49
|
end
|
51
50
|
|
52
51
|
def parse_remainder(args) #:nodoc:
|
53
52
|
@template_type = args.shift
|
54
53
|
raise "Missing template type" if @template_type.nil?
|
55
|
-
raise "Unknown template type: #{@template_type}" if
|
56
|
-
@
|
57
|
-
|
54
|
+
raise "Unknown template type: #{@template_type}" if !["production", "scene"].include?(@template_type)
|
55
|
+
self.send "parse_#{@template_type}".to_sym, args
|
56
|
+
@spec_path = File.join(@production_path, "spec") unless @spec_path
|
58
57
|
end
|
59
58
|
|
60
59
|
def do_requires #:nodoc:
|
@@ -65,17 +64,32 @@ module Limelight
|
|
65
64
|
def build_options(spec) #:nodoc:
|
66
65
|
spec.on("-s <name>", "--scene=<name>", "Name of scene when creating a production. Defaults to 'default_scene'.") { |value| @scene_name = value}
|
67
66
|
spec.on("-p <path>", "--production_path=<path>", "Path of production to contain scene. Defaults to '.'.") { |value| @production_path = value}
|
67
|
+
spec.on("-S <path>", "--spec_path=<path>", "Path to spec directory, relative to <production_path>. Defaults to 'spec'.") { |value| @spec_path = value}
|
68
68
|
end
|
69
69
|
|
70
70
|
private #############################################
|
71
71
|
|
72
|
+
def parse_production(args)
|
73
|
+
@production_path = args.shift
|
74
|
+
raise "Missing production path parameter" if @production_path.nil?
|
75
|
+
end
|
76
|
+
|
77
|
+
def parse_scene(args)
|
78
|
+
@scene_name = args.shift
|
79
|
+
raise "Missing scene name/path parameter" if @scene_name.nil?
|
80
|
+
end
|
81
|
+
|
72
82
|
def create_production
|
73
|
-
Templates::ProductionTemplater.new(
|
74
|
-
Templates::SceneTemplater.new(
|
83
|
+
Templates::ProductionTemplater.new(options_hash).generate
|
84
|
+
Templates::SceneTemplater.new(options_hash).generate
|
75
85
|
end
|
76
86
|
|
77
87
|
def create_scene
|
78
|
-
Templates::SceneTemplater.new(
|
88
|
+
Templates::SceneTemplater.new(options_hash).generate
|
89
|
+
end
|
90
|
+
|
91
|
+
def options_hash
|
92
|
+
return {:production_path => @production_path, :scene_path => @scene_name, :spec_path => @spec_path}
|
79
93
|
end
|
80
94
|
|
81
95
|
end
|
@@ -40,7 +40,7 @@ module Limelight
|
|
40
40
|
def process #:nodoc:
|
41
41
|
check_production_path
|
42
42
|
gem_path = is_gem_file?(@gem_name) ? @gem_name : find_system_gem
|
43
|
-
raise "Gem file does not exist: #{gem_path}"
|
43
|
+
raise "Gem file does not exist: #{gem_path}" unless File.exists?(gem_path)
|
44
44
|
freeze_gem(gem_path)
|
45
45
|
end
|
46
46
|
|
@@ -94,20 +94,35 @@ module Limelight
|
|
94
94
|
gem_installer = Gem::Installer.new(gem_path)
|
95
95
|
@templater.logger.log("unpacking gem", @gem_dir_path)
|
96
96
|
gem_installer.unpack(@gem_dir_path)
|
97
|
+
|
98
|
+
copy_gem_spec
|
99
|
+
end
|
100
|
+
|
101
|
+
def copy_gem_spec
|
102
|
+
@templater.directory(File.join("__resources", "gems", "specifications"))
|
103
|
+
FileUtils.copy(gemspec_path, local_gemspec_path) if File.exists?(gemspec_path)
|
97
104
|
|
98
105
|
install_limelight_hook
|
99
106
|
end
|
100
|
-
|
107
|
+
|
108
|
+
def gemspec_path
|
109
|
+
return File.join(Gem.dir, "specifications", "#{@gem_dir_name}.gemspec")
|
110
|
+
end
|
111
|
+
|
112
|
+
def local_gemspec_path
|
113
|
+
return File.join(@production_path, "__resources", "gems", "specifications")
|
114
|
+
end
|
115
|
+
|
101
116
|
def establish_gem_dir
|
102
117
|
@templater = Templates::Templater.new(@production_path)
|
103
|
-
@gem_dir_path = File.join(@production_path, "__resources", "gems", @gem_dir_name)
|
118
|
+
@gem_dir_path = File.join(@production_path, "__resources", "gems", "gems", @gem_dir_name)
|
104
119
|
raise "The gem (#{@gem_dir_name}) is already frozen." if File.exists?(@gem_dir_path)
|
105
|
-
@templater.directory(File.join("__resources", "gems", @gem_dir_name))
|
120
|
+
@templater.directory(File.join("__resources", "gems", "gems", @gem_dir_name))
|
106
121
|
end
|
107
122
|
|
108
123
|
def install_limelight_hook
|
109
124
|
tokens = { :GEM_NAME => @gem_dir_name, :PATHS => @gem_spec.require_paths.inspect }
|
110
|
-
@templater.file(File.join("__resources", "gems", @gem_dir_name, "limelight_init.rb"), "freezing/limelight_init.rb.template", tokens)
|
125
|
+
@templater.file(File.join("__resources", "gems", "gems", @gem_dir_name, "limelight_init.rb"), "freezing/limelight_init.rb.template", tokens)
|
111
126
|
end
|
112
127
|
|
113
128
|
end
|
@@ -12,6 +12,7 @@ module Limelight
|
|
12
12
|
# Open a limelight production.
|
13
13
|
# options:
|
14
14
|
# -h, --help Prints this usage summary.
|
15
|
+
# -d, --drb_port=<port> Publish the Studio using DRb on the specified port.
|
15
16
|
#
|
16
17
|
class OpenCommand < Command
|
17
18
|
|
@@ -41,7 +42,7 @@ module Limelight
|
|
41
42
|
end
|
42
43
|
|
43
44
|
def build_options(spec) #:nodoc:
|
44
|
-
spec.on("-d <port>", "--drb_port=<port>", "Publish the
|
45
|
+
spec.on("-d <port>", "--drb_port=<port>", "Publish the Studio using DRb on the specified port.") { |value| @drb_port = value }
|
45
46
|
end
|
46
47
|
|
47
48
|
def parse_remainder(args)
|
@@ -9,10 +9,22 @@ module Limelight
|
|
9
9
|
#
|
10
10
|
# See Limelight::Stylesbuilder, Limelight::Stylebuilder
|
11
11
|
#
|
12
|
-
def self.build_styles(
|
13
|
-
builder = DSL::StylesBuilder.new(
|
12
|
+
def self.build_styles(extendable_styles = nil, &block)
|
13
|
+
builder = DSL::StylesBuilder.new(extendable_styles)
|
14
14
|
builder.instance_eval(&block) if block
|
15
|
-
return builder.
|
15
|
+
return builder.__styles
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.build_styles_from_file(filename, extendable_styles = nil)
|
19
|
+
content = IO.read(filename)
|
20
|
+
styles = Limelight.build_styles(extendable_styles) do
|
21
|
+
begin
|
22
|
+
eval content
|
23
|
+
rescue Exception => e
|
24
|
+
raise Limelight::DSL::BuildException.new(filename, content, e)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
return styles
|
16
28
|
end
|
17
29
|
|
18
30
|
module DSL
|
@@ -50,20 +62,27 @@ module Limelight
|
|
50
62
|
|
51
63
|
Limelight::Util.lobotomize(self)
|
52
64
|
|
53
|
-
attr_reader :
|
65
|
+
attr_reader :__styles, :__extendable_styles
|
54
66
|
|
55
|
-
def initialize(
|
56
|
-
@
|
67
|
+
def initialize(extendable_styles = nil)
|
68
|
+
@__extendable_styles = extendable_styles || {}
|
69
|
+
@__styles = {}
|
57
70
|
end
|
58
71
|
|
59
72
|
def method_missing(sym, &block) #:nodoc:
|
60
|
-
|
73
|
+
__add_style(sym.to_s, &block)
|
61
74
|
end
|
62
75
|
|
63
|
-
def
|
64
|
-
|
76
|
+
def __add_style(name, &block) #:nodoc:
|
77
|
+
style = @__styles[name]
|
78
|
+
if style == nil
|
79
|
+
style = Styles::RichStyle.new
|
80
|
+
extension = @__extendable_styles[name]
|
81
|
+
style.add_extension(extension) if extension
|
82
|
+
end
|
83
|
+
builder = StyleBuilder.new(name, style, self)
|
65
84
|
builder.instance_eval(&block) if block
|
66
|
-
@
|
85
|
+
@__styles[name] = style
|
67
86
|
end
|
68
87
|
end
|
69
88
|
|
@@ -73,12 +92,12 @@ module Limelight
|
|
73
92
|
|
74
93
|
Limelight::Util.lobotomize(self)
|
75
94
|
|
76
|
-
attr_reader :
|
95
|
+
attr_reader :__style #:nodoc:
|
77
96
|
|
78
|
-
def initialize(name, styles_builder, options = {}) #:nodoc:
|
97
|
+
def initialize(name, style, styles_builder, options = {}) #:nodoc:
|
79
98
|
@__name = name
|
99
|
+
@__style = style
|
80
100
|
@__styles_builder = styles_builder
|
81
|
-
@__style__ = @__styles_builder.__styles__[name] || Styles::RichStyle.new
|
82
101
|
end
|
83
102
|
|
84
103
|
# Used to define a hover style. Hover styles are appiled when the mouse passed over a prop using the specified style.
|
@@ -94,7 +113,7 @@ module Limelight
|
|
94
113
|
# The text color of props using the 'spinner' style will become white when the mouse hovers over them.
|
95
114
|
#
|
96
115
|
def hover(&block)
|
97
|
-
@__styles_builder.
|
116
|
+
@__styles_builder.__add_style("#{@__name}.hover", &block)
|
98
117
|
end
|
99
118
|
|
100
119
|
# Styles may extend other styles.
|
@@ -113,22 +132,25 @@ module Limelight
|
|
113
132
|
#
|
114
133
|
def extends(*style_names)
|
115
134
|
style_names.each do |style_name|
|
116
|
-
extension = @__styles_builder.
|
135
|
+
extension = @__styles_builder.__styles[style_name.to_s] || @__styles_builder.__extendable_styles[style_name.to_s]
|
117
136
|
raise StyleBuilderException.new("Can't extend missing style: '#{style_name}'") if extension.nil?
|
118
|
-
@
|
137
|
+
@__style.add_extension(extension)
|
119
138
|
end
|
120
139
|
end
|
121
140
|
|
122
141
|
def method_missing(sym, value) #:nodoc:
|
123
142
|
setter_sym = "#{sym}=".to_s
|
124
|
-
raise StyleBuilderException.new("'#{sym}' is not a valid style") if !@
|
125
|
-
@
|
143
|
+
raise StyleBuilderException.new("'#{sym}' is not a valid style") if !@__style.respond_to?(setter_sym)
|
144
|
+
@__style.send(setter_sym, value.to_s)
|
126
145
|
end
|
127
146
|
end
|
128
147
|
|
129
148
|
# Exception thrown by StyleBuilder when an error is encountered.
|
130
149
|
#
|
131
150
|
class StyleBuilderException < Exception
|
151
|
+
def initialize(message)
|
152
|
+
super(message)
|
153
|
+
end
|
132
154
|
end
|
133
155
|
|
134
156
|
end
|