[](name)
click to toggle source
def [](name)
@user_property[name]
end
[]=(name, value)
click to toggle source
def []=(name, value)
@user_property[name] = value
end
__prop_set__(name, *values)
add_default_prop(name, value)
click to toggle source
def add_default_prop(name, value)
name = normalize_property_name(name)
@default_prop[name] = make_prop_value(name, value)
end
adjust_x_centering(x, w)
click to toggle source
def adjust_x_centering(x, w)
x -= centering_adjusted_width
w += centering_adjusted_width
[x, w]
end
adjust_y_margin(y, h)
click to toggle source
def adjust_y_margin(y, h)
y += @margin_bottom
h -= @margin_bottom
[y, h]
end
adjust_y_padding(y, h)
click to toggle source
def adjust_y_padding(y, h)
y -= @padding_top
h += @padding_top + @padding_bottom
[y, h]
end
available_w()
click to toggle source
def available_w
@w - @padding_left - @padding_right
end
centering_adjusted_height()
click to toggle source
def centering_adjusted_height
@centering_adjusted_height || 0
end
centering_adjusted_width()
click to toggle source
def centering_adjusted_width
@centering_adjusted_width || 0
end
clear_margin()
click to toggle source
def clear_margin
@margin_left = @default_margin_left
@margin_right = @default_margin_right
@margin_top = @default_margin_top
@margin_bottom = @default_margin_bottom
end
clear_padding()
click to toggle source
def clear_padding
@padding_left = @default_padding_left
@padding_right = @default_padding_right
@padding_top = @default_padding_top
@padding_bottom = @default_padding_bottom
end
clear_theme()
click to toggle source
def clear_theme
@slide = nil
@visible = @default_visible
@real_simulation = true
@width = @height = nil
@centering_adjusted_width = nil
@centering_adjusted_height = nil
@horizontal_centering = @vertical_centering = false
@prop = default_prop
clear_margin
clear_padding
clear_draw_procs
dirty!
end
clone()
click to toggle source
Calls superclass method
def clone
obj = super
obj.user_property = @user_property.clone
obj.prop = @prop.clone
obj
end
compile(canvas, x, y, w, h)
click to toggle source
def compile(canvas, x, y, w, h)
compile_element(canvas, x, y, w, h)
end
compile_element(canvas, x, y, w, h)
click to toggle source
def compile_element(canvas, x, y, w, h)
@base_x, @base_y, @base_w, @base_h = x, y, w, h
@px, @py, @pw, @ph = @x, @y, @w, @h
x, y, w, h = setup_margin(x, y, w, h)
@canvas, @x, @y, @w, @h = canvas, x, y, w, h
if [@px, @py, @pw, @ph] != [@x, @y, @w, @h]
dirty!
end
end
compile_for_horizontal_centering(canvas, x, y, w, h)
click to toggle source
def compile_for_horizontal_centering(canvas, x, y, w, h)
compile(canvas, x, y, w, h)
end
compile_horizontal(canvas, x, y, w, h)
click to toggle source
def compile_horizontal(canvas, x, y, w, h)
if do_horizontal_centering?
do_horizontal_centering(canvas, x, y, w, h)
else
reset_horizontal_centering(canvas, x, y, w, h)
end
end
default_prop()
click to toggle source
def default_prop
@default_prop.dup
end
dirty!()
click to toggle source
def dirty!
@dirty = true
end
dirty?()
click to toggle source
do_horizontal_centering(canvas, x, y, w, h)
click to toggle source
def do_horizontal_centering(canvas, x, y, w, h)
end
do_horizontal_centering?()
click to toggle source
def do_horizontal_centering?
@horizontal_centering or
(parent and parent.do_horizontal_centering?)
end
do_vertical_centering?()
click to toggle source
def do_vertical_centering?
@vertical_centering or
(parent and parent.do_horizontal_centering?)
end
draw(simulation=false)
click to toggle source
def draw(simulation=false)
x, y, w, h = setup_padding(@x, @y, @w, @h)
x, y, w, h = _draw(@canvas, x, y, w, h, simulation)
x, w = restore_x_padding(x, w)
x, w = restore_x_margin(x, w)
x, w = adjust_x_centering(x, w)
y, h = adjust_y_padding(y, h)
y, h = adjust_y_margin(y, h)
[x, y, w, h]
end
font(props)
click to toggle source
def font(props)
props.each do |key, value|
key, value = normalize_font_property(key, value)
if value
prop_set(key, value)
else
prop_delete(key)
end
end
end
have_tag?(name)
click to toggle source
def have_tag?(name)
false
end
have_wait_tag?()
click to toggle source
def have_wait_tag?
false
end
height()
click to toggle source
def height
@height + @padding_top + @padding_bottom
end
hide(&block)
click to toggle source
def hide(&block)
change_visible(false, &block)
end
horizontal_centering=(new_value)
click to toggle source
def horizontal_centering=(new_value)
if @horizontal_centering != new_value
dirty!
end
@horizontal_centering = new_value
end
if_dirty() { || ... }
click to toggle source
def if_dirty
if dirty?
yield
@dirty = false
end
end
init_default_margin()
click to toggle source
def init_default_margin
@default_margin_left = 0
@default_margin_right = 0
@default_margin_top = 0
@default_margin_bottom = 0
end
init_default_padding()
click to toggle source
def init_default_padding
@default_padding_left = 0
@default_padding_right = 0
@default_padding_top = 0
@default_padding_bottom = 0
end
init_default_visible()
click to toggle source
def init_default_visible
@default_visible = !have_wait_tag?
end
inline_element?()
click to toggle source
def inline_element?
true
end
inspect(verbose=false)
click to toggle source
Calls superclass method
def inspect(verbose=false)
if verbose
super()
else
"<#{self.class.name}>"
end
end
margin_set(*values)
click to toggle source
def margin_set(*values)
top, right, bottom, left = parse_four_way(*values)
@margin_top = top if top
@margin_right = right if right
@margin_bottom = bottom if bottom
@margin_left = left if left
end
margin_with(params)
click to toggle source
def margin_with(params)
margin_set(params)
end
match?(pattern)
click to toggle source
def match?(pattern)
pattern === text
end
next_element()
click to toggle source
def next_element
sibling_element(1)
end
padding_set(*values)
click to toggle source
def padding_set(*values)
top, right, bottom, left = parse_four_way(*values)
@padding_top = top if top
@padding_right = right if right
@padding_bottom = bottom if bottom
@padding_left = left if left
end
padding_with(params)
click to toggle source
def padding_with(params)
padding_set(params)
end
parent=(parent)
click to toggle source
def parent=(parent)
@slide = nil
@parent = parent
end
previous_element()
click to toggle source
def previous_element
sibling_element(-1)
end
prop_delete(name)
click to toggle source
def prop_delete(name)
name = normalize_property_name(name)
@prop.delete(name)
dirty!
end
prop_get(name)
click to toggle source
def prop_get(name)
name = normalize_property_name(name)
@prop[name]
end
prop_set(name, *values)
click to toggle source
def prop_set(name, *values)
name = normalize_property_name(name)
@prop[name] = make_prop_value(name, *values)
dirty!
end
prop_value(name)
click to toggle source
def prop_value(name)
name = normalize_property_name(name)
value = @prop[name]
value = value.value if value.respond_to?(:value)
value
end
reset_horizontal_centering(canvas, x, y, w, h)
click to toggle source
def reset_horizontal_centering(canvas, x, y, w, h)
end
restore_x_margin(x, w)
click to toggle source
def restore_x_margin(x, w)
x -= @margin_left
w += @margin_left + @margin_right
[x, w]
end
restore_x_padding(x, w)
click to toggle source
def restore_x_padding(x, w)
x -= @padding_left
w += @padding_left + @padding_right
[x, w]
end
setup_margin(x, y, w, h)
click to toggle source
def setup_margin(x, y, w, h)
x += @margin_left
y += @margin_top
w -= @margin_left + @margin_right
h -= @margin_top + @margin_bottom
[x, y, w, h]
end
setup_padding(x, y, w, h)
click to toggle source
def setup_padding(x, y, w, h)
x += @padding_left
y += @padding_top
w -= @padding_left + @padding_right
h -= @padding_top + @padding_bottom
[x, y, w, h]
end
show(&block)
click to toggle source
def show(&block)
change_visible(true, &block)
end
slide()
click to toggle source
def slide
@slide ||= _slide
end
substitute_newline()
click to toggle source
def substitute_newline
substitute_text do |text|
text.gsub(/(\)?\n/) {$1 ? "\\n" : "\n"}
end
end
substitute_text()
click to toggle source
def substitute_text
false
end
text_renderer?()
click to toggle source
def text_renderer?
false
end
vertical_centering=(new_value)
click to toggle source
def vertical_centering=(new_value)
dirty! if @vertical_centering != new_value
@vertical_centering = new_value
end
visible?()
click to toggle source
def visible?
@visible
end
wait(*args, &block)
click to toggle source
def wait(*args, &block)
slide.register_wait_proc(self, *args, &block) if slide
end
width()
click to toggle source
def width
@width + @padding_left + @padding_right
end