* Background imagery layers should match those of p1
* Dialog for adding custom imagery url
* Draggin a node under the toolbox and then mouseuping doesn't get passed to the map, so you end up with a node "stuck" to the pointer
-* Toolbox icons should be deactivated when not in correct state
== Miscellaneous data model ==
public static const DOWNLOAD:String = "download";
public static const RESIZE:String = "resize";
public static const MOVE:String = "move";
- public static const CLICK:String = "click";
public static const NUDGE_BACKGROUND:String = "nudge_background";
public var params:Object;
** Should have a close box, and be able to be activated from the top bar
** Should be automatically positioned at bottom-right of canvas on init
** Should float above tagViewer, not beneath it
- ** Icons should be disabled depending on what's selected (setEntity can do this)
** Remove annoying Illustrator cruft from SVG icons!
** Tooltips
public function setEntity(entity:Entity):void {
this.entity=entity;
+ dispatchEvent(new Event("updateSkin"));
+ dispatchEvent(new Event("updateAlpha"));
}
private function handleDown(e:Event):void {
private function handleUp(e:Event):void {
this.stopDrag();
}
+
+ // --------------------------------------------------------------------------------
+ // Enable/disable toolbox buttons
+ // (ideally we'd use CSS to set alpha in disabled state, but Flex's CSS
+ // capabilities aren't up to it)
+
+ [Bindable(event="updateSkin")]
+ public function canDo(op:String):Boolean {
+ switch (op) {
+ case 'delete': return (entity is Way || entity is Node);
+ case 'reverseDirection': return (entity is Way);
+ case 'quadrilateralise': return (entity is Way && Way(entity).isArea());
+ case 'straighten': return (entity is Way && !Way(entity).isArea());
+ case 'circularise': return (entity is Way && Way(entity).isArea());
+ case 'split': return (entity is Node && controller.state is SelectedWayNode);
+ case 'parallelise': return (entity is Way);
+ }
+ return false;
+ }
+
+ [Bindable(event="updateAlpha")]
+ public function getAlpha(op:String):Number {
+ if (canDo(op)) { return 1; }
+ return 0.5;
+ }
+
// --------------------------------------------------------------------------------
// Individual toolbox actions
controller.setState(new NoSelection());
}
}
-
+
public function doReverseDirection():void {
if (entity is Way) {
Way(entity).reverseNodes(MainUndoStack.getGlobalStack().addAction);
Circularise.circularise(Way(entity),controller.map);
}
}
-
+
public function doSplit():void {
if (entity is Node && controller.state is SelectedWayNode) {
controller.setState(SelectedWayNode(controller.state).splitWay());
protected function sharedKeyboardEvents(event:KeyboardEvent):ControllerState {
switch (event.keyCode) {
case 68: controller.map.paint.alpha=1.3-controller.map.paint.alpha; return null; // D
+ case 87: if (selectedWay) { return new SelectedWay(selectedWay); }; return null; // W
case 90: MainUndoStack.getGlobalStack().undo(); return null; // Z
}
return null;
<mx:Button icon="@Embed('embedded/delete.svg')"
click='toolbox.doDelete();'
+ enabled="{toolbox.canDo('delete')}"
+ alpha="{toolbox.getAlpha('delete')}"
width="28" height="28" textAlign="left" paddingLeft="6" paddingRight="0" />
<mx:Button icon="@Embed('embedded/direction.svg')"
click='toolbox.doReverseDirection();'
+ enabled="{toolbox.canDo('reverseDirection')}"
+ alpha="{toolbox.getAlpha('reverseDirection')}"
width="28" height="28" textAlign="left" paddingLeft="8" paddingRight="0" />
<mx:Button icon="@Embed('embedded/cut.svg')"
click='toolbox.doSplit();'
+ enabled="{toolbox.canDo('split')}"
+ alpha="{toolbox.getAlpha('split')}"
width="28" height="28" textAlign="left" paddingLeft="8" paddingRight="0" />
<mx:Button icon="@Embed('embedded/straighten.svg')"
click='toolbox.doStraighten();'
+ enabled="{toolbox.canDo('straighten')}"
+ alpha="{toolbox.getAlpha('straighten')}"
width="28" height="28" textAlign="left" paddingLeft="5" paddingRight="0" />
<mx:Button icon="@Embed('embedded/circle.svg')"
click='toolbox.doCircularise();'
+ enabled="{toolbox.canDo('circularise')}"
+ alpha="{toolbox.getAlpha('circularise')}"
width="28" height="28" textAlign="left" paddingLeft="4" paddingRight="0" />
<mx:Button icon="@Embed('embedded/quadrilateralise.svg')"
click='toolbox.doQuadrilateralise();'
+ enabled="{toolbox.canDo('quadrilateralise')}"
+ alpha="{toolbox.getAlpha('quadrilateralise')}"
width="28" height="28" textAlign="left" paddingLeft="6" paddingRight="0" />
<mx:Button icon="@Embed('embedded/parallel.svg')"
click='toolbox.doParallelise();'
+ enabled="{toolbox.canDo('parallelise')}"
+ alpha="{toolbox.getAlpha('parallelise')}"
width="28" height="28" textAlign="left" paddingLeft="8" paddingRight="0" />
</potlatch2:Toolbox>