Class: Core::GUI::Scrollbar
- Includes:
- Gosu
- Defined in:
- lib/gui/base.rb
Instance Attribute Summary collapse
-
#h ⇒ Object
readonly
Returns the value of attribute h.
-
#sh ⇒ Object
Returns the value of attribute sh.
Attributes inherited from Element
#w, #x, #xoff, #y, #yoff, #zoff
Instance Method Summary collapse
- #draw ⇒ Object
-
#initialize(x, y, w, h) ⇒ Scrollbar
constructor
A new instance of Scrollbar.
- #offset ⇒ Object
- #update ⇒ Object
Methods inherited from Element
Constructor Details
Instance Attribute Details
#h ⇒ Object (readonly)
Returns the value of attribute h.
238 239 240 |
# File 'lib/gui/base.rb', line 238 def h @h end |
#sh ⇒ Object
Returns the value of attribute sh.
237 238 239 |
# File 'lib/gui/base.rb', line 237 def sh @sh end |
Instance Method Details
#draw ⇒ Object
269 270 271 272 |
# File 'lib/gui/base.rb', line 269 def draw @bg.draw(@x+@xoff, @y+@yoff, Core::GUI_Z + 14, @w/@bg.width, @h/@bg.height.to_f) @scroller.draw(@x+@xoff, @sy+@yoff, Core::GUI_Z + 15, 1, @sh/@scroller.height.to_f) end |
#offset ⇒ Object
247 248 249 |
# File 'lib/gui/base.rb', line 247 def offset return ((@sy-@y)/((@y)-(@y+@h-@sh)+1))*-100 end |
#update ⇒ Object
250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 |
# File 'lib/gui/base.rb', line 250 def update x = Core.window.mouse_x y = Core.window.mouse_y if Core.inside?(x, y, @x, @sy, @x+@w, @sy+@sh) and Core.window.(MsLeft) and !@held @held = true @offset = @sy-y end if @held @sy = y + @offset if @sy < @y @sy = @y elsif @sy+@sh > @y+@h @sy = @y+@h-@sh-1 end if !Core.window.(MsLeft) @held = false end end end |