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.
16 17 18 19 20 21 22 |
# File 'lib/cura/component/pack.rb', line 16 def initialize(attributes={}) @fill = false @spacing = 0 # @child_modifiers super end |
Instance Attribute Details
#spacing ⇒ Integer
Get the spacing between children.
97 98 99 |
# File 'lib/cura/component/pack.rb', line 97 def spacing @spacing end |
Instance Method Details
#add_child(component) ⇒ Component
Add a child to this group.
52 53 54 55 56 57 58 |
# File 'lib/cura/component/pack.rb', line 52 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.
64 65 66 67 68 69 70 |
# File 'lib/cura/component/pack.rb', line 64 def delete_child_at(index) child = super pack_children child end |
#draw ⇒ Pack
Draw this pack.
113 114 115 116 117 |
# File 'lib/cura/component/pack.rb', line 113 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.
90 91 92 |
# File 'lib/cura/component/pack.rb', line 90 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.
77 78 79 |
# File 'lib/cura/component/pack.rb', line 77 def fill? @fill end |
#height=(value) ⇒ Object
Set the height dimension of this pack.
34 35 36 37 38 39 40 |
# File 'lib/cura/component/pack.rb', line 34 def height=(value) result = super pack_children result end |
#width=(value) ⇒ Object
Set the width dimension of this pack.
25 26 27 28 29 30 31 |
# File 'lib/cura/component/pack.rb', line 25 def width=(value) result = super pack_children result end |