//////////////////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2014-present, Egret Technology.
// All rights reserved.
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of the Egret nor the
// names of its contributors may be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA,
// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
//////////////////////////////////////////////////////////////////////////////////////
namespace eui {
/**
* The LayoutBase class defines the base class for all Spark layouts.
* To create a custom layout that works with the Spark containers,
* you must extend LayoutBase or one of its subclasses.
*
*
Subclasses must implement the updateDisplayList()
* method, which positions and sizes the target GroupBase's elements, and
* the measure() method, which calculates the default
* size of the target.
LayoutBase 或其子类之一。
*
* 子类必须实现 updateDisplayList() 方法
* (定位 target Group 的子项并调整这些子项的大小)和 measure() 方法
* (计算 target 的默认大小)。
useVirtualLayout property
* to true for the layout associated with the container.
* Only DataGroup with layout set to VerticalLayout,
* HorizontalLayout, or TileLayout supports virtual layout.
* Layout subclasses that do not support virtualization must prevent changing
* this property.
*
* @default false
*
* @version Egret 2.4
* @version eui 1.0
* @platform Web,Native
* @language en_US
*/
/**
* 若要配置容器使用虚拟布局,请为与容器关联的布局的 useVirtualLayout 属性设置为 true。
* 只有布局设置为 VerticalLayout、HorizontalLayout 或 TileLayout 的 DataGroup 才支持虚拟布局。
* 不支持虚拟化的布局子类必须禁止更改此属性。
*
* @default false
*
* @version Egret 2.4
* @version eui 1.0
* @platform Web,Native
* @language zh_CN
*/
public get useVirtualLayout():boolean {
return this.$useVirtualLayout;
}
public set useVirtualLayout(value:boolean) {
value = !!value;
if (this.$useVirtualLayout == value)
return;
this.$useVirtualLayout = value;
this.dispatchEventWith("useVirtualLayoutChanged");
if (this.$useVirtualLayout && !value)
this.clearVirtualLayoutCache();
if (this.target)
this.target.invalidateDisplayList();
}
/**
* @private
*/
$typicalWidth:number = 71;
/**
* @private
*/
$typicalHeight:number = 22;
/**
* Set this size of a typical element
*
* @param width the height of element
* @param height the width of element
*
* @version Egret 2.4
* @version eui 1.0
* @platform Web,Native
* @language en_US
*/
/**
* 设置一个典型元素的大小
*
* @param width 元素的宽
* @param height 元素的高
*
* @version Egret 2.4
* @version eui 1.0
* @platform Web,Native
* @language zh_CN
*/
public setTypicalSize(width:number, height:number):void {
width = +width || 71;
height = +height || 22;
if (width !== this.$typicalWidth || height !== this.$typicalHeight) {
this.$typicalWidth = width;
this.$typicalHeight = height;
if (this.$target) {
this.$target.invalidateSize();
}
}
}
/**
* Called when the verticalScrollPosition or
* horizontalScrollPosition properties change.
*
* @version Egret 2.4
* @version eui 1.0
* @platform Web,Native
* @language en_US
*/
/**
* verticalScrollPosition 或 horizontalScrollPosition
* 属性更改时调用。
*
* @version Egret 2.4
* @version eui 1.0
* @platform Web,Native
* @language zh_CN
*/
public scrollPositionChanged():void {
}
/**
* When useVirtualLayout is true,
* this method can be used by the layout target
* to clear cached layout information when the target changes.
*
* @version Egret 2.4
* @version eui 1.0
* @platform Web,Native
* @language en_US
*/
/**
* 如果 useVirtualLayout 为 true,
* 则当布局目标改变时,布局目标可以使用此方法来清除已缓存布局信息。
*
* @version Egret 2.4
* @version eui 1.0
* @platform Web,Native
* @language zh_CN
*/
public clearVirtualLayoutCache():void {
}
/**
* Called by the target after a layout element
* has been added and before the target's size and display list are
* validated.
* Layouts that cache per element state, like virtual layouts, can
* override this method to update their cache.
*
* @param index The index of the element that was added.
*
* @version Egret 2.4
* @version eui 1.0
* @platform Web,Native
* @language en_US
*/
/**
* 在已添加布局元素之后且在验证目标的大小和显示列表之前,由目标调用。
* 按元素状态缓存的布局(比如虚拟布局)可以覆盖此方法以更新其缓存。
*
* @param index 发生改变的子项索引
*
* @version Egret 2.4
* @version eui 1.0
* @platform Web,Native
* @language zh_CN
*/
public elementAdded(index:number):void {
}
/**
* This method must is called by the target after a layout element
* has been removed and before the target's size and display list are
* validated.
* Layouts that cache per element state, like virtual layouts, can
* override this method to update their cache.
*
* @param index The index of the element that was added.
*
* @version Egret 2.4
* @version eui 1.0
* @platform Web,Native
* @language en_US
*/
/**
*
* 必须在已删除布局元素之后且在验证目标的大小和显示列表之前,由目标调用此方法。
* 按元素状态缓存的布局(比如虚拟布局)可以覆盖此方法以更新其缓存。
*
* @param index 发生改变的子项索引
*
* @version Egret 2.4
* @version eui 1.0
* @platform Web,Native
* @language zh_CN
*/
public elementRemoved(index:number):void {
}
/**
* Return the indices of the element visible within this Group.
*
* @return The indices of the visible element.
*
* @version Egret 2.4
* @version eui 1.0
* @platform Web,Native
* @language en_US
*/
/**
* 返回此 Group 中可见的元素的索引。
*
* @return 可见的元素的索引。
*
* @version Egret 2.4
* @version eui 1.0
* @platform Web,Native
* @language zh_CN
*/
public getElementIndicesInView():number[]{
return null;
}
/**
* Measures the target's default size based on its content.
*
* @version Egret 2.4
* @version eui 1.0
* @platform Web,Native
* @language en_US
*/
/**
* 基于目标的内容测量其默认大小
*
* @version Egret 2.4
* @version eui 1.0
* @platform Web,Native
* @language zh_CN
*/
public measure():void {
}
/**
* Sizes and positions the target's elements.
*
* @param unscaledWidth Specifies the width of the target, in pixels,
* in the targets's coordinates.
*
* @param unscaledHeight Specifies the height of the component, in pixels,
* in the target's coordinates.
*
* @version Egret 2.4
* @version eui 1.0
* @platform Web,Native
* @language en_US
*/
/**
* 调整目标的元素的大小并定位这些元素。
*
* @param unscaledWidth 指定目标在目标坐标中的宽度(以像素为单位)。
* @param unscaledHeight 指定组件在目标坐标中的高度(以像素为单位)。
*
* @version Egret 2.4
* @version eui 1.0
* @platform Web,Native
* @language zh_CN
*/
public updateDisplayList(width:number, height:number):void {
}
}
}