Skip to content

Commit

Permalink
Commit for v0.3
Browse files Browse the repository at this point in the history
Major update. A list of changes which have been made since the last commit will be included shortly.
  • Loading branch information
GimmickNG authored May 6, 2018
1 parent f470cca commit e4913a3
Show file tree
Hide file tree
Showing 48 changed files with 1,260 additions and 959 deletions.
1,148 changes: 594 additions & 554 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
6 changes: 4 additions & 2 deletions src/airdock/delegates/DockHelperDelegate.as
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ package airdock.delegates
import flash.events.IEventDispatcher;
import flash.events.NativeDragEvent;
import flash.utils.Dictionary;

/**
* ...
* @author Gimmick
* @author Gimmick
*/
public class DockHelperDelegate implements IEventDispatcher
{
Expand All @@ -35,7 +36,8 @@ package airdock.delegates

/**
* 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 which it represents, or the side that a container or panel will be attached to when dropped on that target.
* 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
*/
Expand Down
36 changes: 28 additions & 8 deletions src/airdock/delegates/PanelDelegate.as
Original file line number Diff line number Diff line change
@@ -1,22 +1,25 @@
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
* @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 cl_dispatcher:IEventDispatcher
private var vec_displayFilters:Vector.<IDisplayFilter>;
public function PanelDelegate(panel:IPanel) {
cl_dispatcher = panel;
cl_basePanel = panel;
}

public function dispatchChanging(property:String, oldValue:Object, newValue:Object):Boolean {
Expand All @@ -28,23 +31,23 @@ package airdock.delegates
}

public function addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void {
cl_dispatcher.addEventListener(type, listener, useCapture, priority, useWeakReference);
cl_basePanel.addEventListener(type, listener, useCapture, priority, useWeakReference);
}

public function dispatchEvent(event:Event):Boolean {
return cl_dispatcher.dispatchEvent(event);
return cl_basePanel.dispatchEvent(event);
}

public function hasEventListener(type:String):Boolean {
return cl_dispatcher.hasEventListener(type);
return cl_basePanel.hasEventListener(type);
}

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

public function willTrigger(type:String):Boolean {
return cl_dispatcher.willTrigger(type);
return cl_basePanel.willTrigger(type);
}

public function get panelName():String
Expand Down Expand Up @@ -87,6 +90,23 @@ package airdock.delegates
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);
}
}
}

}
24 changes: 21 additions & 3 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,13 +41,31 @@ package airdock.delegates
}

public function requestShow(panel:IPanel):Boolean {
return panel && dispatchEvent(new PanelContainerEvent(PanelContainerEvent.SHOW_REQUESTED, panel, null, false, 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 dispatchEvent(new PanelContainerEvent(PanelContainerEvent.STATE_TOGGLE_REQUESTED, panel, null, true, true))
}
Expand All @@ -61,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 Down
19 changes: 16 additions & 3 deletions src/airdock/delegates/ResizerDelegate.as
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,19 @@ package airdock.delegates
import flash.geom.Rectangle;
/**
* ...
* @author Gimmick
* @author Gimmick
*/
public class ResizerDelegate
{
private var i_sideCode:int;
private var b_dragging:Boolean;
private var rect_maxSize:Rectangle;
private var cl_dispatcher:IResizer;
private var plc_container:IContainer;
public function ResizerDelegate(resizer:IResizer)
public function ResizerDelegate(resizer:IResizer)
{
cl_dispatcher = resizer
cl_dispatcher = resizer;
rect_maxSize = new Rectangle();
}

/**
Expand Down Expand Up @@ -85,6 +87,17 @@ package airdock.delegates
plc_container = value;
}

public function get maxSize():Rectangle { //returns a reference because no public getter
return rect_maxSize //in IResizer; only class that should modify this is
} //the IResizer implementation

public function set maxSize(size:Rectangle):void
{
if (size) {
rect_maxSize.copyFrom(size)
}
}

}

}
5 changes: 4 additions & 1 deletion src/airdock/enums/CrossDockingPolicy.as
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ package airdock.enums
* * Outgoing - Attach to another container which is not originating from (i.e. has not been created by) its Docker
* * Incoming - Have another panel or container, which is not originating from its Docker, be attached to it
* * Both - allow or forbid both actions.
* @author Gimmick
* @author Gimmick
*/
public class CrossDockingPolicy
{
Expand All @@ -16,16 +16,19 @@ package airdock.enums
* panels from other Dockers can be attached to containers originating from the Docker with this policy.
*/
public static const UNRESTRICTED:int = 0;

/**
* Prevents panels from the Docker with this policy from being attached to containers originating from other Dockers, regardless of their docking policies.
*/
public static const PREVENT_OUTGOING:int = 1;

/**
* Prevents panels from other Dockers from being attached to containers originating from the Docker with this policy.
* This has a higher priority than PREVENT_OUTGOING; in effect, if one Docker has the PREVENT_OUTGOING policy and the other has the REJECT_INCOMING policy,
* then the second Docker will reject it before the first can prevent the action.
*/
public static const REJECT_INCOMING:int = 2;

/**
* Alias for (PREVENT_OUTGOING | REJECT_INCOMIN);
* in effect, prevents panels from other Dockers being attached to containers originating from the current Docker
Expand Down
2 changes: 1 addition & 1 deletion src/airdock/enums/DockDefaults.as
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ package airdock.enums

/**
* The default settings for a Docker. It is advised to use this in order to meet most (basic) use cases.
* @author Gimmick
* @author Gimmick
*/
public final class DockDefaults
{
Expand Down
46 changes: 27 additions & 19 deletions src/airdock/enums/PanelContainerSide.as
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,30 @@ package airdock.enums

/**
* The enumeration class which dictates the sides to which containers attach to.
* @author Gimmick
* @author Gimmick
*/
public final class PanelContainerSide
{
/**
* Gets the current container.
*/
public static const FILL:int = 0; //00000000

/**
* Gets the left side of the current container.
*/
public static const LEFT:int = 1; //00000001

/**
* Gets the right side of the current container.
*/
public static const RIGHT:int = 3; //00000011

/**
* Gets the top side of the current container.
*/
public static const TOP:int = 4; //00000100

/**
* Gets the bottom side of the current container.
*/
Expand All @@ -33,18 +37,22 @@ package airdock.enums
* String representation of FILL.
*/
public static const STRING_FILL:String = "F";

/**
* String representation of LEFT.
*/
public static const STRING_LEFT:String = "L"

/**
* String representation of RIGHT.
*/
public static const STRING_RIGHT:String = "R";

/**
* String representation of TOP.
*/
public static const STRING_TOP:String = "T";

/**
* String representation of BOTTOM.
*/
Expand Down Expand Up @@ -125,6 +133,7 @@ package airdock.enums

/**
* Convert a side, in string format, to an integer. Invalid values return FILL, by default.
* Does not convert multiple side codes; only a single side code at a time is supported.
* @param side The side to get the integer representation of, as a string.
* @return The integer representation of the side, as listed in this enumeration.
*/
Expand Down Expand Up @@ -186,29 +195,28 @@ package airdock.enums
if(!side) {
return null;
}
else if (side.length > 1)
else
{
var complementary:String = "";
for (var i:uint = 0; i < side.length; ++i) {
complementary += getComplementaryString(side.charAt(i));
for (var i:uint = 0; i < side.length; ++i)
{
switch(side.charAt(i))
{
case STRING_LEFT:
complementary += STRING_RIGHT;
case STRING_RIGHT:
complementary += STRING_LEFT;
case STRING_TOP:
complementary += STRING_BOTTOM;
case STRING_BOTTOM:
complementary += STRING_TOP;
case STRING_FILL:
default:
complementary += STRING_FILL;
}
}
return complementary
}

switch(side)
{
case STRING_LEFT:
return STRING_RIGHT;
case STRING_RIGHT:
return STRING_LEFT;
case STRING_TOP:
return STRING_BOTTOM;
case STRING_BOTTOM:
return STRING_TOP;
case STRING_FILL:
default:
return STRING_FILL;
}
}

/**
Expand Down
12 changes: 10 additions & 2 deletions src/airdock/enums/PanelContainerState.as
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
package airdock.enums
{
/**
* ...
* @author Gimmick
* Enumeration class indicating the possible states a panel or container can occupy.
* Each panel or container is either integrated or docked, and visible or invisible.
*
* An integrated panel (or container) is one belonging to a container whose root is not parked.
* A docked panel (or container) is one belonging to a container whose root is a parked container.
*
* A visible panel (or container) is that which is visible on the screen; a panel is visible if it belongs to a visible container.
* A container is visible if it is either part of a visible integrated container, or if it is part of a parked container whose window is visible.
*
* @author Gimmick
*/
public final class PanelContainerState
{
Expand Down
Loading

4 comments on commit e4913a3

@GimmickNG
Copy link
Owner Author

@GimmickNG GimmickNG commented on e4913a3 May 6, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Breaking Changes

The main breaking changes are listed below. Most of these involve changes to interfaces or events; if you are not using them, you will most likely not be affected (unless you make use of movePanelToContainer, which is the only miscellaneous breaking change listed.)

  • PanelContainerEvent.REMOVE_REQUESTED is now split into two subtypes:
    • PanelContainerEvent.PANEL_REMOVE_REQUESTED - This is dispatched whenever a panel is to be removed, and is usually dispatched by an IPanelList instance.
    • PanelContainerEvent.CONTAINER_REMOVE_REQUESTED - This is automatically dispatched by the IContainer instance whenever it becomes empty.
      The respective event strings have also been changed or added - the event string pcPanelRemoveRequested now corresponds to PanelContainerEvent.PANEL_REMOVE_REQUESTED and pcContainerRemoveRequested corresponds to PanelContainerEvent.CONTAINER_REMOVE_REQUESTED.
  • The IBasicDocker method movePanelToContainer() has now officially become deprecated with this release. It is advised to use addPanelToSideSequence() instead; the only public difference being that addPanelToSideSequence requires as side string [sequence] instead of a single side. The toString() method of PanelContainerSide can be used to convert integer sides to side strings. Multiple sides can be chained together in a single string, so fetching the container beforehand is not necessary. The deprecated function movePanelToContainer now aliases to addPanelToSideSequence, and will be removed in the future.
  • The hidePanel and showPanel methods in IBasicDocker now return Booleans instead of void.
  • Runtime display filtering is required for IContainer and IPanel implementations. For implementing runtime display filtering, refer to the IFilterable and IDisplayFilter classes.
  • IDockHelper now uses hide() and show() instead of hideAll() and showAll(); a parameter list of candidates can be specified to show or hide.

@GimmickNG
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other Changes & Additions

Other changes and additions, some minor and others semi-major, are listed in further comments.

@GimmickNG
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Additions:

  • Added delegates DockHelperDelegate, PanelDelegate, ResizerDelegate in package airdock.delegates
  • Added requestRemove() and requestDrag() methods in PanelListDelegate
  • Added extra utility functions to PanelContainerSide
  • Added runtime display filtering using the IFilterable and IDisplayFilter interfaces
    • Currently, IContainers and IPanels are required to support runtime display filtering.
  • DefaultPanelList now has close button for removing panels from a container, and shows a graphic when extra tabs are hidden from view (due to insufficient width available to display them)
  • Added AIRDock-specific integratePanel function - not a part of the IBasicDocker or ICustomizableDocker interface - to facilitate integrating panels when the panel state information is not known publicly.

@GimmickNG
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes:

  • Converted spaces to tabs in ASDoc tags & comments
  • Made methods in PanelContainerSide iterative, instead of recursive, where possible
  • Cleaned up implementation classes to use their respective delegation classes where possible (DefaultPanel, DefaultDockHelper, DefaultPanelList, etc.)
  • Removed redundant documentation for setters where getters already had documentation
  • Cleaned up AIRDock to remove redundant and varying methods of docking; all methods of docking (toggling state and drag-docking for both panels and containers) now follow more or less the same methods
  • Converted exclusion parameters to inclusion parameters (no unnecessary filtering on top of a filtered result)
  • Removed filterUndockablePanels and replaced it with extractDockablePanels, which returns the dockable panels instead of the undockable panels
  • Side ratio and thumbnails both use 1.0 as upper bound for percentage - Values greater than 1.0 for dragImageWidth/dragImageHeight of ICustomizableDocker and sideSize of IContainer (default implementations) are downcasted to int and taken as an absolute size (in pixels); values between [0, 1] are regarded as a percentage - previous versions used values between [0, 1) for percentages, leading to clumsy 0.99999... forms.
  • DefaultResizer now scales IContainers as relative, not absolute, sizes (i.e. sets the IContainer's sideSize property to a value between [0, 1] instead of an absolute value, thus permitting a side to scale as the entire container scales)
  • IPanelLists have updatePanel() called on them every time a panel updates, not just when the panel's panelName property changes.
  • Changed static ALLOWED_DRAG_ACTIONS to a non-static private member variable in AIRDock
  • IResizers are now displayed correctly when the mouse appears from either side of the container
  • Removed internal IReadablePanelStateInformation and IWritablePanelStateInformation interfaces from AIRDock as they served no purpose.

Please sign in to comment.