Sha256: 48ae854c68349f68a554b93b4ad2198d670bc494146d0633fbd5eecd92cac044

Contents?: true

Size: 1020 Bytes

Versions: 1

Compression:

Stored size: 1020 Bytes

Contents

class UnderOs::UI::Icon < UnderOs::UI::View
  include UnderOs::UI::IconEngine
  engine UnderOs::UI::IconEngineAwesome

  wraps  UIButton, tag: 'icon'

  def initialize(options)
    options = {type: options} if ! options.is_a?(Hash)

    super(options)

    self.type = options.delete(:type) || :bug
    self.size = options.delete(:size) || 20
    self.disable if options[:disabled]

    @_.sizeToFit
    @_.showsTouchWhenHighlighted = true
  end

  def type
    @type
  end

  def type=(type)
    @type = type
    @_.setTitle self.class.engine.text(type), forState:UIControlStateNormal
  end

  def size(size=nil)
    if size
      self.size = size
      self
    else
      @size
    end
  end

  def size=(size)
    @size = size
    @_.setFont self.class.engine.font(size)
    @_.sizeToFit
  end

  def disabled
    ! @_.isEnabled
  end

  alias :disabled? :disabled

  def disabled=(value)
    @_.enabled = ! value
  end

  def disable
    self.disabled = true
  end

  def enable
    self.disabled = false
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
under-os-ui-1.4.0 lib/under_os/ui/icon.rb