IFlexDisplayObject
.
*
* If the class implements the ILayoutManagerClient
interface,
* then the instance will be validated by the DragManager.
*
* If the class implements the IVisualElement
interface,
* then the instance's owner
property will be set to the List
* that initiates the drag.
*
* The AIR DragManager takes a snapshot of the instance, while
* the non-AIR DragManager uses the instance directly.
*
* @default spark.components.supportClasses.ListItemDragProxy
*
*/
Style(name="dragIndicatorClass", type="Class", inherit="no")
public class List extends ListBase implements IFocusManagerComponent
{
...
SkinPart(required="false", type="mx.core.IVisualElement")
// Should this be also a DisplayObject?
/**
* A skin part that defines a drop indicator that shows where the drag items
* will be inserted if the user releases the mouse to complete the drag drop operation.
*
* This is a dynamic skin part and must be of type IFactory.
*/
public var dropIndicator:IFactory;
//--------------------------------------------------------------------------
//
// Properties
//
//--------------------------------------------------------------------------
public function get dragEnabled():Boolean;
public function set dragEnabled(value:Boolean):void;
/**
* A flag that indicates whether items can be moved instead
* of just copied from the control as part of a drag-and-drop
* operation.
* If true
, and the dragEnabled
property
* is true
, items can be moved.
* Often the data provider cannot or should not have items removed
* from it, so a MOVE operation should not be allowed during
* drag-and-drop.
*
* @default false
*/
public function get dragMoveEnabled():Boolean;
public function set dragMoveEnabled(value:Boolean):void;
public function get dropEnabled():Boolean;
public function set dropEnabled(value:Boolean):void;
//--------------------------------------------------------------------------
//
// Methods: Drag and drop
//
//--------------------------------------------------------------------------
/**
* Adds the selected items to the DragSource object as part of a
* drag-and-drop operation.
* Override this method to add other data to the drag source.
*
* @param dragSource The DragSource object to which to add the data.
*/
public function addDragData(dragSource:DragSource):void;
/**
* The default handler for the dragStart
event.
*
* @param event The DragEvent object.
*/
protected function dragStartHandler(event:DragEvent):void
/**
* Handles DragEvent.DRAG_COMPLETE
events. This method
* removes the item from the data provider.
*
* @param event The DragEvent object.
*/
protected function dragCompleteHandler(event:DragEvent):void
/**
* Handles DragEvent.DRAG_ENTER
events. This method
* determines if the DragSource object contains valid elements and uses
* the DragManager.showDropFeedback()
method to set up the
* UI feedback as well as the layout.showDropIndicator()
method
* to display the drop indicator and initiate drag scrolling.
*
* @param event The DragEvent object.
*/
protected function dragEnterHandler(event:DragEvent):void
/**
* Handles DragEvent.DRAG_OVER
events. This method
* determines if the DragSource object contains valid elements and uses
* the showDropFeedback()
method to set up the UI feedback
* as well as the layout's showDropIndicator()
method
* to display the drop indicator and initiate drag scrolling.
*
* @param event The DragEvent object.
*/
protected function dragOverHandler(event:DragEvent):void
/**
* Handles DragEvent.DRAG_EXIT
events. This method hides
* the UI feedback by calling the hideDropFeedback()
method
* and also hides the drop indicator by calling the layout's
* hideDropIndicator()
method.
*
* @param event The DragEvent object.
*
*/
protected function dragExitHandler(event:DragEvent):void
/**
* Handles DragEvent.DRAG_DROP events
. This method hides
* the drop feedback by calling the hideDropFeedback()
method.
*
* If the action is a COPY
,
* then this method makes a deep copy of the object
* by calling the ObjectUtil.copy()
method,
* and replaces the copy's uid
property (if present)
* with a new value by calling the UIDUtil.createUID()
method.
List
instantiates this class and sets the owner property
* to point back to the List
.
* This class, when validated by the DragManager, looks up its owner
* property and creates item renderers for all the selected visible items in
* the owner List
.
Creates copies of the item renderers and adds them as children in createChildren(). * Override the createChildren() method to insert additional initialization logic.
* *The drag initiator component creates an instance of the ListItemDragProxy. * The owner property is set to the drag initiator component.
*/ public class ListItemDragProxy extends Group { include "../../core/Version.as"; //-------------------------------------------------------------------------- // // Constructor // //-------------------------------------------------------------------------- public function ListItemDragProxy(); } } ##### DropLocation package spark.layouts.supportClasses { import flash.geom.Point; import mx.core.IVisualElement; import mx.events.DragEvent; /** * This class is used to store information related to aDragEvent
* in order to minimize calculations as a DragEvent
* related requests are passed back and forth between the List
and
* its layout.
*
* The DropLocation
is created by the LayoutBase
* class when the List
calls the layout's
* calculateDropLocation()
method in response to a DragEvent
.
*
* The DropLocation is used by the layout for operations such as
* calculating the drop indicator bounds and drag-scroll deltas.
*
*/
public class DropLocation
{
/**
* Constructor.
*/
public function DropLocation()
{
}
/**
* The DragEvent
associated with this location.
*/
public var dragEvent:DragEvent = null;
/**
* The drop index corresponding to the event.
*/
public var dropIndex:int = -1;
/**
* The event point in local coordinates of the layout's target.
*/
public var dropPoint:Point = null;
/**
* The element appearing immediately before the dropIndicator.
* This is usually used by the layout to calculate drag-scrolling
* deltas.
* Note that even when an element exists, this field may still be null
* in cases where the layout can't scroll in that direction.
*/
public var elementBefore:IVisualElement = null;
/**
* The element appearing immediately after the dropIndicator.
* This is usually used by the layout to calculate drag-scrolling
* deltas.
* Note that even when an element exists, this field may still be null
* in cases where the layout can't scroll in that direction.
*/
public var elementAfter:IVisualElement = null;
}
}
##### LayoutBase
package spark.layouts.supportClasses
{
public class LayoutBase
{
...
//--------------------------------------------------------------------------
//
// Methods: Drag and drop, public APIs
//
//--------------------------------------------------------------------------
/**
* Sets the DisplayObject for this layout to use when
* displaying the drop indicator during drag and drop operation.
*
* Typically developers don't access this property directly,
* but instead rely on the List's default DragEvent
* handlers.
*
* The List
sets this property in response to a
* DragEvent.DRAG_ENTER
event.
* The List
initializes this property with an
* instance of its dropIndicator
skin part.
* The List
clears this property in response to a
* DragEvent.DRAG_EXIT
event.
DropLocation
for the specified
* dragEvent
.
*
* @param dragEvent The dragEvent dispatched by the DragManager.
*
* @return Returns the DropLocation for this event, or null if the drop
* operation is not possible.
*
* @see #showDropIndicator
* @see #hideDropIndicator
*/
public function calculateDropLocation(dragEvent:DragEvent):DropLocation;
/**
* Sizes, positions and parents the dropIndicator for the specified
* DropLocation.
*
* Starts/stops drag-scrolling when necessary conditions are met.
*
* The dorpIndicator
must be previously set.
*
* @param dropLocation The DropLocation must be * previously calculated through the calculateDropLocation() method.
* * @return Returns whether the drop indicator is visible. * * @see #hideDropIndicator * @see #calculateDropLocation * @see #dropIndicator */ public function showDropIndicator(dropLocation:DropLocation):Boolean; /** * Hides the previously showndropIndicator
,
* removes it from the display list and also stops the drag-scrolling.
*
* @see #showDropIndicator
* @see #dropIndicator
*/
public function hideDropIndicator():void;
//--------------------------------------------------------------------------
//
// Methods: Protected APIs for easier custom layout DND support
//
//--------------------------------------------------------------------------
/**
* Returns the index where a new item should be inserted if
* the user releases the mouse at the specified coordinates
* while completing a drag and drop gesture.
*
* Called by the calculatedDropLocation()
method.
*
* @param x The x coordinate of the drag and drop gesture, in target's
* local coordinates.
*
* @param y The y coordinate of the drag and drop gesture, in target's
* local coordinates.
*
* @return The drop index or -1 if the drop operation is to available
* at the specified coordinates.
*
* @see #calculateDropLocation
*/
protected function calculateDropIndex(x:Number, y:Number):int;
/**
* Calculates the bounds for the drop indicator UI that provides visual feedback
* to the user of where the items will be inserted at the end of a drag and drop
* gesture.
*
* Called by the showDropIndicator()
method.
*
* @param dropLocation A valid DropLocation
previously calculated
* through the calculateDropLocation
method.
*
* @return The bounds for the drop indicator or null.
*
* @see spark.layouts.supportClasses.DropLocation
* @see #calculateDropIndex
* @see #calculateDragScrollDelta
*/
protected function calculateDropIndicatorBounds(dropLocation:DropLocation):Rectangle;
/**
* Calculates how much to scroll for the specified DropLocation during a drag and drop gesture.
*
* Called by the showDropIndicator()
method, as well as during drag-scrolling.
*
* @param dropLocation A valid DropLocation
previously calculated
* through the calculateDropLocation
method.
*
* @return The scroll delta point or null if there's no need to drag-scroll.
*
* @see spark.layouts.supportClasses.DropLocation
* @see #calculateDropIndex
* @see #calculateDropIndicatorBounds
*/
protected function calculateDragScrollDelta(dropLocation:DropLocation):Point;
}
}
##### Overlays
package spark.components.supportClasses
{
public class GroupBase extends UIComponent implements IViewport
{
...
/**
* The overlay plane for this Group.
* All objects of the overlay plane render on top of the Group elements.
* Don't hold on to this object, as Group destroys and creates it on demand.
*/
public function get overlay():DisplayPlane
}
}
/**
* A DisplayPlane class maintains ordered list of DisplayObjects sorted on
* depth.
* Developers don't instantiate this class, but use the overlay
* property of Group
and DataGroup
.
*
* @see spark.components.Group#overlay
* @see spark.components.DataGroup#overlay
*/
public class DisplayPlane extends EventDispatcher
{
public function DisplayPlane()
//--------------------------------------------------------------------------
//
// Properties
//
//--------------------------------------------------------------------------
/**
* Number of objects in the DisplayPlane.
*/
public function get numDisplayObjects():int
//--------------------------------------------------------------------------
//
// Methods
//
//--------------------------------------------------------------------------
/**
* Returns the requested object with the specified index in the
* ordered list.
*/
public function getDisplayObjectAt(index:int):DisplayObject
/**
* Adds a displayObject
with the specified depth to the ordered list.
* The position of the displayObject
in the sorted lists is based on
* its depth, the object will be inserted after all objects with less than or equal
* depth value.
*
* @return Returns the index of the object.
*/
public function addDisplayObject(displayObject:DisplayObject, depth:Number = OverlayDepth.TOPMOST):int
/**
* Removes the specified displayObject
from the sorted list.
*/
public function removeDisplayObject(displayObject:DisplayObject):void
}
package spark.components.supportClasses
{
/**
* The OverlayDepth class defines the default depth values for
* various overlay elements.
*
* @see spark.components.Group#overlay
* @see spark.components.DataGroup#overlay
*/
public final class OverlayDepth
{
/**
* The overlay depth for a drop indicator.
*/
public static const DROP_INDICATOR_DEPTH:Number = 100;
/**
* The overlay depth for a mask object.
*/
public static const MASK_DEPTH:Number = 200;
/**
* The overlay depth for a focus object.
*/
public static const FOCUS_DEPTH:Number = 300;
/**
* The default top most overlay depth.
*/
public static const TOPMOST:Number = 10000;
}
}
}