Module: Shoes::DSL::Element
- Included in:
- Shoes::DSL
- Defined in:
- shoes-core/lib/shoes/dsl/element.rb
Overview
DSL methods for adding UI elements in Shoes applications.
Instance Method Summary collapse
-
#background(color, styles = {}) ⇒ Shoes::Background
Creates a background for the current slot.
-
#border(color, styles = {}) ⇒ Shoes::Border
Creates a border for the current slot.
-
#button(text = nil, opts = {}, &blk) ⇒ Shoes::Button
Creates a clickable button.
-
#check(opts = {}, &blk) ⇒ Shoes::Check
Creates a checkbox UI element.
-
#edit_box(text = "", styles = {}) ⇒ Shoes::EditBox
Creates a multi-line UI element for entering text.
-
#edit_line(text = "", styles = {}) ⇒ Shoes::EditLine
Creates a single line UI element for entering text.
-
#flow(opts = {}, &blk) ⇒ Shoes::Flow
Creates a flow container.
-
#list_box(opts = {}, &blk) ⇒ Shoes::ListBox
Creates a list box UI element.
-
#progress(opts = {}, &blk) ⇒ Shoes::Progress
Creates a progress bar UI element.
-
#radio(group = "", opts = {}) ⇒ Shoes::Radio
Creates a radio button UI element.
-
#stack(opts = {}, &blk) ⇒ Shoes::Flow
Creates a stacked container.
Instance Method Details
#background(color, styles = {}) ⇒ Shoes::Background
Creates a background for the current slot.
23 24 25 |
# File 'shoes-core/lib/shoes/dsl/element.rb', line 23 def background(color, styles = {}) create Shoes::Background, pattern(color), style_normalizer.normalize(styles) end |
#border(color, styles = {}) ⇒ Shoes::Border
Creates a border for the current slot.
14 15 16 |
# File 'shoes-core/lib/shoes/dsl/element.rb', line 14 def border(color, styles = {}) create Shoes::Border, pattern(color), styles end |
#button(text = nil, opts = {}, &blk) ⇒ Shoes::Button
Creates a clickable button.
125 126 127 |
# File 'shoes-core/lib/shoes/dsl/element.rb', line 125 def (text = nil, opts = {}, &blk) create Shoes::Button, text, opts, blk end |
#check(opts = {}, &blk) ⇒ Shoes::Check
Creates a checkbox UI element.
66 67 68 |
# File 'shoes-core/lib/shoes/dsl/element.rb', line 66 def check(opts = {}, &blk) create Shoes::Check, opts, blk end |
#edit_box(text = "", styles = {}) ⇒ Shoes::EditBox
Creates a multi-line UI element for entering text.
46 47 48 49 50 |
# File 'shoes-core/lib/shoes/dsl/element.rb', line 46 def edit_box(*args, &blk) style = pop_style(args) text = args.first || '' create Shoes::EditBox, text, style, blk end |
#edit_line(text = "", styles = {}) ⇒ Shoes::EditLine
Creates a single line UI element for entering text.
34 35 36 37 38 |
# File 'shoes-core/lib/shoes/dsl/element.rb', line 34 def edit_line(*args, &blk) style = pop_style(args) text = args.first || '' create Shoes::EditLine, text, style, blk end |
#flow(opts = {}, &blk) ⇒ Shoes::Flow
Creates a flow container. Flows contain other UI elements, and will line them up until all available width is consumed before wrapping to another line for additional elements.
102 103 104 |
# File 'shoes-core/lib/shoes/dsl/element.rb', line 102 def flow(opts = {}, &blk) create Shoes::Flow, opts, blk end |
#list_box(opts = {}, &blk) ⇒ Shoes::ListBox
Creates a list box UI element.
90 91 92 |
# File 'shoes-core/lib/shoes/dsl/element.rb', line 90 def list_box(opts = {}, &blk) create Shoes::ListBox, opts, blk end |
#progress(opts = {}, &blk) ⇒ Shoes::Progress
Creates a progress bar UI element.
57 58 59 |
# File 'shoes-core/lib/shoes/dsl/element.rb', line 57 def progress(opts = {}, &blk) create Shoes::Progress, opts, blk end |
#radio(group = "", opts = {}) ⇒ Shoes::Radio
Creates a radio button UI element.
78 79 80 81 82 |
# File 'shoes-core/lib/shoes/dsl/element.rb', line 78 def radio(*args, &blk) style = pop_style(args) group = args.first create Shoes::Radio, group, style, blk end |
#stack(opts = {}, &blk) ⇒ Shoes::Flow
Creates a stacked container. Stacks contain other UI elements and after each item wraps to a new line.
113 114 115 |
# File 'shoes-core/lib/shoes/dsl/element.rb', line 113 def stack(opts = {}, &blk) create Shoes::Stack, opts, blk end |