Class: Clogs::Control

Inherits:
Drawable
  • Object
show all
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.

Direct Known Subclasses

Button, Check, EditBox, EditLine, ListBox, Progress, Radio

Constant Summary collapse

PADDING_X =
10
PADDING_Y =
6

Instance Attribute Summary collapse

Attributes inherited from Drawable

#abs_x, #abs_y, #children, #height, #parent, #shoes_linkable_id, #styles, #width, #x, #y

Instance Method Summary collapse

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

#focusedObject

Returns the value of attribute focused.



19
20
21
# File 'lib/clogs/drawables/controls.rb', line 19

def focused
  @focused
end

#hoveredObject

Returns the value of attribute hovered.



19
20
21
# File 'lib/clogs/drawables/controls.rb', line 19

def hovered
  @hovered
end

#pressedObject

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

Returns:

  • (Boolean)


21
22
23
# File 'lib/clogs/drawables/controls.rb', line 21

def clickable?
  true
end

#labelObject



34
35
36
# File 'lib/clogs/drawables/controls.rb', line 34

def label
  style(:text).to_s
end

#on_mouse_enterObject



38
39
40
41
# File 'lib/clogs/drawables/controls.rb', line 38

def on_mouse_enter
  self.hovered = true
  redraw!
end

#on_mouse_leaveObject



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