lib/rabbit/element/base.rb in rabbit-0.9.3 vs lib/rabbit/element/base.rb in rabbit-1.0.0
- old
+ new
@@ -105,27 +105,38 @@
do_horizontal_centering(canvas, x, y, w, h)
end
end
def prop_set(name, *values)
+ name = normalize_property_name(name)
@prop[name] = make_prop_value(name, *values)
dirty!
end
alias __prop_set__ prop_set
def prop_get(name)
+ name = normalize_property_name(name)
@prop[name]
end
alias __prop_get__ prop_get
+ def prop_value(name)
+ name = normalize_property_name(name)
+ value = @prop[name]
+ value = value.value if value.respond_to?(:value)
+ value
+ end
+
def prop_delete(name)
+ name = normalize_property_name(name)
@prop.delete(name)
dirty!
end
alias __prop_delete__ prop_delete
def add_default_prop(name, value)
+ name = normalize_property_name(name)
@default_prop[name] = make_prop_value(name, value)
end
def font(props)
props.each do |key, value|
@@ -350,11 +361,11 @@
@padding_bottom = bottom if bottom
@padding_left = left if left
end
def padding_with(params)
- padding_set(*extract_four_way(params))
+ padding_set(params)
end
def show(&block)
change_visible(true, &block)
end
@@ -422,9 +433,14 @@
nil
end
else
nil
end
+ end
+
+ def normalize_property_name(name)
+ name = name.to_s if name.is_a?(Symbol)
+ name.gsub(/_/, "-")
end
def normalize_font_property(key, value)
key = key.to_s
case key