Name

layout (LzLayout) — Abstract layout base class.

Synopsis

LZX: layout
JavaScript: LzLayout
Type: Class
Access: public
Topic: LFC.Views
Declared in: WEB-INF/lps/lfc/controllers/LaszloLayout.lzs

Description

This layout class is the base class that all other layouts — such as, for example simplelayout and resizelayout — extend.

A layout arranges the views within the element that it is attached to. simplelayout is one example of a basic extension of this layout object, and the code sample below illustrates its use.

For example, the layout in:

 <canvas height="30">
   <view>
     <text>A</text>
     <text>B</text>
     <simplelayout axis="y"/>
   </view>
 </canvas>
 

is necessary to keep the A and B text views from being positioned on top of each other. As an alternative to the layout element, a view may specify a layout attribute. For example, the previous example is equivalent to:

programlayout-2
 <canvas height="30">
   <view layout="axis: y">
     <text>A</text>
     <text>B</text>
   </view>
 </canvas>
 

You do not use layout to explicitly position views. Rather, you may extend this class to create new types of layouts.

Layouts, like constraints and animators, affect specific attributes of a view. Views can have more than one layout, as long as each set of attributes associated with a layout does not overlap with any of the other sets.

Superclass Chain

node (LzNode) » layout (LzLayout)

Known Subclasses

Details

Properties (4)

delegates
<attribute name="delegates" type="lzDelegate" />
public var delegates : LzDelegate;
An array of all the delegates used by the layout
locked
<attribute name="locked" type="boolean" />
public var locked : Boolean = 2;
Set to true if layout is locked from updates.
subviews
<attribute name="subviews" type="array" />
protected var subviews : Array = null;
Array holding the views under this layout's control.
updateDelegate
<attribute name="updateDelegate" type="lzDelegate" />
public var updateDelegate : LzDelegate;
A delegate used to update the layout.

Setters (1)

Setters for virtual properties, to be used with setAttribute. A setter may or may not have a corresponding getter method; consult the Methods list in this section.

locked

Methods (9)

addSubview()
<method name="addSubview" args="sd" />
protected function addSubview(sd : LzView);
Called whenever a new subview is added to the layout. This is called both in the layout constructor and when a new subview is called after layout has been created. This is only called if the view's "ignorelayout" option is not set.
ignore()
<method name="ignore" args="s" />
protected function ignore(s : LzView);
Called when a subview is to be ignored by the layout. By default, most layouts include all the subviews of a given view.
lock()
<method name="lock" />
public function lock();
Lock the layout from processing updates. This allows the layout to register for events that it generates itself. Unfortunately, right now all subclass routines that can generate calls that may result in the layout calling itself should check the lock before processing. Failure to do so is not catastrophic, but it will slow down your program.
releaseLayout()
<method name="releaseLayout" />
public function releaseLayout();
Remove the layout from the view and unregister the delegates that the layout uses.
removeSubview()
<method name="removeSubview" args="sd" />
protected function removeSubview(sd : LzView);
Called when a subview is removed. This is not well tested.
reset()
<method name="reset" args="e" />
protected function reset(e : Any);
Reset any held parameters (such as kept sizes that may have changed) and before updating.
setLayoutOrder()
<method name="setLayoutOrder" args="sub1, sub2" />
public function setLayoutOrder(sub1 : LzView, sub2 : LzView);
Reorder the second subview given to this function so that it immediately follows the first. Doesn't touch the placement of the first subview given
swapSubviewOrder()
<method name="swapSubviewOrder" args="sub1, sub2" />
public function swapSubviewOrder(sub1 : LzView, sub2 : LzView);
Swap the positions of the two subviews within the layout
unlock()
<method name="unlock" />
public function unlock();
Unlock the layout once update is done.

LZX Synopsis

<class name="LzLayout" extends=" LzNode ">
  <attribute name=" delegates " type="lzDelegate" />
  <attribute name=" locked " type="boolean" />
  <attribute name=" subviews " type="array" />
  <attribute name=" updateDelegate " type="lzDelegate" />
  <method name=" addSubview " args="sd" />
  <method name=" ignore " args="s" />
  <method name=" lock " />
  <method name=" releaseLayout " />
  <method name=" removeSubview " args="sd" />
  <method name=" reset " args="e" />
  <method name=" setLayoutOrder " args="sub1, sub2" />
  <method name=" swapSubviewOrder " args="sub1, sub2" />
  <method name=" unlock " />
</class>

JavaScript Synopsis

public LzLayout extends  LzNode  {
  public var delegates  : LzDelegate;
  public var locked  : Boolean = 2;
  protected var subviews  : Array = null;
  public var updateDelegate  : LzDelegate;
  prototype protected function addSubview (sd : LzView);
  prototype protected function ignore (s : LzView);
  prototype public function lock ();
  prototype public function releaseLayout ();
  prototype protected function removeSubview (sd : LzView);
  prototype protected function reset (e : Any);
  prototype public function setLayoutOrder (sub1 : LzView, sub2 : LzView);
  prototype public function swapSubviewOrder (sub1 : LzView, sub2 : LzView);
  prototype public function unlock ();
}