Class: Core::GUI::ImageButton
- Defined in:
- lib/gui/button.rb
Overview
Same as Button, but draws an image instead of text
Instance Attribute Summary collapse
-
#bg ⇒ Object
readonly
Returns the value of attribute bg.
Attributes inherited from Button
Attributes inherited from Element
#h, #w, #x, #xoff, #y, #yoff, #zoff
Instance Method Summary collapse
- #draw ⇒ Object
-
#initialize(x, y, file, proc, w = -1,, h = -1)) ⇒ ImageButton
constructor
A new instance of ImageButton.
Methods inherited from Button
#disable, #enable, #hovered?, #toggle, #update
Methods inherited from Element
Constructor Details
#initialize(x, y, file, proc, w = -1,, h = -1)) ⇒ ImageButton
Returns a new instance of ImageButton.
72 73 74 75 76 77 78 79 80 81 |
# File 'lib/gui/button.rb', line 72 def initialize(x, y, file, proc, w=-1, h=-1) @bg = Core.sprite(file.to_s) if w < 0 @w = w = @bg.width end if h < 0 @h = h = @bg.height end super(x, y, w, h, "", proc, false) end |
Instance Attribute Details
#bg ⇒ Object (readonly)
Returns the value of attribute bg.
71 72 73 |
# File 'lib/gui/button.rb', line 71 def bg @bg end |
Instance Method Details
#draw ⇒ Object
82 83 84 85 86 87 88 89 90 91 |
# File 'lib/gui/button.rb', line 82 def draw color = Gosu::Color.new(255, 255, 255, 255) if !@enabled color.saturation = 125 end @bg.draw(@x+@xoff, @y+@yoff, Core::GUI_Z + 10 + @zoff, @w/@bg.width.to_f, @h/@bg.height.to_f, color) if @selected and @enabled @hi.draw(@x+@xoff, @y+@yoff, Core::GUI_Z + 11 + @zoff, @w/@hi.width.to_f, @h/@hi.height.to_f, 0xff999999, :additive) end end |