limelight 0.2.0-java → 0.2.1-java
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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
data/lib/limelight/styles.rb
CHANGED
@@ -1,37 +1,334 @@
|
|
1
1
|
#- Copyright 2008 8th Light, Inc. All Rights Reserved.
|
2
2
|
#- Limelight and all included source files are distributed under terms of the GNU LGPL.
|
3
3
|
|
4
|
-
require 'yaml'
|
5
|
-
|
6
4
|
module Limelight
|
7
|
-
|
8
|
-
class Styles
|
9
|
-
|
10
|
-
def self.load(content)
|
11
|
-
yamalized_content = content.gsub("\t", " ").gsub("#", "pigpen")
|
12
|
-
return YAML.load(yamalized_content)
|
13
|
-
end
|
14
|
-
|
15
|
-
def self.load_into_scene(filename, scene)
|
16
|
-
content = scene.loader.load(filename)
|
17
|
-
style_defs = load(content)
|
18
|
-
styles = scene.styles;
|
19
|
-
|
20
|
-
style_defs.each_pair do |key, value|
|
21
|
-
style = create_style(value)
|
22
|
-
styles[key] = style
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
def self.create_style(hash)
|
27
|
-
style = Styles::FlatStyle.new
|
28
|
-
hash.each_pair do |key, value|
|
29
|
-
value = value.to_s.gsub("pigpen", "#")
|
30
|
-
style.send((key.to_s + "=").to_sym, value)
|
31
|
-
end
|
32
|
-
return style
|
33
|
-
end
|
34
5
|
|
6
|
+
# This module is for reference only. The Style class is a java class for various reasons.
|
7
|
+
#
|
8
|
+
module Styles
|
9
|
+
# Specifies the Width of a prop.
|
10
|
+
#
|
11
|
+
# style.width = <value>
|
12
|
+
#
|
13
|
+
Width = Limelight::Styles::Style::STYLE_LIST.get(0)
|
14
|
+
|
15
|
+
# Specifies the Height of a prop.
|
16
|
+
#
|
17
|
+
# style.height = <value>
|
18
|
+
#
|
19
|
+
Height = Limelight::Styles::Style::STYLE_LIST.get(1)
|
20
|
+
|
21
|
+
# Specifies the Min Width of a prop.
|
22
|
+
#
|
23
|
+
# style.min_width = <value>
|
24
|
+
#
|
25
|
+
MinWidth = Limelight::Styles::Style::STYLE_LIST.get(2)
|
26
|
+
|
27
|
+
# Specifies the Min Height of a prop.
|
28
|
+
#
|
29
|
+
# style.min_height = <value>
|
30
|
+
#
|
31
|
+
MinHeight = Limelight::Styles::Style::STYLE_LIST.get(3)
|
32
|
+
|
33
|
+
# Specifies the Max Width of a prop.
|
34
|
+
#
|
35
|
+
# style.max_width = <value>
|
36
|
+
#
|
37
|
+
MaxWidth = Limelight::Styles::Style::STYLE_LIST.get(4)
|
38
|
+
|
39
|
+
# Specifies the Max Height of a prop.
|
40
|
+
#
|
41
|
+
# style.max_height = <value>
|
42
|
+
#
|
43
|
+
MaxHeight = Limelight::Styles::Style::STYLE_LIST.get(5)
|
44
|
+
|
45
|
+
# Specifies the Vertical Scrollbar of a prop.
|
46
|
+
#
|
47
|
+
# style.vertical_scrollbar = <value>
|
48
|
+
#
|
49
|
+
VerticalScrollbar = Limelight::Styles::Style::STYLE_LIST.get(6)
|
50
|
+
|
51
|
+
# Specifies the Horizontal Scrollbar of a prop.
|
52
|
+
#
|
53
|
+
# style.horizontal_scrollbar = <value>
|
54
|
+
#
|
55
|
+
HorizontalScrollbar = Limelight::Styles::Style::STYLE_LIST.get(7)
|
56
|
+
|
57
|
+
# Specifies the Top Border Color of a prop.
|
58
|
+
#
|
59
|
+
# style.top_border_color = <value>
|
60
|
+
#
|
61
|
+
TopBorderColor = Limelight::Styles::Style::STYLE_LIST.get(8)
|
62
|
+
|
63
|
+
# Specifies the Right Border Color of a prop.
|
64
|
+
#
|
65
|
+
# style.right_border_color = <value>
|
66
|
+
#
|
67
|
+
RightBorderColor = Limelight::Styles::Style::STYLE_LIST.get(9)
|
68
|
+
|
69
|
+
# Specifies the Bottom Border Color of a prop.
|
70
|
+
#
|
71
|
+
# style.bottom_border_color = <value>
|
72
|
+
#
|
73
|
+
BottomBorderColor = Limelight::Styles::Style::STYLE_LIST.get(10)
|
74
|
+
|
75
|
+
# Specifies the Left Border Color of a prop.
|
76
|
+
#
|
77
|
+
# style.left_border_color = <value>
|
78
|
+
#
|
79
|
+
LeftBorderColor = Limelight::Styles::Style::STYLE_LIST.get(11)
|
80
|
+
|
81
|
+
# Specifies the Top Border Width of a prop.
|
82
|
+
#
|
83
|
+
# style.top_border_width = <value>
|
84
|
+
#
|
85
|
+
TopBorderWidth = Limelight::Styles::Style::STYLE_LIST.get(12)
|
86
|
+
|
87
|
+
# Specifies the Right Border Width of a prop.
|
88
|
+
#
|
89
|
+
# style.right_border_width = <value>
|
90
|
+
#
|
91
|
+
RightBorderWidth = Limelight::Styles::Style::STYLE_LIST.get(13)
|
92
|
+
|
93
|
+
# Specifies the Bottom Border Width of a prop.
|
94
|
+
#
|
95
|
+
# style.bottom_border_width = <value>
|
96
|
+
#
|
97
|
+
BottomBorderWidth = Limelight::Styles::Style::STYLE_LIST.get(14)
|
98
|
+
|
99
|
+
# Specifies the Left Border Width of a prop.
|
100
|
+
#
|
101
|
+
# style.left_border_width = <value>
|
102
|
+
#
|
103
|
+
LeftBorderWidth = Limelight::Styles::Style::STYLE_LIST.get(15)
|
104
|
+
|
105
|
+
# Specifies the Top Margin of a prop.
|
106
|
+
#
|
107
|
+
# style.top_margin = <value>
|
108
|
+
#
|
109
|
+
TopMargin = Limelight::Styles::Style::STYLE_LIST.get(16)
|
110
|
+
|
111
|
+
# Specifies the Right Margin of a prop.
|
112
|
+
#
|
113
|
+
# style.right_margin = <value>
|
114
|
+
#
|
115
|
+
RightMargin = Limelight::Styles::Style::STYLE_LIST.get(17)
|
116
|
+
|
117
|
+
# Specifies the Bottom Margin of a prop.
|
118
|
+
#
|
119
|
+
# style.bottom_margin = <value>
|
120
|
+
#
|
121
|
+
BottomMargin = Limelight::Styles::Style::STYLE_LIST.get(18)
|
122
|
+
|
123
|
+
# Specifies the Left Margin of a prop.
|
124
|
+
#
|
125
|
+
# style.left_margin = <value>
|
126
|
+
#
|
127
|
+
LeftMargin = Limelight::Styles::Style::STYLE_LIST.get(19)
|
128
|
+
|
129
|
+
# Specifies the Top Padding of a prop.
|
130
|
+
#
|
131
|
+
# style.top_padding = <value>
|
132
|
+
#
|
133
|
+
TopPadding = Limelight::Styles::Style::STYLE_LIST.get(20)
|
134
|
+
|
135
|
+
# Specifies the Right Padding of a prop.
|
136
|
+
#
|
137
|
+
# style.right_padding = <value>
|
138
|
+
#
|
139
|
+
RightPadding = Limelight::Styles::Style::STYLE_LIST.get(21)
|
140
|
+
|
141
|
+
# Specifies the Bottom Padding of a prop.
|
142
|
+
#
|
143
|
+
# style.bottom_padding = <value>
|
144
|
+
#
|
145
|
+
BottomPadding = Limelight::Styles::Style::STYLE_LIST.get(22)
|
146
|
+
|
147
|
+
# Specifies the Left Padding of a prop.
|
148
|
+
#
|
149
|
+
# style.left_padding = <value>
|
150
|
+
#
|
151
|
+
LeftPadding = Limelight::Styles::Style::STYLE_LIST.get(23)
|
152
|
+
|
153
|
+
# Specifies the Background Color of a prop.
|
154
|
+
#
|
155
|
+
# style.background_color = <value>
|
156
|
+
#
|
157
|
+
BackgroundColor = Limelight::Styles::Style::STYLE_LIST.get(24)
|
158
|
+
|
159
|
+
# Specifies the Secondary Background Color of a prop.
|
160
|
+
#
|
161
|
+
# style.secondary_background_color = <value>
|
162
|
+
#
|
163
|
+
SecondaryBackgroundColor = Limelight::Styles::Style::STYLE_LIST.get(25)
|
164
|
+
|
165
|
+
# Specifies the Background Image of a prop.
|
166
|
+
#
|
167
|
+
# style.background_image = <value>
|
168
|
+
#
|
169
|
+
BackgroundImage = Limelight::Styles::Style::STYLE_LIST.get(26)
|
170
|
+
|
171
|
+
# Specifies the Background Image Fill Strategy of a prop.
|
172
|
+
#
|
173
|
+
# style.background_image_fill_strategy = <value>
|
174
|
+
#
|
175
|
+
BackgroundImageFillStrategy = Limelight::Styles::Style::STYLE_LIST.get(27)
|
176
|
+
|
177
|
+
# Specifies the Gradient of a prop.
|
178
|
+
#
|
179
|
+
# style.gradient = <value>
|
180
|
+
#
|
181
|
+
Gradient = Limelight::Styles::Style::STYLE_LIST.get(28)
|
182
|
+
|
183
|
+
# Specifies the Gradient Angle of a prop.
|
184
|
+
#
|
185
|
+
# style.gradient_angle = <value>
|
186
|
+
#
|
187
|
+
GradientAngle = Limelight::Styles::Style::STYLE_LIST.get(29)
|
188
|
+
|
189
|
+
# Specifies the Gradient Penetration of a prop.
|
190
|
+
#
|
191
|
+
# style.gradient_penetration = <value>
|
192
|
+
#
|
193
|
+
GradientPenetration = Limelight::Styles::Style::STYLE_LIST.get(30)
|
194
|
+
|
195
|
+
# Specifies the Cyclic Gradient of a prop.
|
196
|
+
#
|
197
|
+
# style.cyclic_gradient = <value>
|
198
|
+
#
|
199
|
+
CyclicGradient = Limelight::Styles::Style::STYLE_LIST.get(31)
|
200
|
+
|
201
|
+
# Specifies the Horizontal Alignment of a prop.
|
202
|
+
#
|
203
|
+
# style.horizontal_alignment = <value>
|
204
|
+
#
|
205
|
+
HorizontalAlignment = Limelight::Styles::Style::STYLE_LIST.get(32)
|
206
|
+
|
207
|
+
# Specifies the Vertical Alignment of a prop.
|
208
|
+
#
|
209
|
+
# style.vertical_alignment = <value>
|
210
|
+
#
|
211
|
+
VerticalAlignment = Limelight::Styles::Style::STYLE_LIST.get(33)
|
212
|
+
|
213
|
+
# Specifies the Text Color of a prop.
|
214
|
+
#
|
215
|
+
# style.text_color = <value>
|
216
|
+
#
|
217
|
+
TextColor = Limelight::Styles::Style::STYLE_LIST.get(34)
|
218
|
+
|
219
|
+
# Specifies the Font Face of a prop.
|
220
|
+
#
|
221
|
+
# style.font_face = <value>
|
222
|
+
#
|
223
|
+
FontFace = Limelight::Styles::Style::STYLE_LIST.get(35)
|
224
|
+
|
225
|
+
# Specifies the Font Size of a prop.
|
226
|
+
#
|
227
|
+
# style.font_size = <value>
|
228
|
+
#
|
229
|
+
FontSize = Limelight::Styles::Style::STYLE_LIST.get(36)
|
230
|
+
|
231
|
+
# Specifies the Font Style of a prop.
|
232
|
+
#
|
233
|
+
# style.font_style = <value>
|
234
|
+
#
|
235
|
+
FontStyle = Limelight::Styles::Style::STYLE_LIST.get(37)
|
236
|
+
|
237
|
+
# Specifies the Transparency of a prop.
|
238
|
+
#
|
239
|
+
# style.transparency = <value>
|
240
|
+
#
|
241
|
+
Transparency = Limelight::Styles::Style::STYLE_LIST.get(38)
|
242
|
+
|
243
|
+
# Specifies the Top Right Rounded Corner Radius of a prop.
|
244
|
+
#
|
245
|
+
# style.top_right_rounded_corner_radius = <value>
|
246
|
+
#
|
247
|
+
TopRightRoundedCornerRadius = Limelight::Styles::Style::STYLE_LIST.get(39)
|
248
|
+
|
249
|
+
# Specifies the Bottom Right Rounded Corner Radius of a prop.
|
250
|
+
#
|
251
|
+
# style.bottom_right_rounded_corner_radius = <value>
|
252
|
+
#
|
253
|
+
BottomRightRoundedCornerRadius = Limelight::Styles::Style::STYLE_LIST.get(40)
|
254
|
+
|
255
|
+
# Specifies the Bottom Left Rounded Corner Radius of a prop.
|
256
|
+
#
|
257
|
+
# style.bottom_left_rounded_corner_radius = <value>
|
258
|
+
#
|
259
|
+
BottomLeftRoundedCornerRadius = Limelight::Styles::Style::STYLE_LIST.get(41)
|
260
|
+
|
261
|
+
# Specifies the Top Left Rounded Corner Radius of a prop.
|
262
|
+
#
|
263
|
+
# style.top_left_rounded_corner_radius = <value>
|
264
|
+
#
|
265
|
+
TopLeftRoundedCornerRadius = Limelight::Styles::Style::STYLE_LIST.get(42)
|
266
|
+
|
267
|
+
# Specifies the Top Right Border Width of a prop.
|
268
|
+
#
|
269
|
+
# style.top_right_border_width = <value>
|
270
|
+
#
|
271
|
+
TopRightBorderWidth = Limelight::Styles::Style::STYLE_LIST.get(43)
|
272
|
+
|
273
|
+
# Specifies the Bottom Right Border Width of a prop.
|
274
|
+
#
|
275
|
+
# style.bottom_right_border_width = <value>
|
276
|
+
#
|
277
|
+
BottomRightBorderWidth = Limelight::Styles::Style::STYLE_LIST.get(44)
|
278
|
+
|
279
|
+
# Specifies the Bottom Left Border Width of a prop.
|
280
|
+
#
|
281
|
+
# style.bottom_left_border_width = <value>
|
282
|
+
#
|
283
|
+
BottomLeftBorderWidth = Limelight::Styles::Style::STYLE_LIST.get(45)
|
284
|
+
|
285
|
+
# Specifies the Top Left Border Width of a prop.
|
286
|
+
#
|
287
|
+
# style.top_left_border_width = <value>
|
288
|
+
#
|
289
|
+
TopLeftBorderWidth = Limelight::Styles::Style::STYLE_LIST.get(46)
|
290
|
+
|
291
|
+
# Specifies the Top Right Border Color of a prop.
|
292
|
+
#
|
293
|
+
# style.top_right_border_color = <value>
|
294
|
+
#
|
295
|
+
TopRightBorderColor = Limelight::Styles::Style::STYLE_LIST.get(47)
|
296
|
+
|
297
|
+
# Specifies the Bottom Right Border Color of a prop.
|
298
|
+
#
|
299
|
+
# style.bottom_right_border_color = <value>
|
300
|
+
#
|
301
|
+
BottomRightBorderColor = Limelight::Styles::Style::STYLE_LIST.get(48)
|
302
|
+
|
303
|
+
# Specifies the Bottom Left Border Color of a prop.
|
304
|
+
#
|
305
|
+
# style.bottom_left_border_color = <value>
|
306
|
+
#
|
307
|
+
BottomLeftBorderColor = Limelight::Styles::Style::STYLE_LIST.get(49)
|
308
|
+
|
309
|
+
# Specifies the Top Left Border Color of a prop.
|
310
|
+
#
|
311
|
+
# style.top_left_border_color = <value>
|
312
|
+
#
|
313
|
+
TopLeftBorderColor = Limelight::Styles::Style::STYLE_LIST.get(50)
|
314
|
+
|
315
|
+
# Specifies the Float of a prop.
|
316
|
+
#
|
317
|
+
# style.float = <value>
|
318
|
+
#
|
319
|
+
Float = Limelight::Styles::Style::STYLE_LIST.get(51)
|
320
|
+
|
321
|
+
# Specifies the X of a prop.
|
322
|
+
#
|
323
|
+
# style.x = <value>
|
324
|
+
#
|
325
|
+
X = Limelight::Styles::Style::STYLE_LIST.get(52)
|
326
|
+
|
327
|
+
# Specifies the Y of a prop.
|
328
|
+
#
|
329
|
+
# style.y = <value>
|
330
|
+
#
|
331
|
+
Y = Limelight::Styles::Style::STYLE_LIST.get(53)
|
35
332
|
end
|
36
|
-
|
333
|
+
|
37
334
|
end
|
@@ -1,60 +1,130 @@
|
|
1
1
|
#- Copyright 2008 8th Light, Inc. All Rights Reserved.
|
2
2
|
#- Limelight and all included source files are distributed under terms of the GNU LGPL.
|
3
|
+
require 'limelight/util'
|
3
4
|
|
4
5
|
module Limelight
|
5
|
-
|
6
|
+
|
7
|
+
# A trigger to define Style objects using the StyleBuilder DSL.
|
8
|
+
#
|
9
|
+
# See Limelight::Stylesbuilder, Limelight::Stylebuilder
|
10
|
+
#
|
6
11
|
def self.build_styles(style_hash = nil, &block)
|
7
12
|
builder = StylesBuilder.new(style_hash)
|
8
13
|
builder.instance_eval(&block) if block
|
9
|
-
return builder.
|
14
|
+
return builder.__styles__
|
10
15
|
end
|
11
|
-
|
16
|
+
|
17
|
+
# The basis of the DSL for building Style objects.
|
18
|
+
#
|
19
|
+
# Sample StyleBuilder DSL
|
20
|
+
#
|
21
|
+
# sandbox {
|
22
|
+
# width "100%"
|
23
|
+
# height "100%"
|
24
|
+
# vertical_alignment :top
|
25
|
+
# }
|
26
|
+
#
|
27
|
+
# sample {
|
28
|
+
# width 320
|
29
|
+
# height 320
|
30
|
+
# gradient :on
|
31
|
+
# }
|
32
|
+
#
|
33
|
+
# spinner {
|
34
|
+
# extends :sample
|
35
|
+
# background_color :green
|
36
|
+
# secondary_background_color :blue
|
37
|
+
# gradient_angle 0
|
38
|
+
# gradient_penetration 100
|
39
|
+
# }
|
40
|
+
#
|
41
|
+
# This exmple builds three styles: sandbox, sample, spinner. Within each style block, the individual attributes of
|
42
|
+
# the style may be set.
|
43
|
+
#
|
44
|
+
# See Limelight::Styles
|
45
|
+
#
|
12
46
|
class StylesBuilder
|
13
|
-
|
47
|
+
|
48
|
+
Limelight::Util.lobotomize(self)
|
49
|
+
|
50
|
+
attr_reader :__styles__
|
14
51
|
|
15
52
|
def initialize(style_hash = nil)
|
16
|
-
@
|
53
|
+
@__styles__ = style_hash || {}
|
17
54
|
end
|
18
55
|
|
19
|
-
def method_missing(sym, &block)
|
20
|
-
|
56
|
+
def method_missing(sym, &block) #:nodoc:
|
57
|
+
__add_style__(sym.to_s, &block)
|
21
58
|
end
|
22
59
|
|
23
|
-
def
|
60
|
+
def __add_style__(name, &block) #:nodoc:
|
24
61
|
builder = StyleBuilder.new(name, self)
|
25
62
|
builder.instance_eval(&block) if block
|
26
|
-
@
|
63
|
+
@__styles__[name] = builder.__style__
|
27
64
|
end
|
28
65
|
end
|
29
|
-
|
66
|
+
|
67
|
+
# The basis of the DSL for defining a Style object.
|
68
|
+
#
|
30
69
|
class StyleBuilder
|
31
|
-
|
70
|
+
|
71
|
+
Limelight::Util.lobotomize(self)
|
72
|
+
|
73
|
+
attr_reader :__style__ #:nodoc:
|
32
74
|
|
33
|
-
def initialize(name, styles_builder, options = {})
|
75
|
+
def initialize(name, styles_builder, options = {}) #:nodoc:
|
34
76
|
@__name = name
|
35
77
|
@__styles_builder = styles_builder
|
36
|
-
@
|
78
|
+
@__style__ = @__styles_builder.__styles__[name] || Styles::RichStyle.new
|
37
79
|
end
|
38
|
-
|
80
|
+
|
81
|
+
# Used to define a hover style. Hover styles are appiled when the mouse passed over a prop using the specified style.
|
82
|
+
#
|
83
|
+
# spinner {
|
84
|
+
# width 50
|
85
|
+
# height 50
|
86
|
+
# hover {
|
87
|
+
# text_color :white
|
88
|
+
# }
|
89
|
+
# }
|
90
|
+
#
|
91
|
+
# The text color of props using the 'spinner' style will become white when the mouse hovers over them.
|
92
|
+
#
|
39
93
|
def hover(&block)
|
40
|
-
@__styles_builder.
|
94
|
+
@__styles_builder.__add_style__("#{@__name}.hover", &block)
|
41
95
|
end
|
42
96
|
|
97
|
+
# Styles may extend other styles.
|
98
|
+
#
|
99
|
+
# base {
|
100
|
+
# background_color :red
|
101
|
+
# }
|
102
|
+
#
|
103
|
+
# cell {
|
104
|
+
# extends :base
|
105
|
+
# text_color :black
|
106
|
+
# }
|
107
|
+
#
|
108
|
+
# The 'cell' style now has all attributes defined in 'base'. Therefore any prop using the 'cell' style
|
109
|
+
# will have a red background. Styles may override attributes aquired through extension.
|
110
|
+
#
|
43
111
|
def extends(*style_names)
|
44
112
|
style_names.each do |style_name|
|
45
|
-
extension = @__styles_builder.
|
113
|
+
extension = @__styles_builder.__styles__[style_name.to_s]
|
46
114
|
raise StyleBuilderException.new("Can't extend missing style: '#{style_name}'") if extension.nil?
|
47
|
-
@
|
115
|
+
@__style__.add_extension(extension)
|
48
116
|
end
|
49
117
|
end
|
50
118
|
|
51
|
-
def method_missing(sym, value)
|
119
|
+
def method_missing(sym, value) #:nodoc:
|
52
120
|
setter_sym = "#{sym}=".to_s
|
53
|
-
raise StyleBuilderException.new("'#{sym}' is not a valid style") if !@
|
54
|
-
@
|
121
|
+
raise StyleBuilderException.new("'#{sym}' is not a valid style") if !@__style__.respond_to?(setter_sym)
|
122
|
+
@__style__.send(setter_sym, value.to_s)
|
55
123
|
end
|
56
124
|
end
|
57
|
-
|
125
|
+
|
126
|
+
# Exception thrown by StyleBuilder when an error is encountered.
|
127
|
+
#
|
58
128
|
class StyleBuilderException < Exception
|
59
129
|
end
|
60
130
|
|