Class: Cura::Component::Group
- Includes:
- Attributes::HasChildren
- Defined in:
- lib/cura/component/group.rb
Overview
A component with children. When children are added, their parent will be set to this group.
Instance Attribute Summary
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 and set it’s parent to this Group.
-
#delete_child_at(index) ⇒ Component
Remove a child from this object’s children at the given index and set it’s parent to nil.
-
#draw ⇒ Object
Draw all children relative to this location.
-
#height ⇒ Integer
Get the height of this group.
-
#update ⇒ Object
Update all children.
-
#width ⇒ Integer
Get the width of this group.
Methods included from Attributes::HasChildren
#add_children, #children, #children?, #delete_child, #delete_children, #each, #initialize
Methods inherited from Base
#application, #background, #contains_coordinates?, #cursor, #focus, #focused?, #foreground, inherited, #inspect, #pencil, type
Methods included from Attributes::HasVisibility
#initialize, #visible=, #visible?
Methods included from Attributes::HasAttributes
included, #initialize, #update_attributes
Methods included from Attributes::HasRelativeCoordinates
#absolute_x, #absolute_y, #initialize
Methods included from Attributes::HasCoordinates
#initialize, #x, #x=, #y, #y=
Methods included from Attributes::HasAncestry
#ancestors, #initialize, #parent?
Methods included from Attributes::HasOffsets
#border, #border=, #initialize, #margin, #margin=, #padding, #padding=
Methods included from Attributes::HasColors
#background, #background=, #foreground, #foreground=, #initialize
Methods included from Attributes::HasFocusability
#focusable=, #focusable?, #initialize
Methods included from Attributes::HasEvents
included, #initialize, #on_event
Methods included from Attributes::HasDimensions
#height=, #initialize, #resize, #width=
Methods included from Attributes::HasInitialize
Instance Method Details
#add_child(component_or_type, attributes = {}) ⇒ Component
Add a child to this group and set it’s parent to this Group.
54 55 56 57 58 59 60 |
# File 'lib/cura/component/group.rb', line 54 def add_child(component_or_type, attributes={}) component = super component.parent = self component end |
#delete_child_at(index) ⇒ Component
Remove a child from this object’s children at the given index and set it’s parent to nil.
66 67 68 69 70 71 72 |
# File 'lib/cura/component/group.rb', line 66 def delete_child_at(index) component = super component.parent = nil component end |
#draw ⇒ Object
Draw all children relative to this location. TODO: If the dimensions of this group of this group are less than the computed dimensions, the drawing will be clipped.
83 84 85 86 87 |
# File 'lib/cura/component/group.rb', line 83 def draw super draw_children end |
#height ⇒ Integer
Get the height of this group.
26 27 28 29 30 31 |
# File 'lib/cura/component/group.rb', line 26 def height return @height unless @height == :auto return 0 if children.empty? children.collect { |child| child.y + child.height + child.offsets.height }.max end |
#update ⇒ Object
Update all children.
75 76 77 78 79 |
# File 'lib/cura/component/group.rb', line 75 def update super update_children end |
#width ⇒ Integer
Get the width of this group.
16 17 18 19 20 21 |
# File 'lib/cura/component/group.rb', line 16 def width return @width unless @width == :auto return 0 if children.empty? children.collect { |child| child.x + child.width + child.offsets.width }.max end |