Module: UI

Defined in:
flow/ui/ui.rb,
flow/ui/font.rb,
flow/ui/view.rb,
flow/ui/alert.rb,
flow/ui/color.rb,
flow/ui/label.rb,
flow/ui/image.rb,
flow/ui/button.rb,
flow/ui/screen.rb,
flow/ui/list_row.rb,
flow/ui/eventable.rb,
flow/ui/navigation.rb,
flow/ui/text_input.rb,
flow/ui/application.rb,
flow/ui/activity_indicator.rb

Defined Under Namespace

Modules: Eventable Classes: ActivityIndicator, Application, Button, Color, Font, Image, Label, ListRow, Navigation, Screen, TextInput, View

Constant Summary

TEXT_ALIGNMENT =

Hash keys: :left, :center, :right, :justify

{}

Class Method Summary (collapse)

Class Method Details

+ (Object) alert(opt = {}, &block)

Parameters:

  • options (Hash)


8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'flow/ui/alert.rb', line 8

def self.alert(opt={}, &block)
  alert = UI::Alert.new
  alert.title = (opt[:title] or raise ":title needed")
  alert.message = (opt[:message] or raise ":message needed")

  buttons = [:cancel, :default]
  has_button = false
  buttons.each do |button|
    if title = opt[button]
      alert.set_button(title, button)
      has_button = true
    end
  end
  alert.set_button('Cancel', :cancel) unless has_button

  alert.show(&block)
  @last_alert = alert # Keep a strong reference to the alert object has it has to remain alive.
end

+ (Color) Color(color)

Returns:



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'flow/ui/color.rb', line 3

def self.Color(color)
  if UI::Color._native?(color)
    UI::Color.new(color)
  else
    case color
      when UI::Color
        self
      when String
        UI::Color.hex(color)
      when Symbol
        UI::Color.symbol(color)
      when Array
        case color.size
          when 3
            color = color + [255]
          when 4
          else
            raise "Expected Array of 3 or 4 elements"
        end
        UI::Color.rgba(*color)
      else
        raise "Expected UI::Color, String, Symbol or Array of Fixnum objects"
    end
  end
end

+ (Font) Font(font)

Parameters:

  • font (Hash)

Options Hash (font):

  • name (String)
  • size (Fixnum)
  • trait (Symbol)

    :normal, :bold, :italic, :bold_italic

Returns:



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'flow/ui/font.rb', line 7

def self.Font(font)
  case font
    when UI::Font
      self
    when Hash
      name = (font[:name] or raise ":name expected")
      size = (font[:size] or raise ":size expected")
      trait = (font[:trait] or :normal)
      UI::Font.new(name, size, trait)
    when Array
      raise "Expected Array of 2 or 3 elements" if font.size < 2 or font.size > 3
      UI::Font.new(*font)
    else
      raise "Expected UI::Font or Hash or Array"
  end
end