Class: Clogs::Check
- Defined in:
- lib/clogs/drawables/controls.rb
Constant Summary collapse
- BOX =
16
Constants inherited from Control
Clogs::Control::PADDING_X, Clogs::Control::PADDING_Y
Instance Attribute Summary
Attributes inherited from Control
Attributes inherited from Drawable
#abs_x, #abs_y, #children, #height, #parent, #shoes_linkable_id, #styles, #width, #x, #y
Instance Method Summary collapse
- #draw(painter, x, y) ⇒ Object
- #measure(_available_width) ⇒ Object
- #on_release(x, y, _button) ⇒ Object
Methods inherited from Control
#clickable?, #label, #on_mouse_enter, #on_mouse_leave, #text_style
Methods inherited from Drawable
#add_child, #app, #clickable?, #contains?, #destroy_self, #each_peer, #focus_gained, #focus_lost, #focusable?, for_shoes_class, #hidden?, #initialize, #margin, #needs_layout!, #notify, #on_click, #on_key, #on_mouse_move, #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 Method Details
#draw(painter, x, y) ⇒ Object
102 103 104 105 106 107 108 109 110 111 |
# File 'lib/clogs/drawables/controls.rb', line 102 def draw(painter, x, y) painter.draw(fill: [255, 255, 255, 255], stroke: [120, 120, 120, 255], thickness: 1) do |p| Clogs.rounded_rect(p, x + 0.5, y + 0.5, BOX - 1, BOX - 1, 3) end return unless style(:checked) painter.draw(stroke: [30, 30, 30, 255], thickness: 2, cap: UI::CAP_ROUND) do |p| p.move_to(x + 4, y + 8).line_to(x + 7, y + 11).line_to(x + 12, y + 5) end end |
#measure(_available_width) ⇒ Object
97 98 99 100 |
# File 'lib/clogs/drawables/controls.rb', line 97 def measure(_available_width) @width = BOX @height = BOX end |
#on_release(x, y, _button) ⇒ Object
113 114 115 116 117 118 119 |
# File 'lib/clogs/drawables/controls.rb', line 113 def on_release(x, y, ) return unless contains?(x, y) @styles["checked"] = !style(:checked) notify("click") redraw! end |