Class: LayoutItem
- Inherits:
-
CompositionItem
- Object
- ActiveRecord::Base
- ApplicationRecord
- CompositionItem
- LayoutItem
- Defined in:
- app/models/layout_item.rb
Overview
A LayoutItem places a specific thing in a Layout.
Only a LayoutItem::GroupItem may be the parent of a LayoutItem, so that a Layout's items only ever nest by translation (see GroupItem). Arbitrary parent/child transforms (zoom and rotation inherited about a parent's center) would oblige every renderer to compose, invert and decompose them, and would conflict with members stacking by their own z. Loosen deliberately if a feature needs it, e.g. an annotation pinned to an image.
What a LayoutItem class may place comes from object concerns it includes (e.g. Shared::Render::DepictionItem), several per class. So that they combine safely, an object concern:
- permits its class in a .composition_item_object_permitted? that falls back to super, so a class permits whatever any of its concerns permit
- guards its validations and callbacks by the object's type
- prefixes any other methods with its type (e.g. depiction_...), so that no concern overrides another's
Direct Known Subclasses
Defined Under Namespace
Classes: GroupItem, LightTableItem
Instance Attribute Summary
Attributes inherited from CompositionItem
#composition_id, #composition_item_object_id, #composition_item_object_type, #css_style, #height, #is_visible, #opacity, #parent_id, #position, #project_id, #rotation_z, #svg_clip, #svg_view_box, #text, #total, #type, #width, #x, #y, #z, #zoom
Instance Method Summary collapse
- #composition_is_layout ⇒ Object protected
- #parent_is_group ⇒ Object protected
Methods inherited from CompositionItem
#annotates_community_object?, #community_composition_has_no_object, #composition_is_unchanged, #composition_item_object_is_permitted, composition_item_object_permitted?, is_community?, #is_community?, #parent_is_in_composition, #parent_is_not_self_or_descendant, #set_community_project_id
Methods included from Housekeeping
#has_polymorphic_relationship?
Methods inherited from ApplicationRecord
Instance Method Details
#composition_is_layout ⇒ Object (protected)
33 34 35 36 37 |
# File 'app/models/layout_item.rb', line 33 def composition_is_layout if composition && !composition.is_a?(Layout) errors.add(:composition, 'must be a Layout') end end |
#parent_is_group ⇒ Object (protected)
27 28 29 30 31 |
# File 'app/models/layout_item.rb', line 27 def parent_is_group if parent && !parent.is_a?(LayoutItem::GroupItem) errors.add(:parent, 'must be a group') end end |