Layout(LzLayout)

出自OpenFace

跳转到: 导航, 搜索

目录

<layout>

Abstract layout base class. JavaScript: LzLayout


Extends Node 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:


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

Attributes

Name     Usage     Type(Tag)     Type(JS)    Default    Category

locked    Tag & JS   boolean       Boolean            setter

     Set to true if layout is locked from updates.


updateDelegate JS only  LzDelegate                     readonly

     A delegate used to update the layout.


Attributes inherited from Node

class, classroot, cloneManager, datapath, defaultplacement, id, ignoreAttribute, ignoreplacement, immediateparent, initstage, name, nodeLevel, onconstruct, oninit, parent, placement, subnodes



Methods

addSubview()

LzLayout.addSubview(sd) 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.

Parameters Name Type Desc sd LzView The subview to add.


lock()

LzLayout.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.


removeSubview()

LzLayout.removeSubview(sd) Called when a subview is removed. This is not well tested.

Parameters Name Type Desc sd LzView The subview to be removed.



reset()

LzLayout.reset(e) Reset any held parameters (such as kept sizes that may have changed) and before updating.

Parameters Name Type Desc e Any The event data that is passed by the delegate that called this funciton. This is usually unused, since more than one type of delegate can call reset.


unlock()

LzLayout.unlock() Unlock the layout once update is done.




Methods inherited from LzNode

animate, applyConstraint, applyData, childOf, completeInstantiation, construct, createChildren, dataBindAttribute, destroy, determinePlacement, getAttribute, getOption, getUID, init, lookupSourceLocator, searchImmediateSubnodes, searchSubnodes, setAttribute, setDatapath, setID, setName, setOption



Events

Events inherited from LzNode

onconstruct, ondata, oninit