Class: LUIT::VerticalSlider

Inherits:
LUITElement show all
Defined in:
lib/luit.rb

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) ⇒ VerticalSlider

Returns a new instance of VerticalSlider.



270
271
272
273
274
275
# File 'lib/luit.rb', line 270

def initialize(holder, id, x, y, range)
	super(holder, id, x, y, 30, range + 10)
	@range = range
	@value = 0
	@buttonColor = LUIT.uiColor
end

Instance Attribute Details

#valueObject

Returns the value of attribute value.



269
270
271
# File 'lib/luit.rb', line 269

def value
  @value
end

Instance Method Details

#button_down(id) ⇒ Object



298
299
# File 'lib/luit.rb', line 298

def button_down(id)
end

#draw(x = 0, y = 0) ⇒ Object



277
278
279
280
# File 'lib/luit.rb', line 277

def draw(x = 0, y = 0)
	Gosu::draw_rect(@x + x + 10, @y + y, 10, @h, @buttonColor, LUIT.z)
	Gosu::draw_rect(@x + x, @y + y  + @value, @w, 10, @buttonColor, LUIT.z + 1)
end

#update(x = 0, y = 0) ⇒ Object



286
287
288
289
290
291
292
293
294
295
296
# File 'lib/luit.rb', line 286

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.mY - (y + 5)
		@value = 0 if @value < 0
		@value = @range if @value > @range
	end
	@buttonColor = @hover ? LUIT.uiColorLight : LUIT.uiColor
end

#updateHover(x, y) ⇒ Object



282
283
284
# File 'lib/luit.rb', line 282

def updateHover(x, y)
	@hover = LUIT.mX.between?(x - 10, x + @w + 20) && LUIT.mY.between?(y - 10, y + @h + 20)
end