Class: LUIT::Toggle
- Inherits:
-
LUITElement
- Object
- LUITElement
- LUIT::Toggle
- Defined in:
- lib/luit.rb
Instance Attribute Summary collapse
-
#value ⇒ Object
Returns the value of attribute value.
Attributes inherited from LUITElement
Instance Method Summary collapse
- #button_down(id) ⇒ Object
- #draw(x = 0, y = 0) ⇒ Object
-
#initialize(holder, id, x, y, size = 30) ⇒ Toggle
constructor
A new instance of Toggle.
- #update(x = 0, y = 0) ⇒ Object
Methods inherited from LUITElement
#draw_rel, #updateHover, #update_rel
Constructor Details
Instance Attribute Details
#value ⇒ Object
Returns the value of attribute value.
303 304 305 |
# File 'lib/luit.rb', line 303 def value @value end |
Instance Method Details
#button_down(id) ⇒ Object
328 329 330 331 332 333 |
# File 'lib/luit.rb', line 328 def (id) if id == Gosu::MsLeft && @hover @value = !@value @holder.onClick(@id) end end |
#draw(x = 0, y = 0) ⇒ Object
312 313 314 315 316 317 318 |
# File 'lib/luit.rb', line 312 def draw(x = 0, y = 0) x += @x y += @y Gosu::draw_rect(x, y, @w, @h, @buttonColor, LUIT.z) @value ? v = 1 : v = 0 Gosu::draw_rect(x + 4 + (@h * v), y + 4, @h - 8, @h - 8, @value ? 0xff_ffffff : 0xff_000000, LUIT.z + 1) end |
#update(x = 0, y = 0) ⇒ Object
320 321 322 323 324 325 326 |
# File 'lib/luit.rb', line 320 def update(x = 0, y = 0) x += @x y += @y updateHover(x, y) @buttonColor = @hover ? LUIT.uiColorLight : LUIT.uiColor super end |