Sha256: cc9f8f065298e8643bef8d4dc1c2f10548215354ddcefeefc18603c07a171604

Contents?: true

Size: 998 Bytes

Versions: 3

Compression:

Stored size: 998 Bytes

Contents

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

  wraps  UIButton, tag: 'icon'
  engine :Awesome

  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

3 entries across 3 versions & 1 rubygems

Version Path
under-os-1.3.0 lib/under_os/ui/icon.rb
under-os-1.2.1 lib/under_os/ui/icon.rb
under-os-1.2.0 lib/under_os/ui/icon.rb