Class: Clogs::Control
- Defined in:
- lib/clogs/drawables/controls.rb
Overview
Shoes' widgets, drawn by hand.
libui does have real native buttons and entries, but it can only stack them in boxes and grids -- there is no container that puts a control at an arbitrary (x, y). Shoes' whole layout model needs exactly that, so Clogs paints its widgets into the same area as everything else. The trade-off is noted in docs/libui_shoes_coverage.md: these look like Shoes widgets, not like the host platform's.
Constant Summary collapse
- PADDING_X =
10- PADDING_Y =
6
Instance Attribute Summary collapse
-
#focused ⇒ Object
Returns the value of attribute focused.
-
#hovered ⇒ Object
Returns the value of attribute hovered.
-
#pressed ⇒ Object
Returns the value of attribute pressed.
Attributes inherited from Drawable
#abs_x, #abs_y, #children, #height, #parent, #shoes_linkable_id, #styles, #width, #x, #y
Instance Method Summary collapse
- #clickable? ⇒ Boolean
- #label ⇒ Object
- #on_mouse_enter ⇒ Object
- #on_mouse_leave ⇒ Object
- #text_style(size: nil, color: [0, 0, 0, 255]) ⇒ Object
Methods inherited from Drawable
#add_child, #app, #contains?, #destroy_self, #draw, #each_peer, #focus_gained, #focus_lost, #focusable?, for_shoes_class, #hidden?, #initialize, #margin, #measure, #needs_layout!, #notify, #on_click, #on_key, #on_mouse_move, #on_release, #paint, #positioned?, #properties_changed, #redraw!, #remove_child, #requested_height, #requested_width, #set_parent, #style
Constructor Details
This class inherits a constructor from Clogs::Drawable
Instance Attribute Details
#focused ⇒ Object
Returns the value of attribute focused.
19 20 21 |
# File 'lib/clogs/drawables/controls.rb', line 19 def focused @focused end |
#hovered ⇒ Object
Returns the value of attribute hovered.
19 20 21 |
# File 'lib/clogs/drawables/controls.rb', line 19 def hovered @hovered end |
#pressed ⇒ Object
Returns the value of attribute pressed.
19 20 21 |
# File 'lib/clogs/drawables/controls.rb', line 19 def pressed @pressed end |
Instance Method Details
#clickable? ⇒ Boolean
21 22 23 |
# File 'lib/clogs/drawables/controls.rb', line 21 def clickable? true end |
#label ⇒ Object
34 35 36 |
# File 'lib/clogs/drawables/controls.rb', line 34 def label style(:text).to_s end |
#on_mouse_enter ⇒ Object
38 39 40 41 |
# File 'lib/clogs/drawables/controls.rb', line 38 def on_mouse_enter self.hovered = true redraw! end |
#on_mouse_leave ⇒ Object
43 44 45 46 47 |
# File 'lib/clogs/drawables/controls.rb', line 43 def on_mouse_leave self.hovered = false self.pressed = false redraw! end |
#text_style(size: nil, color: [0, 0, 0, 255]) ⇒ Object
25 26 27 28 29 30 31 32 |
# File 'lib/clogs/drawables/controls.rb', line 25 def text_style(size: nil, color: [0, 0, 0, 255]) Paragraph::TextStyle.new( family: style(:family) || Clogs.default_font_family, size: size || (style(:size) || style(:font_size) || Clogs.default_font_size).to_i, bold: false, italic: false, underline: false, color: color, bg: nil, owner: self ) end |