Sha256: 7eb16576c7fd6816c245d9ed240b98f4b4df5cf904b17682f6553dc0d9c499d5

Contents?: true

Size: 795 Bytes

Versions: 2

Compression:

Stored size: 795 Bytes

Contents

module MotionPrime
  class LabelElement < BaseElement
    include MotionPrime::ElementTextDimensionsMixin

    before_render :size_to_fit_if_needed
    after_render :size_to_fit

    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
        else
          view.sizeToFit
        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
      end
    end

    def computed_inner_top
      computed_options[:top].to_i
    end

    def computed_inner_bottom
      computed_options[:bottom].to_i
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
motion-prime-0.3.1 motion-prime/elements/label.rb
motion-prime-0.3.0 motion-prime/elements/label.rb