class Cura::Component::Group
A component with children. When children are added, their parent will be set to this group.
Public Instance Methods
add_child(component_or_type, attributes={})
click to toggle source
Add a child to this group and set it's parent to this Group
.
@param [#to_sym, Component] component_or_type
A Symbol representing the child component type or a {Component::Base} instance. When a Symbol is given, a new child component will be initialized of that type. See {Component::Base.type}.
@param [#to_h] attributes
When component_or_type is a Symbol, then these attributes will be used to initialize the child component. When component_or_type is a {Component::Base}, then these attributes will be used to update the child component.
@return [Component]
Calls superclass method
Cura::Attributes::HasChildren#add_child
# 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)
click to toggle source
Remove a child from this object's children at the given index and set it's parent to nil.
@param [Integer] index @return [Component]
Calls superclass method
Cura::Attributes::HasChildren#delete_child_at
# File lib/cura/component/group.rb, line 66 def delete_child_at(index) component = super component.parent = nil component end
draw()
click to toggle source
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.
Calls superclass method
Cura::Component::Base#draw
# File lib/cura/component/group.rb, line 83 def draw super return self unless @draw draw_children end
height()
click to toggle source
Get the height of this group.
@return [Integer]
# 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()
click to toggle source
Update all children.
Calls superclass method
Cura::Component::Base#update
# File lib/cura/component/group.rb, line 75 def update super update_children end
width()
click to toggle source
Get the width of this group.
@return [Integer]
# 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