Sha256: e049d0a8093ef5257f13abbd998b0cda4aa933fd5d471b686a9a1a54563902a9

Contents?: true

Size: 741 Bytes

Versions: 2

Compression:

Stored size: 741 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

    @_.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
end

Version data entries

2 entries across 2 versions & 1 rubygems

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