Class: Cura::Component::Pack
- Includes:
- Attributes::HasOrientation
- Defined in:
- lib/cura/component/pack.rb
Overview
A component with children which moves and optionally resizes them. TODO: Expand attribute - See: www.pygtk.org/pygtk2tutorial/sec-DetailsOfBoxes.html TODO: I think the only time it needs to pack_children is right before drawing? Would that get messy?
Direct Known Subclasses
Instance Attribute Summary collapse
-
#spacing ⇒ Integer
Get the spacing between children.
Attributes included from Attributes::HasOrientation
Attributes included from Attributes::HasAncestry
Attributes included from Attributes::HasOffsets
Attributes included from Attributes::HasEvents
Instance Method Summary collapse
-
#add_child(component) ⇒ Component
Add a child to this group.
-
#delete_child_at(index) ⇒ Component
Remove a child from this object’s children at the given index.
-
#draw ⇒ Pack
Draw this pack.
-
#fill=(value) ⇒ Boolean
Set whether children will be filled.
-
#fill? ⇒ Boolean
Get whether children will be filled.
-
#height=(value) ⇒ Object
Set the height dimension of this pack.
-
#initialize(attributes = {}) ⇒ Pack
constructor
A new instance of Pack.
-
#width=(value) ⇒ Object
Set the width dimension of this pack.
Methods included from Attributes::HasOrientation
Methods included from Attributes::HasAttributes
Methods inherited from Group
Methods included from Attributes::HasChildren
#add_children, #children, #children?, #delete_child, #delete_children, #each
Methods inherited from Base
#application, #background, #contains_coordinates?, #cursor, #focus, #focused?, #foreground, #inspect, #pencil, #update
Methods included from Attributes::HasRelativeCoordinates
Methods included from Attributes::HasCoordinates
Methods included from Attributes::HasAncestry
Methods included from Attributes::HasOffsets
#border, #border=, #margin, #margin=, #padding, #padding=
Methods included from Attributes::HasColors
#background, #background=, #foreground, #foreground=
Methods included from Attributes::HasFocusability
Methods included from Attributes::HasEvents
Methods included from Attributes::HasDimensions
Constructor Details
#initialize(attributes = {}) ⇒ Pack
Returns a new instance of Pack.
14 15 16 17 18 19 20 |
# File 'lib/cura/component/pack.rb', line 14 def initialize(attributes={}) @fill = false @spacing = 0 # @child_modifiers super end |
Instance Attribute Details
#spacing ⇒ Integer
Get the spacing between children.
95 96 97 |
# File 'lib/cura/component/pack.rb', line 95 def spacing @spacing end |
Instance Method Details
#add_child(component) ⇒ Component
Add a child to this group.
50 51 52 53 54 55 56 |
# File 'lib/cura/component/pack.rb', line 50 def add_child(component) child = super pack_children child end |
#delete_child_at(index) ⇒ Component
Remove a child from this object’s children at the given index.
62 63 64 65 66 67 68 |
# File 'lib/cura/component/pack.rb', line 62 def delete_child_at(index) child = super pack_children child end |
#draw ⇒ Pack
Draw this pack.
111 112 113 114 115 |
# File 'lib/cura/component/pack.rb', line 111 def draw pack_children super end |
#fill=(value) ⇒ Boolean
Set whether children will be filled. Must be truthy or falsey.
If set to a truthy value, children will be resized to fit the space available to it. For example, if orientation is set to :horizontal, then all of the children’s width attributes will be set to this instance’s width.
88 89 90 |
# File 'lib/cura/component/pack.rb', line 88 def fill=(value) @fill = !!value end |
#fill? ⇒ Boolean
Get whether children will be filled. If this pack’s orientation is set to :vertical, then the children’s width will be set to this pack’s width. If this pack’s orientation is set to :horizontal, then the children’s height will be set to this pack’s width.
75 76 77 |
# File 'lib/cura/component/pack.rb', line 75 def fill? @fill end |
#height=(value) ⇒ Object
Set the height dimension of this pack.
32 33 34 35 36 37 38 |
# File 'lib/cura/component/pack.rb', line 32 def height=(value) result = super pack_children result end |
#width=(value) ⇒ Object
Set the width dimension of this pack.
23 24 25 26 27 28 29 |
# File 'lib/cura/component/pack.rb', line 23 def width=(value) result = super pack_children result end |