class Fidgit::ScrollArea
A basic scrolling area. It is not managed in any way (use ScrollWindow
for that).
Attributes
content[R]
@return [Vertical] The content shown within this ScrollArea
Public Class Methods
new(options = {})
click to toggle source
@option options [Number] :offset (0) @option options [Number] :offset_x (value of :offset option) @option options [Number] :offset_y (value of :offset option) @option options [Element] :owner The owner of the content, such as the scroll-window containing the content.
Calls superclass method
Fidgit::Container::new
# File lib/fidgit/elements/scroll_area.rb, line 24 def initialize(options = {}) options = { offset: 0, owner: nil, }.merge! options @owner = options[:owner] super(options) @content = Vertical.new(parent: self, padding: 0) self.offset_x = options[:offset_x] || options[:offset] self.offset_y = options[:offset_y] || options[:offset] end
Public Instance Methods
hit_element(x, y)
click to toggle source
# File lib/fidgit/elements/scroll_area.rb, line 40 def hit_element(x, y) # Only pass on mouse events if they are inside the window. if hit?(x, y) @content.hit_element(x, y) || self else nil end end
offset_x()
click to toggle source
# File lib/fidgit/elements/scroll_area.rb, line 9 def offset_x; x - @content.x; end
offset_x=(value)
click to toggle source
# File lib/fidgit/elements/scroll_area.rb, line 12 def offset_x=(value) @content.x = x - [[@content.width - width, value].min, 0].max end
offset_y()
click to toggle source
# File lib/fidgit/elements/scroll_area.rb, line 10 def offset_y; y - @content.y; end
offset_y=(value)
click to toggle source
# File lib/fidgit/elements/scroll_area.rb, line 16 def offset_y=(value) @content.y = y - [[@content.height - height, value].min, 0].max end
recalc()
click to toggle source
Calls superclass method
# File lib/fidgit/elements/scroll_area.rb, line 49 def recalc super # Always recalc our owner if our content resizes, even though our size can't change even if the content changes # (may encourage ScrollWindow to show/hide scroll-bars, for example) @owner.recalc if @owner end
Protected Instance Methods
draw_foreground()
click to toggle source
# File lib/fidgit/elements/scroll_area.rb, line 57 def draw_foreground $window.clip_to(*rect) do @content.draw end end
post_init_block(&block)
click to toggle source
# File lib/fidgit/elements/scroll_area.rb, line 64 def post_init_block(&block) with(&block) end