Scenes Documentation Beta

Class Containable​Renderable​Entity

open class ContainableRenderableEntity : RenderableEntity 

A ContainableRenderableEntity is used for subclassing entities which may be contained in a RenderableEntityContainer. Descendant classes must:

  1. Position the entity at topLeft
  2. Always use the mostRecentSize to determine its actual size
  3. The entity must provide hints to its container by calculating its own size and setting currentCalculatedSize accordingly
  4. If the entity finds the currentCalculatedSize is nil, it must recalcualte its size in calculate()
  5. Containers will resize and reposition their contained entities and maintaining the currentCalculatedSize as the minimum size
%107 ContainableRenderableEntity ContainableRenderableEntity RenderableEntity RenderableEntity ContainableRenderableEntity->RenderableEntity RenderableEntityContainer RenderableEntityContainer RenderableEntityContainer->ContainableRenderableEntity

Superclass

RenderableEntity

A RenderableEntity provides the majority of rendering and interactive functionality by overriding the required methods and working with the Dispatcher to register events of intrest.

Subclasses

RenderableEntityContainer

A RenderableEntityContainer is used for containing zero or more ContainableRenderableEntitys. Because the container itself is a ContainableRenderableEntity, building a hierarchy of such containers is possible.

Initializers

init(name:​top​Left:​fixed​Size:​)

public init(name:String?=nil,
                topLeft:Point=Point.zero, fixedSize:Size?) 

Properties

owning​Container

public internal(set) weak var owningContainer : RenderableEntityContainer? 

The owning container, if any This is set when this entity is inserted into a container

top​Left

public var topLeft : Point 

The topLeft point of the entity When set, this entity must reposition accordingly.

external​Size

public var externalSize : Size? 

The externally specified size of the entity, overriding the currentCalculatedSize.

current​Calculated​Size

public var currentCalculatedSize : Size? 

previous​Calculated​Size

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 ContainableRenderableEntitys because they never have an externalSize so they'd temporarily lose their size during a recalculation.

most​Recent​Calculated​Size

public var mostRecentCalculatedSize : Size? 

The most recently available calculated size

most​Recent​Size

public var mostRecentSize : Size? 

The most recently available size and the size that the entity MUST use.

fixed​Size

public let fixedSize : Size?

Used for the currentCaclulcatedSize if specified If specifed, the currentCalculatedSize cannot be changed

Methods

size​Changed()

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.

top​Left​Changed()

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().