Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Wired the Mac toolbar Started on PC taskbar icon menu Added SignalCommandMap swc Refactored
- Loading branch information
1 parent
bba130d
commit 98c0412
Showing
15 changed files
with
630 additions
and
257 deletions.
There are no files selected for viewing
Binary file not shown.
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,27 @@ | ||
package com.destroytoday.dwarf.controllers { | ||
import com.destroytoday.dwarf.views.ruler.RulerView; | ||
|
||
import org.robotlegs.mvcs.SignalCommand; | ||
|
||
/** | ||
* The AddRulerCommand class creates the RulerView instance's mediator. | ||
* @author Jonnie Hallman | ||
*/ | ||
public class AddRulerCommand extends SignalCommand { | ||
[Inject] | ||
public var ruler:RulerView; | ||
|
||
/** | ||
* @private | ||
*/ | ||
public function AddRulerCommand() { | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
override public function execute():void { | ||
mediatorMap.createMediator(ruler); | ||
} | ||
} | ||
} |
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,59 @@ | ||
package com.destroytoday.dwarf.controllers { | ||
import com.destroytoday.dwarf.contexts.ApplicationContext; | ||
import com.destroytoday.dwarf.core.ITool; | ||
import com.destroytoday.dwarf.models.ToolModel; | ||
import com.destroytoday.dwarf.signals.AddRulerSignal; | ||
import com.destroytoday.dwarf.views.ruler.RulerView; | ||
import com.destroytoday.util.WindowUtil; | ||
|
||
import org.robotlegs.mvcs.Actor; | ||
|
||
/** | ||
* The ToolController class adds and removes tools. | ||
* @author Jonnie Hallman | ||
*/ | ||
public class ToolController extends Actor { | ||
[Inject] | ||
public var model:ToolModel; | ||
|
||
[Inject] | ||
public var addRulerSignal:AddRulerSignal; | ||
|
||
/** | ||
* Constructs the ToolController instance. | ||
*/ | ||
public function ToolController() { | ||
} | ||
|
||
/** | ||
* Adds a ruler. | ||
*/ | ||
public function addRuler():void { | ||
var ruler:RulerView = new RulerView(); | ||
|
||
addRulerSignal.dispatch(ruler); | ||
|
||
ruler.open(); | ||
|
||
model.addTool(ruler); | ||
} | ||
|
||
/** | ||
* Removes the provided ruler. | ||
* @param ruler | ||
*/ | ||
public function removeRuler(ruler:RulerView):void { | ||
ruler.close(); | ||
model.removeTool(ruler); | ||
} | ||
|
||
/** | ||
* Removes the current tool, as indicated by the ToolModel. | ||
*/ | ||
public function removeCurrentTool():void { | ||
var tool:ITool = model.removeTool(model.currentTool); | ||
|
||
if (tool) tool.close(); | ||
} | ||
} | ||
} |
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,6 @@ | ||
package com.destroytoday.dwarf.core { | ||
public interface ITool { | ||
function open():void; | ||
function close():void; | ||
} | ||
} |
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,68 @@ | ||
package com.destroytoday.dwarf.desktop { | ||
import com.destroytoday.desktop.NativeMenuPlus; | ||
import com.destroytoday.dwarf.controllers.ToolController; | ||
import com.destroytoday.util.ApplicationUtil; | ||
|
||
import flash.desktop.DockIcon; | ||
import flash.desktop.Icon; | ||
import flash.desktop.NativeApplication; | ||
import flash.desktop.SystemTrayIcon; | ||
import flash.display.NativeMenuItem; | ||
import flash.net.URLRequest; | ||
import flash.net.navigateToURL; | ||
import flash.ui.Keyboard; | ||
|
||
public class IconMenu extends NativeMenuPlus { | ||
[Inject] | ||
public var toolController:ToolController; | ||
|
||
public function IconMenu() { | ||
} | ||
|
||
public function setup():void { | ||
var modifier:uint; | ||
|
||
if (ApplicationUtil.mac) { | ||
(NativeApplication.nativeApplication.icon as DockIcon).menu = this; | ||
|
||
data = | ||
<menu> | ||
<item name="newRuler" label="New Ruler" /> | ||
<separator /> | ||
<item name="closeTool" label="Close Tool" /> | ||
</menu>; | ||
} else { | ||
(NativeApplication.nativeApplication.icon as SystemTrayIcon).menu = this; | ||
|
||
data = | ||
<menu> | ||
<item name="newRuler" keyEquivalentModifiers="control" keyEquivalent="r" label="New Ruler" /> | ||
<separator /> | ||
<item name="closeTool" keyEquivalentModifiers="control" keyEquivalent="w" label="Close Tool" /> | ||
</menu>; | ||
} | ||
|
||
//add listeners | ||
itemSelectSignal.add(iconMenuItemSelectHandler); | ||
} | ||
|
||
/** | ||
* @private | ||
* @param menu | ||
* @param item | ||
*/ | ||
protected function iconMenuItemSelectHandler(menu:NativeMenuPlus, item:NativeMenuItem):void { | ||
switch (item.name) { | ||
case "aboutDwarf": | ||
navigateToURL(new URLRequest("http://github.com/destroytoday/Dwarf")); | ||
break; | ||
case "newRuler": | ||
toolController.addRuler(); | ||
break; | ||
case "closeTool": | ||
toolController.removeCurrentTool(); | ||
break; | ||
} | ||
} | ||
} | ||
} |
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.