scaffold.libs_as.feathers.layout.ILayout.as Maven / Gradle / Ivy
/*
Feathers
Copyright 2012-2015 Bowler Hat LLC. All Rights Reserved.
This program is free software. You can redistribute and/or modify it in
accordance with the terms of the accompanying license agreement.
*/
package feathers.layout
{
import feathers.core.IFeathersEventDispatcher;
import flash.geom.Point;
import starling.display.DisplayObject;
/**
* Dispatched when a property of the layout changes, indicating that a
* redraw is probably needed.
*
* The properties of the event object have the following values:
*
* Property Value
* bubbles
false
* currentTarget
The Object that defines the
* event listener that handles the event. For example, if you use
* myButton.addEventListener()
to register an event listener,
* myButton is the value of the currentTarget
.
* data
null
* target
The Object that dispatched the event;
* it is not always the Object listening for the event. Use the
* currentTarget
property to always access the Object
* listening for the event.
*
*
* @eventType starling.events.Event.CHANGE
*/
[Event(name="change",type="starling.events.Event")]
/**
* Interface providing layout capabilities for containers.
*/
public interface ILayout extends IFeathersEventDispatcher
{
/**
* Determines if the container calls layout()
when the
* scroll position changes. Useful for transforming items as the view
* port scrolls. This value should be true
for layouts that
* implement the IVirtualLayout
interface and the
* useVirtualLayout
property is set to true
.
* May also be used by layouts that toggle item visibility as the items
* scroll into and out of the view port.
*/
function get requiresLayoutOnScroll():Boolean;
/**
* Positions (and possibly resizes) the supplied items within the
* optional bounds argument. If no bounds are specified, the layout
* algorithm will assume that the bounds start a 0,0 and have unbounded
* dimensions. Returns the actual bounds of the content, which may
* be different than the specified bounds.
*
* Note: The items are not absolutely
* restricted to appear only within the bounds. The bounds can affect
* positioning, but the algorithm may very well ignore them completely.
*
* If a layout implementation needs to access accurate width
* and height
values from items that are of type
* IFeathersControl
, it must call validate()
* manually. For performance reasons, the container that is the parent
* of the items will not call validate()
before passing the
* items to a layout implementation. Meeting this requirement may be as
* simple as looping through the items at the beginning of
* layout()
and validating all items that are Feathers UI
* controls:
*
*
* const itemCount:int = items.length;
* for(var i:int = 0; i < itemCount; i++)
* {
* var item:IFeathersControl = items[i] as IFeathersControl;
* if(item)
* {
* item.validate();
* }
* }
*
* @see feathers.core.FeathersControl#validate()
*/
function layout(items:Vector., viewPortBounds:ViewPortBounds = null, result:LayoutBoundsResult = null):LayoutBoundsResult;
/**
* Using the item dimensions, calculates a scroll position that will
* ensure that the item at a given index will be visible within the
* specified bounds.
*
* Typically, this function is used to show the item in the most
* prominent way, such as centering. To scroll a minimum distance
* required to display the full bounds of the item in the view port,
* use getNearestScrollPositionForIndex()
instead.
*
* This function should always be called after the
* layout()
function. The width and height arguments are
* the final bounds of the view port, which may be calculated in the
* layout() function.
*
* @see #getNearestScrollPositionForIndex()
*/
function getScrollPositionForIndex(index:int, items:Vector.,
x:Number, y:Number, width:Number, height:Number, result:Point = null):Point;
/**
* Calculates the scroll position nearest to the current scroll position
* that will display the full bounds of the item within the view port.
* If the item is already fully displayed in the view port, the current
* scroll position will be returned unchanged.
*
* While the item will be displayed in the view port without being
* clipped in any way, it may not be placed in the most prominent
* position possible. To give the item a more prominent location, use
* getScrollPositionForIndex()
instead.
*
* This function should always be called after the
* layout()
function. The width and height arguments are
* the final bounds of the view port, which may be calculated in the
* layout() function.
*
* @see #getScrollPositionForIndex()
*/
function getNearestScrollPositionForIndex(index:int, scrollX:Number, scrollY:Number,
items:Vector., x:Number, y:Number, width:Number, height:Number, result:Point = null):Point
}
}