motion-prime/elements/label.rb in motion-prime-0.3.1 vs motion-prime/elements/label.rb in motion-prime-0.3.2

- old
+ new

@@ -1,32 +1,32 @@ module MotionPrime class LabelElement < BaseElement + include MotionPrime::ElementContentPaddingMixin include MotionPrime::ElementTextDimensionsMixin before_render :size_to_fit_if_needed after_render :size_to_fit + def view_class + "MPLabel" + end + def size_to_fit if computed_options[:size_to_fit] || style_options[:size_to_fit] if computed_options[:width] - view.setHeight content_height + 2 # TODO maybe set width too as it can be wider + view.setHeight([content_outer_height, computed_options[:height]].compact.min) else view.sizeToFit + # we should re-set values, because sizeToFit do not use padding + view.setWidth(view.bounds.size.width + content_padding_width) + view.setHeight(view.bounds.size.height + content_padding_height) end end end def size_to_fit_if_needed if computed_options[:size_to_fit] && computed_options[:width] - @computed_options[:height_to_fit] = content_height + @computed_options[:height_to_fit] = content_outer_height end - end - - def computed_inner_top - computed_options[:top].to_i - end - - def computed_inner_bottom - computed_options[:bottom].to_i end end end \ No newline at end of file