Reinstate shift-click to alter way geometry
authorRichard Fairhurst <richard@systemeD.net>
Sun, 19 Mar 2017 19:29:48 +0000 (19:29 +0000)
committerRichard Fairhurst <richard@systemeD.net>
Sun, 19 Mar 2017 19:29:48 +0000 (19:29 +0000)
net/systemeD/potlatch2/controller/ControllerState.as
net/systemeD/potlatch2/controller/SelectedWay.as
net/systemeD/potlatch2/controller/SelectedWayNode.as
net/systemeD/potlatch2/controller/ZoomArea.as

index a2c7de4..bf3c5e3 100644 (file)
@@ -66,6 +66,9 @@ package net.systemeD.potlatch2.controller {
         */
         public function exitState(newState:ControllerState):void {}
 
+               /** Mark that the state should process a shift-click on entry (because ZoomArea rejected it). */
+               public function handleShiftClickOnEntry(event:MouseEvent):void {}
+
                /** Represent the state in text for debugging. */
                public function toString():String {
                        return "(No state)";
index 8c5e5ec..06af28b 100644 (file)
@@ -16,7 +16,8 @@ package net.systemeD.potlatch2.controller {
         private var clicked:Point;             // did the user enter this state by clicking at a particular point?
                private var wayList:Array;              // list of ways to cycle through with '/' keypress
                private var initIndex: int;     // index of last selected node if entered from SelectedWayNode
-        
+               private var shiftClickEvent:MouseEvent; // shift-click event if rejected by ZoomArea
+
         /** 
         * @param way The way that is now selected.
         * @param point The location that was clicked.
@@ -29,6 +30,10 @@ package net.systemeD.potlatch2.controller {
                        initIndex=index;
         }
 
+               override public function handleShiftClickOnEntry(event:MouseEvent):void {
+                       shiftClickEvent=event;
+               }
+
         private function updateSelectionUI(e:Event):void {
             controller.updateSelectionUIWithoutTagChange();
         }
@@ -62,14 +67,6 @@ package net.systemeD.potlatch2.controller {
                                // shift-clicked POI node to insert it
                                Way(firstSelected).insertNodeAtClosestPosition(Node(entity), false, MainUndoStack.getGlobalStack().addAction);
                                return this;
-                       } else if ( event.type == MouseEvent.MOUSE_UP && !entity && event.shiftKey ) {
-                               // shift-clicked nearby to insert node
-                               var lat:Number = controller.map.coord2lat(event.localY);
-                               var lon:Number = controller.map.coord2lon(event.localX);
-                               var undo:CompositeUndoableAction = new CompositeUndoableAction("Insert node");
-                               Way(firstSelected).insertNodeOrMoveExisting(lat, lon, undo.push);
-                               MainUndoStack.getGlobalStack().addAction(undo);
-                               return this;
                        } else if ( event.type == MouseEvent.MOUSE_DOWN && event.ctrlKey && !event.altKey && entity && entity!=firstSelected && paint.interactive) {
                                // multiple selection
                                return new SelectedMultiple([firstSelected,entity],layer);
@@ -132,6 +129,15 @@ package net.systemeD.potlatch2.controller {
 
         /** Officially enter this state by marking the previously nominated way as selected. */
         override public function enterState():void {
+                       if (shiftClickEvent) {
+                               // previously shift-clicked nearby to insert node, passed through by ZoomArea
+                               var lat:Number = controller.map.coord2lat(shiftClickEvent.localY);
+                               var lon:Number = controller.map.coord2lon(shiftClickEvent.localX);
+                               var undo:CompositeUndoableAction = new CompositeUndoableAction("Insert node");
+                               initWay.insertNodeOrMoveExisting(lat, lon, undo.push);
+                               MainUndoStack.getGlobalStack().addAction(undo);
+                               shiftClickEvent = null;
+                       }
             if (firstSelected!=initWay) {
                    clearSelection(this);
                    layer.setHighlight(initWay, { selected: true, hover: false });
index 920934b..2c94a0a 100644 (file)
@@ -13,12 +13,17 @@ package net.systemeD.potlatch2.controller {
                private var parentWay:Way;
                private var initIndex:int;
                private var selectedIndex:int;
+               private var shiftClickEvent:MouseEvent;
         
         public function SelectedWayNode(way:Way,index:int) {
             parentWay = way;
                        initIndex = index;
         }
+
+               override public function handleShiftClickOnEntry(event:MouseEvent):void {
+                       shiftClickEvent=event;
+               }
+
         protected function selectNode(way:Way,index:int):void {
                        var node:Node=way.getNode(index);
             if ( way == parentWay && node == firstSelected )
@@ -117,6 +122,15 @@ package net.systemeD.potlatch2.controller {
                }
 
                override public function enterState():void {
+                       if (shiftClickEvent) {
+                               // previously shift-clicked nearby to insert node, passed through by ZoomArea
+                               var lat:Number = controller.map.coord2lat(shiftClickEvent.localY);
+                               var lon:Number = controller.map.coord2lon(shiftClickEvent.localX);
+                               var undo:CompositeUndoableAction = new CompositeUndoableAction("Insert node");
+                               parentWay.insertNodeOrMoveExisting(lat, lon, undo.push);
+                               MainUndoStack.getGlobalStack().addAction(undo);
+                               shiftClickEvent = null;
+                       }
             selectNode(parentWay,initIndex);
                        layer.setPurgable(selection,false);
         }
index 8189dd8..1d86832 100644 (file)
@@ -47,8 +47,11 @@ package net.systemeD.potlatch2.controller {
                                                z++; w/=2; h/=2;
                                        } while (left>=(lon-w/2) && right<=(lon+w/2) && bottom>=(lat-h/2) && top<=(lat+h/2) && z<controller.map.MAXSCALE);
                                        controller.map.moveMapFromLatLonScale(lat,lon,z-1);
+                                       return previousState;
+                               } else {
+                                       previousState.handleShiftClickOnEntry(event);
+                                       return previousState;
                                }
-                       return previousState;
                        }
             return this;
         }