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_or_type, attributes = {}) ⇒ 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, inherited, #inspect, #pencil, type, #update
Methods included from Attributes::HasVisibility
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 |
# File 'lib/cura/component/pack.rb', line 14 def initialize(attributes={}) @fill = false @spacing = 0 super end |
Instance Attribute Details
#spacing ⇒ Integer
Get the spacing between children.
99 100 101 |
# File 'lib/cura/component/pack.rb', line 99 def spacing @spacing end |
Instance Method Details
#add_child(component_or_type, attributes = {}) ⇒ Component
Add a child to this group.
53 54 55 56 57 58 59 60 |
# File 'lib/cura/component/pack.rb', line 53 def add_child(component_or_type, attributes={}) # TODO: :expand and :fill attributes? child = super pack_children child end |
#delete_child_at(index) ⇒ Component
Remove a child from this object’s children at the given index.
66 67 68 69 70 71 72 |
# File 'lib/cura/component/pack.rb', line 66 def delete_child_at(index) child = super pack_children child end |
#draw ⇒ Pack
Draw this pack.
115 116 117 118 119 |
# File 'lib/cura/component/pack.rb', line 115 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.
92 93 94 |
# File 'lib/cura/component/pack.rb', line 92 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.
79 80 81 |
# File 'lib/cura/component/pack.rb', line 79 def fill? @fill end |
#height=(value) ⇒ Object
Set the height dimension of this pack.
31 32 33 34 35 36 37 |
# File 'lib/cura/component/pack.rb', line 31 def height=(value) result = super pack_children result end |
#width=(value) ⇒ Object
Set the width dimension of this pack.
22 23 24 25 26 27 28 |
# File 'lib/cura/component/pack.rb', line 22 def width=(value) result = super pack_children result end |