class LUIT::Slider
Attributes
value[RW]
Public Class Methods
new(holder, id, x, y, range)
click to toggle source
Calls superclass method
LUIT::LUITElement::new
# File lib/luit.rb, line 229 def initialize(holder, id, x, y, range) super(holder, id, x, y, range + 10, 30) @range = range @value = 0 @buttonColor = LUIT.uiColor end
Public Instance Methods
draw(x = 0, y = 0)
click to toggle source
# File lib/luit.rb, line 236 def draw(x = 0, y = 0) Gosu::draw_rect(@x + x, @y + y + 10, @w, 10, @buttonColor, LUIT.z) Gosu::draw_rect(@x + x + @value, @y + y, 10, @h, @buttonColor, LUIT.z + 1) end
update(x = 0, y = 0)
click to toggle source
# File lib/luit.rb, line 245 def update(x = 0, y = 0) x += @x y += @y updateHover(x, y) if @hover && (Gosu::button_down?(Gosu::MsLeft) or LUIT.touchDown) @value = LUIT.mX - (x + 5) @value = 0 if @value < 0 @value = @range if @value > @range end @buttonColor = @hover ? LUIT.uiColorLight : LUIT.uiColor end
updateHover(x, y)
click to toggle source
# File lib/luit.rb, line 241 def updateHover(x, y) @hover = LUIT.mX.between?(x - 10, x + @w + 20) && LUIT.mY.between?(y - 10, y + @h + 20) end