Class
ContainableRenderableEntity
open class ContainableRenderableEntity : RenderableEntity
A ContainableRenderableEntity
is used for subclassing entities which may be
contained in a RenderableEntityContainer
.
Descendant classes must:
- Position the entity at topLeft
- Always use the mostRecentSize to determine its actual size
- The entity must provide hints to its container by calculating its own size and setting currentCalculatedSize accordingly
- If the entity finds the currentCalculatedSize is nil, it must recalcualte its size in calculate()
- Containers will resize and reposition their contained entities and maintaining the currentCalculatedSize as the minimum size
Relationships
Superclass
RenderableEntity
A
RenderableEntity
provides the majority of rendering and interactive functionality by overriding the required methods and working with theDispatcher
to register events of intrest.
Subclasses
RenderableEntityContainer
A
RenderableEntityContainer
is used for containing zero or moreContainableRenderableEntity
s. Because the container itself is aContainableRenderableEntity
, building a hierarchy of such containers is possible.
Initializers
init(name:topLeft:fixedSize:)
public init(name:String?=nil,
topLeft:Point=Point.zero, fixedSize:Size?)
Properties
owningContainer
public internal(set) weak var owningContainer : RenderableEntityContainer?
The owning container, if any This is set when this entity is inserted into a container
topLeft
public var topLeft : Point
The topLeft point of the entity When set, this entity must reposition accordingly.
externalSize
public var externalSize : Size?
The externally specified size of the entity, overriding the currentCalculatedSize.
currentCalculatedSize
public var currentCalculatedSize : Size?
previousCalculatedSize
public private(set) var previousCalculatedSize : Size?
The previously calculated size, set to the currentCalculatedSize whenever
that value is about to change to a non-nil value
This is important for stand-alone ContainableRenderableEntity
s because
they never have an externalSize so they'd temporarily lose their size
during a recalculation.
mostRecentCalculatedSize
public var mostRecentCalculatedSize : Size?
The most recently available calculated size
mostRecentSize
public var mostRecentSize : Size?
The most recently available size and the size that the entity MUST use.
fixedSize
public let fixedSize : Size?
Used for the currentCaclulcatedSize if specified If specifed, the currentCalculatedSize cannot be changed
Methods
sizeChanged()
open func sizeChanged()
Invoked to inform an entity that its size has changed. Descendant classes should only note this change and take action later in calculate(). The potential change in size may be due to a new, external size or a new calculated size, either of which MAY result in an actual change in rendered size.
topLeftChanged()
open func topLeftChanged()
Invoked to inform an entity that its topLeft has changed. Descendant classes should only note this change and take action later in calculate().