class LUIT::Button
Public Class Methods
new(holder, id, x, y, text, w = 0, h = 0)
click to toggle source
w and h will auto adjust to the text size + 10px padding if its not set (or set lower than acceptable)
Calls superclass method
LUIT::LUITElement::new
# File lib/luit.rb, line 204 def initialize(holder, id, x, y, text, w = 0, h = 0) h = [50, h].max @text = text @buttonColor = LUIT.uiColor @font = Gosu::Font.new(h - 20) @textW = @font.text_width(@text) w = @textW + 20 if w < @textW + 20 super(holder, id, x, y, w, h) end
Public Instance Methods
draw(x = 0, y = 0)
click to toggle source
# File lib/luit.rb, line 214 def draw(x = 0, y = 0) Gosu::draw_rect(x + @x, y + @y, @w, @h, @hover ? LUIT.uiColorLight : LUIT.uiColor, LUIT.z) @font.draw_rel(@text, @x + x + @w / 2, @y + y + @h / 2, LUIT.z + 1, 0.5, 0.5) end
update(x = 0, y = 0)
click to toggle source
Calls superclass method
LUIT::LUITElement#update
# File lib/luit.rb, line 219 def update(x = 0, y = 0) x += @x y += @y updateHover(x, y) super(x, y) end