Skip to content

Commit

Permalink
Merge pull request #4 from GimmickNG/experimental
Browse files Browse the repository at this point in the history
AIRDock v0.3 (from experimental)
  • Loading branch information
GimmickNG authored May 6, 2018
2 parents f4e688a + 29f1173 commit ddf3627
Show file tree
Hide file tree
Showing 48 changed files with 1,932 additions and 1,151 deletions.
1,188 changes: 623 additions & 565 deletions src/airdock/AIRDock.as

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/airdock/config/ContainerConfig.as
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ package airdock.config
* Base configuration class for creating a container.
* The width and height parameters are the minimum required parameters for creating the container;
* additional parameters can be added for extra customizability.
* @author Gimmick
* @author Gimmick
*/
public class ContainerConfig extends Object
{
Expand Down
2 changes: 1 addition & 1 deletion src/airdock/config/DockConfig.as
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ package airdock.config
import flash.display.NativeWindowInitOptions;
/**
* Base configuration class for creating a Docker instance.
* @author Gimmick
* @author Gimmick
*/
public class DockConfig extends Object
{
Expand Down
2 changes: 1 addition & 1 deletion src/airdock/config/PanelConfig.as
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package airdock.config
/**
* Base configuration class for creating a panel.
* Extra attributes can be added for customizability, subject to the instance of the PanelFactory used by the Docker.
* @author Gimmick
* @author Gimmick
*/
public class PanelConfig extends Object
{
Expand Down
135 changes: 135 additions & 0 deletions src/airdock/delegates/DockHelperDelegate.as
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;
}
}

}
112 changes: 112 additions & 0 deletions src/airdock/delegates/PanelDelegate.as
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);
}
}
}

}
38 changes: 30 additions & 8 deletions src/airdock/delegates/PanelListDelegate.as
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ package airdock.delegates
import flash.events.IEventDispatcher;
/**
* ...
* @author Gimmick
* @author Gimmick
*/
public class PanelListDelegate implements IEventDispatcher
{
Expand Down Expand Up @@ -41,11 +41,33 @@ package airdock.delegates
}

public function requestShow(panel:IPanel):Boolean {
return panel && cl_dispatcher.dispatchEvent(new PanelContainerEvent(PanelContainerEvent.SHOW_REQUESTED, panel, null, true, true))
return panel && dispatchEvent(new PanelContainerEvent(PanelContainerEvent.SHOW_REQUESTED, panel, null, true, true))
}

/**
* Requests the panelList's container to start a drag-dock operation for the given panel.
* If no panel is supplied (i.e. a null panel) then the drag-dock operation is started for the entire container.
* @param panel An (optional) IPanel instance which is to take part in a drag-dock operation.
* A null IPanel instance indicates the entire container should take part in the drag-dock operation.
* @return A Boolean indicating whether the operation was a success. If the event was prevented via preventDefault(), false is returned.
*/
public function requestDrag(panel:IPanel):Boolean {
return dispatchEvent(new PanelContainerEvent(PanelContainerEvent.DRAG_REQUESTED, panel, null, true, true))
}

public function requestRemove(panel:IPanel):Boolean {
return panel && dispatchEvent(new PanelContainerEvent(PanelContainerEvent.PANEL_REMOVE_REQUESTED, panel, null, true, true))
}

/**
* Requests the panelList's container to toggle the state (docked to integrated and vice versa) for the given panel
* If no panel is supplied (i.e. a null panel) then the state toggle operation is applied to the entire container.
* @param panel An (optional) IPanel instance whose state is to be toggled (from docked to integrated and vice versa)
* A null IPanel instance indicates the state toggle operation is to be applied to the entire container.
* @return A Boolean indicating whether the operation was a success. If the event was prevented via preventDefault(), false is returned.
*/
public function requestStateToggle(panel:IPanel):Boolean {
return cl_dispatcher.dispatchEvent(new PanelContainerEvent(PanelContainerEvent.STATE_TOGGLE_REQUESTED, panel, null, true, true))
return dispatchEvent(new PanelContainerEvent(PanelContainerEvent.STATE_TOGGLE_REQUESTED, panel, null, true, true))
}

public function removePanelAt(index:int):IPanel {
Expand All @@ -57,7 +79,7 @@ package airdock.delegates
var result:IPanel;
var index:int = getPanelIndex(panel);
if(index != -1) {
result = removePanelAt(index)
result = removePanelAt(index);
}
return result;
}
Expand All @@ -66,6 +88,10 @@ package airdock.delegates
cl_dispatcher.addEventListener(type, listener, useCapture, priority, useWeakReference);
}

public function removeEventListener(type:String, listener:Function, useCapture:Boolean = false):void {
cl_dispatcher.removeEventListener(type, listener, useCapture);
}

public function dispatchEvent(event:Event):Boolean {
return cl_dispatcher.dispatchEvent(event);
}
Expand All @@ -74,10 +100,6 @@ package airdock.delegates
return cl_dispatcher.hasEventListener(type);
}

public function removeEventListener(type:String, listener:Function, useCapture:Boolean = false):void {
cl_dispatcher.removeEventListener(type, listener, useCapture);
}

public function willTrigger(type:String):Boolean {
return cl_dispatcher.willTrigger(type);
}
Expand Down
Loading

0 comments on commit ddf3627

Please sign in to comment.