selected background node
authorAndy Allan <andy@gravitystorm.co.uk>
Fri, 10 Jun 2011 16:54:55 +0000 (17:54 +0100)
committerAndy Allan <andy@gravitystorm.co.uk>
Fri, 10 Jun 2011 16:54:55 +0000 (17:54 +0100)
net/systemeD/potlatch2/controller/ControllerState.as
net/systemeD/potlatch2/controller/SelectedBackgroundNode.as [new file with mode: 0644]

index 0aeddaa..e7641c3 100644 (file)
@@ -96,7 +96,7 @@ package net.systemeD.potlatch2.controller {
                        if ( paint && paint.isBackground ) {
                 if ( event.type == MouseEvent.MOUSE_DOWN && entity.connection is SnapshotConnection) {
                     if (entity is Way) { return new SelectedBackgroundWay(entity as Way); }
-                    else if (entity is Node) { return new SelectedPOINode(entity as Node); }
+                    else if (entity is Node) { return new SelectedBackgroundNode(entity as Node, paint); }
                 } else if ( event.type == MouseEvent.MOUSE_DOWN && ((event.shiftKey && event.ctrlKey) || event.altKey) ) {
                                        // alt-click to pull data out of vector background layer
                                        var newEntity:Entity=paint.pullThrough(entity,editableLayer);
diff --git a/net/systemeD/potlatch2/controller/SelectedBackgroundNode.as b/net/systemeD/potlatch2/controller/SelectedBackgroundNode.as
new file mode 100644 (file)
index 0000000..a125a7b
--- /dev/null
@@ -0,0 +1,69 @@
+package net.systemeD.potlatch2.controller {
+       import flash.events.*;
+       import flash.ui.Keyboard;
+    import net.systemeD.potlatch2.EditController;
+    import net.systemeD.halcyon.connection.*;
+    import net.systemeD.halcyon.MapPaint;
+
+    public class SelectedBackgroundNode extends ControllerState {
+        protected var initNode:Node;
+        protected var layer:MapPaint;
+
+        public function SelectedBackgroundNode(node:Node, layer:MapPaint) {
+            initNode = node;
+            this.layer = layer;
+        }
+
+        protected function selectNode(node:Node):void {
+            if ( firstSelected is Node && Node(firstSelected)==node )
+                return;
+
+            clearSelection(this);
+            editableLayer.setHighlight(node, { selected: true });
+            selection = [node];
+            controller.updateSelectionUI(layer);
+            initNode = node;
+        }
+
+        protected function clearSelection(newState:ControllerState):void {
+            if ( selectCount ) {
+                editableLayer.setHighlight(firstSelected, { selected: false });
+                selection = [];
+                if (!newState.isSelectionState()) { controller.updateSelectionUI(); }
+            }
+        }
+
+        override public function processMouseEvent(event:MouseEvent, entity:Entity):ControllerState {
+                       if (event.type==MouseEvent.MOUSE_MOVE) { return this; }
+            if (event.type==MouseEvent.MOUSE_UP) { return this; }
+                       var cs:ControllerState = sharedMouseEvents(event, entity);
+                       return cs ? cs : this;
+        }
+
+               override public function processKeyboardEvent(event:KeyboardEvent):ControllerState {
+                       switch (event.keyCode) {
+                       }
+                       var cs:ControllerState = sharedKeyboardEvents(event);
+                       return cs ? cs : this;
+               }
+
+               public function deletePOI():ControllerState {
+                       return new NoSelection();
+               }
+
+        override public function enterState():void {
+            selectNode(initNode);
+                       editableLayer.setPurgable(selection,false);
+        }
+
+        override public function exitState(newState:ControllerState):void {
+                       editableLayer.setPurgable(selection,true);
+            clearSelection(newState);
+        }
+
+        override public function toString():String {
+            return "SelectedBackgroundNode";
+        }
+
+    }
+}