Class: Fidgit::ScrollArea
- Defined in:
- lib/fidgit/elements/scroll_area.rb
Overview
A basic scrolling area. It is not managed in any way (use ScrollWindow for that).
Constant Summary
Constants inherited from Element
Element::DEFAULT_SCHEMA_FILE, Element::VALID_ALIGN_H, Element::VALID_ALIGN_V
Instance Attribute Summary collapse
-
#content ⇒ Vertical
readonly
The content shown within this ScrollArea.
Attributes inherited from Element
#align_h, #align_v, #background_color, #border_thickness, #font, #padding_bottom, #padding_left, #padding_right, #padding_top, #parent, #tip, #z
Instance Method Summary collapse
- #hit_element(x, y) ⇒ Object
-
#initialize(options = {}) ⇒ ScrollArea
constructor
A new instance of ScrollArea.
- #offset_x ⇒ Object
- #offset_x=(value) ⇒ Object
- #offset_y ⇒ Object
- #offset_y=(value) ⇒ Object
- #recalc ⇒ Object
Methods inherited from Container
#add, #button, #clear, #color_picker, #color_well, #combo_box, #file_browser, #grid, #group, #horizontal, #image_frame, #insert, #label, #list, #radio_button, #remove, #scroll_area, #scroll_window, #slider, #text_area, #to_s, #toggle_button, #update, #vertical, #write_tree, #x=, #y=
Methods inherited from Element
#default, #drag?, #draw, #draw_frame, #draw_rect, #enabled=, #enabled?, #height, #height=, #hit?, #max_height, #max_width, #min_height, #min_width, new, original_new, #outer_height, #outer_width, schema, #to_s, #update, #width, #width=, #with, #x, #x=, #y, #y=
Methods included from Event
#events, included, new_event_handlers, #publish, #subscribe, #unsubscribe
Constructor Details
#initialize(options = {}) ⇒ ScrollArea
Returns a new instance of ScrollArea.
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/fidgit/elements/scroll_area.rb', line 24 def initialize( = {}) = { offset: 0, owner: nil, }.merge! @owner = [:owner] super() @content = Vertical.new(parent: self, padding: 0) self.offset_x = [:offset_x] || [:offset] self.offset_y = [:offset_y] || [:offset] end |
Instance Attribute Details
#content ⇒ Vertical (readonly)
Returns The content shown within this ScrollArea.
7 8 9 |
# File 'lib/fidgit/elements/scroll_area.rb', line 7 def content @content end |
Instance Method Details
#hit_element(x, y) ⇒ Object
40 41 42 43 44 45 46 47 |
# 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 ⇒ Object
9 |
# File 'lib/fidgit/elements/scroll_area.rb', line 9 def offset_x; x - @content.x; end |
#offset_x=(value) ⇒ Object
12 13 14 |
# 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 ⇒ Object
10 |
# File 'lib/fidgit/elements/scroll_area.rb', line 10 def offset_y; y - @content.y; end |
#offset_y=(value) ⇒ Object
16 17 18 |
# 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 ⇒ Object
49 50 51 52 53 54 |
# 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 |