-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from GimmickNG/experimental
AIRDock v0.3 (from experimental)
- Loading branch information
Showing
48 changed files
with
1,932 additions
and
1,151 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,135 @@ | ||
package airdock.delegates | ||
{ | ||
import airdock.enums.PanelContainerSide; | ||
import airdock.events.DockEvent; | ||
import airdock.interfaces.ui.IDockHelper; | ||
import airdock.util.IPair; | ||
import flash.desktop.NativeDragManager; | ||
import flash.display.DisplayObject; | ||
import flash.display.InteractiveObject; | ||
import flash.events.Event; | ||
import flash.events.IEventDispatcher; | ||
import flash.events.NativeDragEvent; | ||
import flash.utils.Dictionary; | ||
|
||
/** | ||
* ... | ||
* @author Gimmick | ||
*/ | ||
public class DockHelperDelegate implements IEventDispatcher | ||
{ | ||
private var str_panelFormat:String; | ||
private var cl_dockHelper:IDockHelper; | ||
private var dct_dockTargets:Dictionary; | ||
private var str_containerFormat:String; | ||
public function DockHelperDelegate(dockHelper:IDockHelper) | ||
{ | ||
cl_dockHelper = dockHelper; | ||
dct_dockTargets = new Dictionary(true) | ||
dockHelper.addEventListener(NativeDragEvent.NATIVE_DRAG_DROP, acceptDragDrop, false, 0, true) | ||
dockHelper.addEventListener(NativeDragEvent.NATIVE_DRAG_OVER, displayTargetsOnDrag, false, 0, true) | ||
} | ||
|
||
public function addTarget(target:DisplayObject, side:int):void { | ||
dct_dockTargets[target] = side; | ||
} | ||
|
||
/** | ||
* Adds the targets specified to the list of all dock helper candidates/targets. | ||
* Each target is a key-value pair with the key as the target displayObject and the value as the side it represents. | ||
* In other words, the value is the side that a container or panel will be attached to when dropped on that target. | ||
* @param targets A Vector of key-value pairs with the key as the target displayObject and the value as the side which it represents. | ||
* @see airdock.util.IPair | ||
*/ | ||
public function addTargets(targets:Vector.<IPair>):void | ||
{ | ||
for (var i:uint = 0; i < targets.length; ++i) | ||
{ | ||
var target:IPair = targets[i]; | ||
if (target && target.key is DisplayObject && target.value !== null) { | ||
addTarget(target.key as DisplayObject, int(target.value)); | ||
} | ||
} | ||
} | ||
|
||
public function removeTarget(target:DisplayObject):void { | ||
delete dct_dockTargets[target]; | ||
} | ||
|
||
public function removeTargets(targets:Vector.<DisplayObject>):void | ||
{ | ||
for (var i:uint = 0; i < targets.length; ++i) | ||
{ | ||
var target:DisplayObject = targets[i] as DisplayObject | ||
if(target) { | ||
removeTarget(target) | ||
} | ||
} | ||
} | ||
|
||
public function getSideFrom(dropTarget:DisplayObject):int | ||
{ | ||
if(dropTarget in dct_dockTargets) { | ||
return int(dct_dockTargets[dropTarget]) | ||
} | ||
return PanelContainerSide.FILL | ||
} | ||
|
||
public function get targets():Vector.<DisplayObject> | ||
{ | ||
var targets:Vector.<DisplayObject> = new Vector.<DisplayObject>() | ||
for(var obj:Object in dct_dockTargets) { | ||
targets.push(obj) | ||
} | ||
return targets; | ||
} | ||
|
||
/** | ||
* Dispatches a DockEvent when the user has dropped the panel or container on any of the sprites of this object, prior to the end of the drag-dock action. | ||
*/ | ||
private function acceptDragDrop(evt:NativeDragEvent):void | ||
{ | ||
if (evt.clipboard.hasFormat(str_panelFormat) || evt.clipboard.hasFormat(str_containerFormat)) { | ||
dispatchEvent(new DockEvent(DockEvent.DRAG_COMPLETING, evt.clipboard, evt.target as DisplayObject, true, true)) | ||
} | ||
} | ||
|
||
private function displayTargetsOnDrag(evt:NativeDragEvent):void | ||
{ | ||
var currentTarget:InteractiveObject = evt.target as InteractiveObject | ||
if (!(currentTarget in dct_dockTargets && (evt.clipboard.hasFormat(str_panelFormat) || evt.clipboard.hasFormat(str_containerFormat)))) { | ||
return; | ||
} | ||
cl_dockHelper.hide(); //hides all the targets | ||
cl_dockHelper.show(new <DisplayObject>[currentTarget]) //except the current one | ||
NativeDragManager.acceptDragDrop(currentTarget) | ||
} | ||
|
||
public function addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void { | ||
cl_dockHelper.addEventListener(type, listener, useCapture, priority, useWeakReference); | ||
} | ||
|
||
public function dispatchEvent(event:Event):Boolean { | ||
return cl_dockHelper.dispatchEvent(event); | ||
} | ||
|
||
public function hasEventListener(type:String):Boolean { | ||
return cl_dockHelper.hasEventListener(type); | ||
} | ||
|
||
public function removeEventListener(type:String, listener:Function, useCapture:Boolean = false):void { | ||
cl_dockHelper.removeEventListener(type, listener, useCapture); | ||
} | ||
|
||
public function willTrigger(type:String):Boolean { | ||
return cl_dockHelper.willTrigger(type); | ||
} | ||
|
||
public function setDockFormat(panelFormat:String, containerFormat:String):void | ||
{ | ||
str_panelFormat = panelFormat; | ||
str_containerFormat = containerFormat; | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
package airdock.delegates | ||
{ | ||
import airdock.events.PanelPropertyChangeEvent; | ||
import airdock.interfaces.display.IDisplayFilter; | ||
import airdock.interfaces.docking.IPanel; | ||
import flash.display.DisplayObject; | ||
import flash.events.Event; | ||
import flash.events.IEventDispatcher; | ||
|
||
/** | ||
* ... | ||
* @author Gimmick | ||
*/ | ||
public class PanelDelegate implements IEventDispatcher | ||
{ | ||
private var b_dockable:Boolean; | ||
private var b_resizable:Boolean; | ||
private var cl_basePanel:IPanel; | ||
private var str_panelName:String; | ||
private var vec_displayFilters:Vector.<IDisplayFilter>; | ||
public function PanelDelegate(panel:IPanel) { | ||
cl_basePanel = panel; | ||
} | ||
|
||
public function dispatchChanging(property:String, oldValue:Object, newValue:Object):Boolean { | ||
return dispatchEvent(new PanelPropertyChangeEvent(PanelPropertyChangeEvent.PROPERTY_CHANGING, property, oldValue, newValue, true, true)) | ||
} | ||
|
||
public function dispatchChanged(property:String, oldValue:Object, newValue:Object):void { | ||
dispatchEvent(new PanelPropertyChangeEvent(PanelPropertyChangeEvent.PROPERTY_CHANGED, property, oldValue, newValue, true, false)) | ||
} | ||
|
||
public function addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void { | ||
cl_basePanel.addEventListener(type, listener, useCapture, priority, useWeakReference); | ||
} | ||
|
||
public function dispatchEvent(event:Event):Boolean { | ||
return cl_basePanel.dispatchEvent(event); | ||
} | ||
|
||
public function hasEventListener(type:String):Boolean { | ||
return cl_basePanel.hasEventListener(type); | ||
} | ||
|
||
public function removeEventListener(type:String, listener:Function, useCapture:Boolean = false):void { | ||
cl_basePanel.removeEventListener(type, listener, useCapture); | ||
} | ||
|
||
public function willTrigger(type:String):Boolean { | ||
return cl_basePanel.willTrigger(type); | ||
} | ||
|
||
public function get panelName():String | ||
{ | ||
return str_panelName; | ||
} | ||
|
||
public function set panelName(value:String):void | ||
{ | ||
var prevValue:String = str_panelName | ||
if (str_panelName != value && dispatchChanging("panelName", prevValue, value)) | ||
{ | ||
str_panelName = value; | ||
dispatchChanged("panelName", prevValue, value) | ||
} | ||
} | ||
|
||
public function get resizable():Boolean { | ||
return b_resizable; | ||
} | ||
|
||
public function set resizable(value:Boolean):void | ||
{ | ||
if (b_resizable != value && dispatchChanging("resizable", !value, value)) | ||
{ | ||
b_resizable = value; | ||
dispatchChanged("resizable", !value, value) | ||
} | ||
} | ||
|
||
public function get dockable():Boolean { | ||
return b_dockable; | ||
} | ||
|
||
public function set dockable(value:Boolean):void | ||
{ | ||
if (b_dockable != value && dispatchChanging("dockable", !value, value)) | ||
{ | ||
b_dockable = value; | ||
dispatchChanged("dockable", !value, value) | ||
} | ||
} | ||
|
||
public function get displayFilters():Vector.<IDisplayFilter> { | ||
return vec_displayFilters && vec_displayFilters.concat(); | ||
} | ||
|
||
public function set displayFilters(value:Vector.<IDisplayFilter>):void | ||
{ | ||
var i:int; | ||
var filters:Vector.<IDisplayFilter> = vec_displayFilters | ||
for (i = int(filters && filters.length) - 1; i >= 0; --i) { | ||
filters[i].remove(cl_basePanel); | ||
} | ||
vec_displayFilters = value.concat(); | ||
for (i = int(value && value.length) - 1; i >= 0; --i) { | ||
value[i].apply(cl_basePanel); | ||
} | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.