Class: LUIT::Slider
Instance Attribute Summary collapse
Attributes inherited from LUITElement
#h, #hover, #id, #w, #x, #y
Instance Method Summary
collapse
Methods inherited from LUITElement
#draw_rel, #update_rel
Constructor Details
#initialize(holder, id, x, y, range) ⇒ Slider
Returns a new instance of Slider.
236
237
238
239
240
241
|
# File 'lib/luit.rb', line 236
def initialize(holder, id, x, y, range)
super(holder, id, x, y, range + 10, 30)
@range = range
@value = 0
@buttonColor = LUIT.uiColor
end
|
Instance Attribute Details
#value ⇒ Object
Returns the value of attribute value.
235
236
237
|
# File 'lib/luit.rb', line 235
def value
@value
end
|
Instance Method Details
264
265
|
# File 'lib/luit.rb', line 264
def button_down(id)
end
|
#draw(x = 0, y = 0) ⇒ Object
243
244
245
246
|
# File 'lib/luit.rb', line 243
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) ⇒ Object
252
253
254
255
256
257
258
259
260
261
262
|
# File 'lib/luit.rb', line 252
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) ⇒ Object
248
249
250
|
# File 'lib/luit.rb', line 248
def updateHover(x, y)
@hover = LUIT.mX.between?(x - 10, x + @w + 20) && LUIT.mY.between?(y - 10, y + @h + 20)
end
|