LayoutProxy¶
Overview¶
A stand-in for the layout-based fields of a Node, but where everything is done in the coordinate frame of the "root" of the Trail. It is a pooled object, so it can be reused to avoid memory issues.
NOTE: For layout, these trails usually have the "root" Node equal to the children of the layout constraint's ancestor Node. Therefore, the coordinate space is typically the local coordinate frame of the ancestorNode of the LayoutConstraint. This is not the same as the "global" coordinates for a Scenery Node in general (as most of the root nodes of the trails provided to LayoutProxy will have parents!)
@author Jonathan Olson <jonathan.olson@colorado.edu>
Class LayoutProxy¶
Constructor¶
new LayoutProxy( trail : Trail )¶
Instance Methods¶
initialize( trail : Trail ) : this¶
This is where the logic of a poolable type's "initializer" will go. It will be potentially run MULTIPLE times, as if it was constructing multiple different objects. It will be put back in the pool with dispose(). It will go through cycles of: - constructor(...) => initialize(...) --- only at the start - dispose() - initialize(...) - dispose() - initialize(...) - dispose() and so on.
DO not call it twice without in-between disposals (follow the above pattern).
isSizable( orientation : Orientation ) : boolean¶
getMinimum( orientation : Orientation ) : number¶
getMax( orientation : Orientation ) : number | null¶
Returns either the maxWidth or maxHeight depending on the orientation
attemptPreferredSize( orientation : Orientation, preferredSize : number | null )¶
dispose()¶
Releases references, and frees it to the pool.
freeToPool()¶
Instance Properties¶
trail : Trail | null¶
Nulled out when disposed
Static Properties¶
pool : Pool¶
(readonly)
Type Layoutable¶
For supporting general cases where you may layout a Node, or use in ManualConstraints.
Source Code¶
See the source for LayoutProxy.ts in the scenery repository.