Improve selection for background objects and tidy ControllerState layer handling
authorRichard Fairhurst <richard@systemeD.net>
Wed, 15 Jun 2011 20:29:43 +0000 (21:29 +0100)
committerRichard Fairhurst <richard@systemeD.net>
Wed, 15 Jun 2011 20:29:43 +0000 (21:29 +0100)
18 files changed:
net/systemeD/halcyon/Map.as
net/systemeD/halcyon/WayUI.as
net/systemeD/potlatch2/controller/ControllerState.as
net/systemeD/potlatch2/controller/DragSelection.as
net/systemeD/potlatch2/controller/DragWayNode.as
net/systemeD/potlatch2/controller/DrawWay.as
net/systemeD/potlatch2/controller/NoSelection.as
net/systemeD/potlatch2/controller/SelectArea.as
net/systemeD/potlatch2/controller/SelectedBackgroundNode.as
net/systemeD/potlatch2/controller/SelectedBackgroundWay.as
net/systemeD/potlatch2/controller/SelectedMarker.as
net/systemeD/potlatch2/controller/SelectedMultiple.as
net/systemeD/potlatch2/controller/SelectedPOINode.as
net/systemeD/potlatch2/controller/SelectedParallelWay.as
net/systemeD/potlatch2/controller/SelectedWay.as
net/systemeD/potlatch2/controller/SelectedWayNode.as
net/systemeD/potlatch2/utils/ShpImporter.as
resources/stylesheets/core_interactive.css

index b65ac7a..1377d44 100644 (file)
@@ -245,7 +245,7 @@ package net.systemeD.halcyon {
                
                public function addLayer(connection:Connection, styleurl:String, backgroundlayer:Boolean=true, interactive:Boolean=false):MapPaint {
                        var paint:MapPaint=new MapPaint(this, connection, styleurl, -5, 5);
-                       paintContainer.addChild(paint);
+                       paintContainer.addChildAt(paint,0);
                        paint.isBackground=backgroundlayer;
                        paint.interactive=interactive;
                        return paint;
index fdec4d4..787385f 100644 (file)
@@ -231,6 +231,7 @@ package net.systemeD.halcyon {
             // Copy tags object, and add states
             var tags:Object = entity.getTagsCopy();
             setStateClass('area', Way(entity).isArea());
+            setStateClass('background', paint.isBackground);
             setStateClass('tiger', (entity.isUneditedTiger() && Globals.vars.highlightTiger));
             tags=applyStateClasses(tags);
                        if (entity.status) { tags['_status']=entity.status; }
index ad8ac7f..3c02e1b 100644 (file)
@@ -20,7 +20,7 @@ package net.systemeD.potlatch2.controller {
     public class ControllerState {
 
         protected var controller:EditController;
-               protected var editableLayer:MapPaint;
+               public var layer:MapPaint;
         protected var previousState:ControllerState;
 
                protected var _selection:Array=[];
@@ -28,8 +28,8 @@ package net.systemeD.potlatch2.controller {
         public function ControllerState() {}
 
         public function setController(controller:EditController):void {
-            this.controller = controller;
-                       editableLayer = controller.map.editableLayer;
+            this.controller=controller;
+            if (!layer) layer=controller.map.editableLayer;
         }
 
         public function setPreviousState(previousState:ControllerState):void {
@@ -72,6 +72,7 @@ package net.systemeD.potlatch2.controller {
                }
                /** Default behaviour for the current state that should be called if state-specific action has been taken care of or ruled out. */
                protected function sharedKeyboardEvents(event:KeyboardEvent):ControllerState {
+                       var editableLayer:MapPaint=controller.map.editableLayer;                                                                // shorthand for this method
                        switch (event.keyCode) {
                                case 66:        setSourceTag(); break;                                                                                                  // B - set source tag for current object
                                case 67:        editableLayer.connection.closeChangeset(); break;                                               // C - close changeset
@@ -93,22 +94,38 @@ package net.systemeD.potlatch2.controller {
                        var paint:MapPaint = getMapPaint(DisplayObject(event.target));
             var focus:Entity = getTopLevelFocusEntity(entity);
 
+                       if ( event.type == MouseEvent.MOUSE_UP && focus && map.dragstate!=map.NOT_DRAGGING) {
+                               map.mouseUpHandler();   // in case the end-drag is over an EntityUI
+                       } else if ( event.type == MouseEvent.ROLL_OVER && paint && paint.interactive ) {
+                               paint.setHighlight(focus, { hover: true });
+                       } else if ( event.type == MouseEvent.MOUSE_OUT && paint && paint.interactive ) {
+                               paint.setHighlight(focus, { hover: false });
+                       } else if ( event.type == MouseEvent.MOUSE_WHEEL ) {
+                               if      (event.delta > 0) { map.zoomIn(); }
+                               else if (event.delta < 0) { map.zoomOut(); }
+                       }
+
                        if ( paint && paint.isBackground ) {
                                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);
+                                       paint.setHighlight(entity, { hover:false, selected: false });
+                                       if (entity is Way) paint.setHighlightOnNodes(Way(entity), { selectedway: false });
+                                       var newEntity:Entity=paint.pullThrough(entity,controller.map.editableLayer);
                                        if      (entity is Way ) { return new SelectedWay(newEntity as Way); }
                                        else if (entity is Node) { return new SelectedPOINode(newEntity as Node); }
-                } else if (event.type == MouseEvent.MOUSE_DOWN && paint.interactive) {
-                    if      (entity is Way   ) { return new SelectedBackgroundWay(entity as Way); }
-                    else if (entity is Node  ) { return new SelectedBackgroundNode(entity as Node, paint); }
+                               } else if (!paint.interactive) {
+                                       return null;
+                               } else if (event.type == MouseEvent.MOUSE_DOWN && paint.interactive) {
+                                       if      (entity is Way   ) { return new SelectedBackgroundWay(entity as Way, paint); }
+                                       else if (entity is Node  ) { return new SelectedBackgroundNode(entity as Node, paint); }
                                        else if (entity is Marker) { return new SelectedMarker(entity as Marker, paint); }
-                               } else if ( event.type == MouseEvent.MOUSE_UP ) {
+                               } else if ( event.type == MouseEvent.MOUSE_UP) {
                                        return (this is NoSelection) ? null : new NoSelection();
-                               } else { return null; }
-                       }
-
-                       if ( event.type == MouseEvent.MOUSE_DOWN ) {
+                               } else if ( event.type == MouseEvent.CLICK && focus == null && map.dragstate!=map.DRAGGING) {
+                                       return (this is NoSelection) ? null : new NoSelection();
+                               }
+                                       
+                       } else if ( event.type == MouseEvent.MOUSE_DOWN ) {
                                if ( entity is Node && selectedWay && entity.hasParent(selectedWay) ) {
                                        // select node within this way
                        return new DragWayNode(selectedWay,  getNodeIndex(selectedWay,entity as Node),  event, false);
@@ -125,30 +142,9 @@ package net.systemeD.potlatch2.controller {
                                } else if (event.ctrlKey) {
                                        return new SelectArea(event.localX,event.localY);
                                }
-            } else if ( event.type == MouseEvent.CLICK && focus == null && map.dragstate!=map.DRAGGING && this is SelectedMarker) {
-                // this is identical to the below, but needed for unselecting markers on vector background layers.
-                // Deselecting a POI or way on the main layer emits both CLICK and MOUSE_UP, but markers only CLICK
-                // I'll leave it to someone who understands to decide whether they are the same thing and should be
-                // combined with a (CLICK || MOUSE_UP)
-                
-                // "&& this is SelectedMarker" added by Steve Bennett. The CLICK event being processed for SelectedWay state
-                // causes way to get unselected...so restrict the double processing as much as possible.  
-                
+
+            } else if ( (event.type==MouseEvent.CLICK || event.type==MouseEvent.MOUSE_UP) && focus == null && map.dragstate!=map.DRAGGING) {
                 return (this is NoSelection) ? null : new NoSelection();
-                       } else if ( event.type == MouseEvent.MOUSE_UP && focus == null && map.dragstate!=map.DRAGGING) {
-                               return (this is NoSelection) ? null : new NoSelection();
-                       } else if ( event.type == MouseEvent.MOUSE_UP && focus && map.dragstate!=map.NOT_DRAGGING) {
-                               map.mouseUpHandler();   // in case the end-drag is over an EntityUI
-                       } else if ( event.type == MouseEvent.ROLL_OVER ) {
-                               editableLayer.setHighlight(focus, { hover: true });
-                       } else if ( event.type == MouseEvent.MOUSE_OUT ) {
-                               editableLayer.setHighlight(focus, { hover: false });
-            } else if ( event.type == MouseEvent.MOUSE_WHEEL ) {
-                if (event.delta > 0) {
-                  map.zoomIn();
-                } else if (event.delta < 0) {
-                  map.zoomOut();
-                }
             }
                        return null;
                }
index 739180e..6f583f6 100644 (file)
@@ -95,14 +95,14 @@ package net.systemeD.potlatch2.controller {
         /** Highlight the dragged selection. */
         override public function enterState():void {
                        for each (var entity:Entity in selection) {
-                               editableLayer.setHighlight(entity, { selected: true });
+                               layer.setHighlight(entity, { selected: true });
                        }
         }
         
         /** Un-highlight the dragged selection. */
         override public function exitState(newState:ControllerState):void {
                        for each (var entity:Entity in selection) {
-                               editableLayer.setHighlight(entity, { selected: false });
+                               layer.setHighlight(entity, { selected: false });
                        }
         }
         /** "DragSelection" */
index 3625b17..b8c7911 100644 (file)
@@ -33,7 +33,7 @@ package net.systemeD.potlatch2.controller {
         }
 
         private function addNode(selectedWay:Way,event:MouseEvent):int {
-                       var ways:Array = editableLayer.findWaysAtPoint(event.stageX, event.stageY, selectedWay);
+                       var ways:Array = layer.findWaysAtPoint(event.stageX, event.stageY, selectedWay);
             var lat:Number = controller.map.coord2lat(event.localY);
             var lon:Number = controller.map.coord2lon(event.localX);
             var undo:CompositeUndoableAction = new CompositeUndoableAction("Insert node");
@@ -109,17 +109,17 @@ package net.systemeD.potlatch2.controller {
                        originalLat = draggingNode.lat;
                        originalLon = draggingNode.lon;
 
-                       editableLayer.setHighlightOnNodes(parentWay, { selectedway: true } );
-                       editableLayer.limitWayDrawing(parentWay, draggingIndex);
-                       editableLayer.setHighlight(draggingNode, { selected: true } );
-                       editableLayer.protectWay(parentWay);
-                       editableLayer.limitWayDrawing(parentWay, NaN, draggingIndex);
+                       layer.setHighlightOnNodes(parentWay, { selectedway: true } );
+                       layer.limitWayDrawing(parentWay, draggingIndex);
+                       layer.setHighlight(draggingNode, { selected: true } );
+                       layer.protectWay(parentWay);
+                       layer.limitWayDrawing(parentWay, NaN, draggingIndex);
         }
         override public function exitState(newState:ControllerState):void {
-                       editableLayer.unprotectWay(parentWay);
-                       editableLayer.limitWayDrawing(parentWay);
-                       editableLayer.setHighlightOnNodes(parentWay, { selectedway: false } );
-                       editableLayer.setHighlight(draggingNode, { selected: false } );
+                       layer.unprotectWay(parentWay);
+                       layer.limitWayDrawing(parentWay);
+                       layer.setHighlightOnNodes(parentWay, { selectedway: false } );
+                       layer.setHighlight(draggingNode, { selected: false } );
         }
         override public function toString():String {
             return "DragWayNode";
index 84a9549..1984ece 100644 (file)
@@ -43,8 +43,8 @@ package net.systemeD.potlatch2.controller {
                 controller.map.mouseUpHandler(); // in case you're still in the drag-tolerance zone, and mouse up over something.
                                if ( entity == null || isBackground ) { // didn't hit anything: extend the way by one node.
                                        node = createAndAddNode(event, MainUndoStack.getGlobalStack().addAction);
-                    editableLayer.setHighlight(node, { selectedway: true });
-                    editableLayer.setPurgable([node], false);
+                    layer.setHighlight(node, { selectedway: true });
+                    layer.setPurgable([node], false);
                                        resetElastic(node);
                                        lastClick=node;
                                        controller.updateSelectionUIWithoutTagChange();
@@ -56,7 +56,7 @@ package net.systemeD.potlatch2.controller {
                             MainUndoStack.getGlobalStack().undo(); // undo the BeginWayAction that (presumably?) just happened
                             
                             var newPoiAction:CreatePOIAction = new CreatePOIAction(
-                                                               editableLayer.connection,
+                                                               layer.connection,
                                                                {},
                                                                controller.map.coord2lat(event.localY),
                                                                controller.map.coord2lon(event.localX));
@@ -76,9 +76,9 @@ package net.systemeD.potlatch2.controller {
                                                // hit a node, add it to this way and carry on
                                                appendNode(entity as Node, MainUndoStack.getGlobalStack().addAction);
                                                if (focus is Way) {
-                          editableLayer.setHighlightOnNodes(focus as Way, { hoverway: false });
+                          layer.setHighlightOnNodes(focus as Way, { hoverway: false });
                         }
-                                               editableLayer.setHighlight(entity, { selectedway: true });
+                                               layer.setHighlight(entity, { selectedway: true });
                                                resetElastic(entity as Node);
                                                lastClick=entity;
                                                if (Way(firstSelected).getNode(0)==Way(firstSelected).getLastNode()) {
@@ -102,13 +102,13 @@ package net.systemeD.potlatch2.controller {
                         node = createAndAddNode(event, jnct.push);
                         Way(entity).insertNodeAtClosestPosition(node, true, jnct.push);
                         MainUndoStack.getGlobalStack().addAction(jnct);
-                        editableLayer.setHighlight(node, { selectedway: true });
-                        editableLayer.setPurgable([node], false);
+                        layer.setHighlight(node, { selectedway: true });
+                        layer.setPurgable([node], false);
                                        }
                                        resetElastic(node);
                                        lastClick=node;
-                                       editableLayer.setHighlightOnNodes(entity as Way, { hoverway: false });
-                                       editableLayer.setHighlightOnNodes(firstSelected as Way, { selectedway: true });
+                                       layer.setHighlightOnNodes(entity as Way, { hoverway: false });
+                                       layer.setHighlightOnNodes(firstSelected as Way, { selectedway: true });
                                }
                                lastClickTime=new Date();
                        } else if ( event.type == MouseEvent.MOUSE_MOVE && elastic ) {
@@ -122,7 +122,7 @@ package net.systemeD.potlatch2.controller {
                                if (focus is Way && focus!=firstSelected) {
                                        // floating over another way, highlight its nodes
                                        hoverEntity=focus;
-                                       editableLayer.setHighlightOnNodes(focus as Way, { hoverway: true });
+                                       layer.setHighlightOnNodes(focus as Way, { hoverway: true });
                                }
                                // set cursor depending on whether we're floating over the start of this way, 
                                // another random node, a possible junction...
@@ -137,7 +137,7 @@ package net.systemeD.potlatch2.controller {
                        } else if ( event.type == MouseEvent.MOUSE_OUT && !isBackground ) {
                                if (focus is Way && entity!=firstSelected) {
                                        hoverEntity=null;
-                                       editableLayer.setHighlightOnNodes(focus as Way, { hoverway: false });
+                                       layer.setHighlightOnNodes(focus as Way, { hoverway: false });
                                        // ** We could do with an optional way of calling WayUI.redraw to only do the nodes, which would be a
                                        // useful optimisation.
                                }
@@ -195,7 +195,7 @@ package net.systemeD.potlatch2.controller {
                
                protected function stopDrawing():ControllerState {
                        if ( hoverEntity ) {
-                               editableLayer.setHighlightOnNodes(hoverEntity as Way, { hoverway: false });
+                               layer.setHighlightOnNodes(hoverEntity as Way, { hoverway: false });
                                hoverEntity = null;
                        }
 
@@ -244,7 +244,7 @@ package net.systemeD.potlatch2.controller {
                        }
                        // Only actually delete the node if it has no other tags, and is not part of other ways (or part of this way twice)
                        if (node.numParentWays==1 && Way(firstSelected).hasOnceOnly(node) && !node.hasInterestingTags()) {
-                               editableLayer.setPurgable([node], true);
+                               layer.setPurgable([node], true);
                                node.connection.unregisterPOI(node);
                                node.remove(undo.push);
                        }
@@ -261,7 +261,7 @@ package net.systemeD.potlatch2.controller {
             performAction(undo);
 
             if(!node.isDeleted()) { // i.e. was junction with another way (or is now POI)
-              editableLayer.setHighlight(node, {selectedway: false});
+              layer.setHighlight(node, {selectedway: false});
             }
             return state;
                }
@@ -310,7 +310,7 @@ package net.systemeD.potlatch2.controller {
                        appendNode(nextNode as Node, MainUndoStack.getGlobalStack().addAction);
                        resetElastic(nextNode as Node);
                        lastClick=nextNode;
-                       editableLayer.setHighlight(nextNode, { selectedway: true });
+                       layer.setHighlight(nextNode, { selectedway: true });
 
                        // recentre the map if the new lat/lon is offscreen
                        controller.map.scrollIfNeeded(nextNode.lat,nextNode.lon);
index 5c5f880..5c5072d 100644 (file)
@@ -26,7 +26,7 @@ package net.systemeD.potlatch2.controller {
                        if (event.type==MouseEvent.MOUSE_UP && (focus==null || (paint && paint.isBackground)) && map.dragstate!=map.DRAGGING) {
                                map.dragstate=map.NOT_DRAGGING;
                                var undo:CompositeUndoableAction = new BeginWayAction();
-                               var conn:Connection = editableLayer.connection;
+                               var conn:Connection = layer.connection;
                                var startNode:Node = conn.createNode(
                                        {}, 
                                        controller.map.coord2lat(event.localY),
index 73cb2fc..1a0ad60 100644 (file)
@@ -34,7 +34,7 @@ package net.systemeD.potlatch2.controller {
                                var right:Number=controller.map.coord2lon(endX);
                                var top:Number=controller.map.coord2lat(startY);
                                var bottom:Number=controller.map.coord2lat(endY);
-                               var entities:Object=editableLayer.connection.getObjectsByBbox(left,right,top,bottom);
+                               var entities:Object=layer.connection.getObjectsByBbox(left,right,top,bottom);
                                for each (var way:Way  in entities.waysInside) { if (way.intersects(left,right,top,bottom)) toggleSelection(way); }
                                for each (var poi:Node in entities.poisInside) { toggleSelection(poi); }
                                return controller.findStateForSelection(selection);
@@ -51,7 +51,7 @@ package net.systemeD.potlatch2.controller {
                
                override public function enterState():void {
                        box=new Shape();
-                       var l:DisplayObject=editableLayer.getPaintSpriteAt(editableLayer.maxlayer);
+                       var l:DisplayObject=layer.getPaintSpriteAt(layer.maxlayer);
                        var o:DisplayObject=Sprite(l).getChildAt(3);
                        (o as Sprite).addChild(box);
                        controller.map.draggable=false;
index a125a7b..33ab41c 100644 (file)
@@ -7,7 +7,6 @@ package net.systemeD.potlatch2.controller {
 
     public class SelectedBackgroundNode extends ControllerState {
         protected var initNode:Node;
-        protected var layer:MapPaint;
 
         public function SelectedBackgroundNode(node:Node, layer:MapPaint) {
             initNode = node;
@@ -19,7 +18,7 @@ package net.systemeD.potlatch2.controller {
                 return;
 
             clearSelection(this);
-            editableLayer.setHighlight(node, { selected: true });
+            layer.setHighlight(node, { selected: true });
             selection = [node];
             controller.updateSelectionUI(layer);
             initNode = node;
@@ -27,7 +26,7 @@ package net.systemeD.potlatch2.controller {
 
         protected function clearSelection(newState:ControllerState):void {
             if ( selectCount ) {
-                editableLayer.setHighlight(firstSelected, { selected: false });
+                layer.setHighlight(firstSelected, { selected: false });
                 selection = [];
                 if (!newState.isSelectionState()) { controller.updateSelectionUI(); }
             }
@@ -53,11 +52,11 @@ package net.systemeD.potlatch2.controller {
 
         override public function enterState():void {
             selectNode(initNode);
-                       editableLayer.setPurgable(selection,false);
+                       layer.setPurgable(selection,false);
         }
 
         override public function exitState(newState:ControllerState):void {
-                       editableLayer.setPurgable(selection,true);
+                       layer.setPurgable(selection,true);
             clearSelection(newState);
         }
 
index 934010c..6ce097f 100644 (file)
@@ -5,8 +5,7 @@ package net.systemeD.potlatch2.controller {
        
        import net.systemeD.halcyon.WayUI;
        import net.systemeD.halcyon.connection.*;
-       import net.systemeD.potlatch2.tools.Quadrilateralise;
-       import net.systemeD.potlatch2.tools.Simplify;
+    import net.systemeD.halcyon.MapPaint;
 
     /** Behaviour that takes place while a way is selected includes: adding a node to the way, straightening/reshaping the way, dragging it. */
     public class SelectedBackgroundWay extends ControllerState {
@@ -20,11 +19,12 @@ package net.systemeD.potlatch2.controller {
         * @param way The way that is now selected.
         * @param point The location that was clicked.
         * @param ways An ordered list of ways sharing a node, to make "way cycling" work. */
-        public function SelectedBackgroundWay(way:Way, point:Point=null, ways:Array=null, index:int=0) {
+        public function SelectedBackgroundWay(way:Way, layer:MapPaint, point:Point=null, ways:Array=null, index:int=0) {
             initWay = way;
                        clicked = point;
                        wayList = ways;
                        initIndex=index;
+                       this.layer = layer;
         }
 
         private function updateSelectionUI(e:Event):void {
@@ -34,8 +34,8 @@ package net.systemeD.potlatch2.controller {
         /** Tidy up UI as we transition to a new state without the current selection. */
         protected function clearSelection(newState:ControllerState):void {
             if ( selectCount ) {
-               editableLayer.setHighlight(firstSelected, { selected: false, hover: false });
-               editableLayer.setHighlightOnNodes(firstSelected as Way, { selectedway: false });
+               layer.setHighlight(firstSelected, { selected: false, hover: false });
+               layer.setHighlightOnNodes(firstSelected as Way, { selectedway: false });
                 selection = [];
                 if (!newState.isSelectionState()) { controller.updateSelectionUI(); }
             }
@@ -63,17 +63,17 @@ package net.systemeD.potlatch2.controller {
         override public function enterState():void {
             if (firstSelected!=initWay) {
                 clearSelection(this);
-                editableLayer.setHighlight(initWay, { selected: true, hover: false });
-                   editableLayer.setHighlightOnNodes(initWay, { selectedway: true });
+                layer.setHighlight(initWay, { selected: true, hover: false });
+                   layer.setHighlightOnNodes(initWay, { selectedway: true });
                    selection = [initWay];
                    controller.updateSelectionUI();
                        }
-                       editableLayer.setPurgable(selection,false);
+                       layer.setPurgable(selection,false);
         }
         
         /** Officially leave the state */
         override public function exitState(newState:ControllerState):void {
-            editableLayer.setPurgable(selection,true);
+            layer.setPurgable(selection,true);
             clearSelection(newState);
         }
 
index 9f9aeca..2af2441 100644 (file)
@@ -7,7 +7,6 @@ package net.systemeD.potlatch2.controller {
 
     public class SelectedMarker extends ControllerState {
         protected var initMarker:Marker;
-        protected var layer:MapPaint;
 
         public function SelectedMarker(marker:Marker, layer:MapPaint) {
             initMarker = marker;
@@ -19,7 +18,7 @@ package net.systemeD.potlatch2.controller {
                 return;
 
             clearSelection(this);
-            editableLayer.setHighlight(marker, { selected: true });
+            layer.setHighlight(marker, { selected: true });
             selection = [marker];
             controller.updateSelectionUI(layer);
             initMarker = marker;
@@ -27,7 +26,7 @@ package net.systemeD.potlatch2.controller {
 
         protected function clearSelection(newState:ControllerState):void {
             if ( selectCount ) {
-                editableLayer.setHighlight(firstSelected, { selected: false });
+                layer.setHighlight(firstSelected, { selected: false });
                 selection = [];
                 if (!newState.isSelectionState()) { controller.updateSelectionUI(); }
             }
@@ -53,11 +52,11 @@ package net.systemeD.potlatch2.controller {
 
         override public function enterState():void {
             selectMarker(initMarker);
-                       editableLayer.setPurgable(selection,false);
+                       layer.setPurgable(selection,false);
         }
 
         override public function exitState(newState:ControllerState):void {
-                       editableLayer.setPurgable(selection,true);
+                       layer.setPurgable(selection,true);
             clearSelection(newState);
         }
 
index aa89551..3b0a012 100644 (file)
@@ -19,7 +19,7 @@ package net.systemeD.potlatch2.controller {
 
                        if ( event.type == MouseEvent.MOUSE_DOWN && entity && event.ctrlKey ) {
                                // modify selection
-                               editableLayer.setHighlight(entity, { selected: toggleSelection(entity) });
+                               layer.setHighlight(entity, { selected: toggleSelection(entity) });
                                controller.updateSelectionUI();
 
                                if (selectCount>1) { return this; }
@@ -110,16 +110,16 @@ package net.systemeD.potlatch2.controller {
                override public function enterState():void {
                        selection=initSelection.concat();
                        for each (var entity:Entity in selection) {
-                               editableLayer.setHighlight(entity, { selected: true, hover: false });
+                               layer.setHighlight(entity, { selected: true, hover: false });
                        }
                        controller.updateSelectionUI();
-                       editableLayer.setPurgable(selection,false);
+                       layer.setPurgable(selection,false);
                }
 
                override public function exitState(newState:ControllerState):void {
-                       editableLayer.setPurgable(selection,true);
+                       layer.setPurgable(selection,true);
                        for each (var entity:Entity in selection) {
-                               editableLayer.setHighlight(entity, { selected: false, hover: false });
+                               layer.setHighlight(entity, { selected: false, hover: false });
                        }
                        selection = [];
                        if (!newState.isSelectionState()) { controller.updateSelectionUI(); }
index 2710dc9..2e6af17 100644 (file)
@@ -16,7 +16,7 @@ package net.systemeD.potlatch2.controller {
                 return;
 
             clearSelection(this);
-            editableLayer.setHighlight(node, { selected: true });
+            layer.setHighlight(node, { selected: true });
             selection = [node];
             controller.updateSelectionUI();
             initNode = node;
@@ -24,7 +24,7 @@ package net.systemeD.potlatch2.controller {
                 
         protected function clearSelection(newState:ControllerState):void {
             if ( selectCount ) {
-                editableLayer.setHighlight(firstSelected, { selected: false });
+                layer.setHighlight(firstSelected, { selected: false });
                 selection = [];
                 if (!newState.isSelectionState()) { controller.updateSelectionUI(); }
             }
@@ -60,13 +60,13 @@ package net.systemeD.potlatch2.controller {
 
         override public function enterState():void {
             selectNode(initNode);
-                       editableLayer.setPurgable(selection,false);
+                       layer.setPurgable(selection,false);
         }
         override public function exitState(newState:ControllerState):void {
             if(firstSelected.hasTags()) {
               controller.clipboards['node']=firstSelected.getTagsCopy();
             }
-                       editableLayer.setPurgable(selection,true);
+                       layer.setPurgable(selection,true);
             clearSelection(newState);
         }
 
index 1324af1..dc35494 100644 (file)
@@ -76,7 +76,7 @@ package net.systemeD.potlatch2.controller {
                /** Creates the WayUI for the parallel way. */
                override public function enterState():void {
                        selection=[parallelise.parallelWay];
-                       editableLayer.createWayUI(firstSelected as Way);
+                       layer.createWayUI(firstSelected as Way);
                        startlon =controller.map.coord2lon(controller.map.mouseX);
                        startlatp=controller.map.coord2latp(controller.map.mouseY);
         }
index 1c15243..fd978be 100644 (file)
@@ -33,8 +33,8 @@ package net.systemeD.potlatch2.controller {
         /** Tidy up UI as we transition to a new state without the current selection. */
         protected function clearSelection(newState:ControllerState):void {
             if ( selectCount ) {
-               editableLayer.setHighlight(firstSelected, { selected: false, hover: false });
-               editableLayer.setHighlightOnNodes(firstSelected as Way, { selectedway: false });
+               layer.setHighlight(firstSelected, { selected: false, hover: false });
+               layer.setHighlightOnNodes(firstSelected as Way, { selectedway: false });
                 selection = [];
                 if (!newState.isSelectionState()) { controller.updateSelectionUI(); }
             }
@@ -85,7 +85,7 @@ package net.systemeD.potlatch2.controller {
                        if (!clicked || (wayList && wayList.length<2)) { return this; }
 
                        if (!wayList) {
-                               wayList=[initWay].concat(editableLayer.findWaysAtPoint(clicked.x,clicked.y,initWay));
+                               wayList=[initWay].concat(layer.findWaysAtPoint(clicked.x,clicked.y,initWay));
                        }
                        wayList=wayList.slice(1).concat(wayList[0]);
                        // Find the new way's index of the currently "selected" node, to facilitate keyboard navigation
@@ -95,7 +95,7 @@ package net.systemeD.potlatch2.controller {
 
                /** Perform deletion of currently selected way. */
                public function deleteWay():ControllerState {
-                       editableLayer.setHighlightOnNodes(firstSelected as Way, {selectedway: false});
+                       layer.setHighlightOnNodes(firstSelected as Way, {selectedway: false});
                        selectedWay.remove(MainUndoStack.getGlobalStack().addAction);
                        return new NoSelection();
                }
@@ -104,13 +104,13 @@ package net.systemeD.potlatch2.controller {
         override public function enterState():void {
             if (firstSelected!=initWay) {
                    clearSelection(this);
-                   editableLayer.setHighlight(initWay, { selected: true, hover: false });
-                   editableLayer.setHighlightOnNodes(initWay, { selectedway: true });
+                   layer.setHighlight(initWay, { selected: true, hover: false });
+                   layer.setHighlightOnNodes(initWay, { selectedway: true });
                    selection = [initWay];
                    controller.updateSelectionUI();
                    initWay.addEventListener(Connection.WAY_REORDERED, updateSelectionUI, false, 0, true);
                        }
-                       editableLayer.setPurgable(selection,false);
+                       layer.setPurgable(selection,false);
         }
         /** Officially leave the state, remembering the current way's tags for future repeats. */
         // TODO: tweak this so that repeat tags aren't remembered if you only select a way in order to branch off it. (a la PL1) 
@@ -118,7 +118,7 @@ package net.systemeD.potlatch2.controller {
                        if (firstSelected.hasTags()) {
               controller.clipboards['way']=firstSelected.getTagsCopy();
             }
-                       editableLayer.setPurgable(selection,true);
+                       layer.setPurgable(selection,true);
             firstSelected.removeEventListener(Connection.WAY_REORDERED, updateSelectionUI);
             clearSelection(newState);
         }
index fbe7cea..03ba21c 100644 (file)
@@ -25,9 +25,9 @@ package net.systemeD.potlatch2.controller {
                 return;
 
             clearSelection(this);
-            editableLayer.setHighlight(way, { hover: false });
-            editableLayer.setHighlight(node, { selected: true });
-            editableLayer.setHighlightOnNodes(way, { selectedway: true });
+            layer.setHighlight(way, { hover: false });
+            layer.setHighlight(node, { selected: true });
+            layer.setHighlightOnNodes(way, { selectedway: true });
             selection = [node]; parentWay = way;
             controller.updateSelectionUI();
                        selectedIndex = index; initIndex = index;
@@ -35,9 +35,9 @@ package net.systemeD.potlatch2.controller {
                 
         protected function clearSelection(newState:ControllerState):void {
             if ( selectCount ) {
-               editableLayer.setHighlight(parentWay, { selected: false });
-                               editableLayer.setHighlight(firstSelected, { selected: false });
-                               editableLayer.setHighlightOnNodes(parentWay, { selectedway: false });
+               layer.setHighlight(parentWay, { selected: false });
+                               layer.setHighlight(firstSelected, { selected: false });
+                               layer.setHighlightOnNodes(parentWay, { selectedway: false });
                                selection = [];
                 if (!newState.isSelectionState()) { controller.updateSelectionUI(); }
             }
@@ -106,13 +106,13 @@ package net.systemeD.potlatch2.controller {
 
                override public function enterState():void {
             selectNode(parentWay,initIndex);
-                       editableLayer.setPurgable(selection,false);
+                       layer.setPurgable(selection,false);
         }
                override public function exitState(newState:ControllerState):void {
             if (firstSelected.hasTags()) {
               controller.clipboards['node']=firstSelected.getTagsCopy();
             }
-                       editableLayer.setPurgable(selection,true);
+                       layer.setPurgable(selection,true);
             clearSelection(newState);
         }
 
@@ -146,8 +146,8 @@ package net.systemeD.potlatch2.controller {
                            if (parentWay.getLastNode() == n) { return this; }
                        }
 
-                       editableLayer.setHighlightOnNodes(parentWay, { selectedway: false } );
-                       editableLayer.setPurgable([parentWay],true);
+                       layer.setHighlightOnNodes(parentWay, { selectedway: false } );
+                       layer.setPurgable([parentWay],true);
             MainUndoStack.getGlobalStack().addAction(new SplitWayAction(parentWay, ni));
 
                        return new SelectedWay(parentWay);
@@ -162,7 +162,7 @@ package net.systemeD.potlatch2.controller {
                }
                
                public function deleteNode():ControllerState {
-                       editableLayer.setPurgable(selection,true);
+                       layer.setPurgable(selection,true);
                        firstSelected.remove(MainUndoStack.getGlobalStack().addAction);
                        return new SelectedWay(parentWay);
                }
@@ -182,7 +182,7 @@ package net.systemeD.potlatch2.controller {
 
             // First, look for POI nodes in 20x20 pixel box around the current node
                        // FIXME: why aren't we using a hitTest for this?
-            var hitnodes:Array = editableLayer.connection.getObjectsByBbox(
+            var hitnodes:Array = layer.connection.getObjectsByBbox(
                 map.coord2lon(p.x-10),
                 map.coord2lon(p.x+10),
                 map.coord2lat(p.y-10),
@@ -194,7 +194,7 @@ package net.systemeD.potlatch2.controller {
                 }
             }
             
-                       var ways:Array=editableLayer.findWaysAtPoint(q.x, q.y, selectedWay);
+                       var ways:Array=layer.findWaysAtPoint(q.x, q.y, selectedWay);
                        for each (var w:Way in ways) {
                 // hit a way, now let's see if we hit a specific node
                 for (var i:uint = 0; i < w.length; i++) {
index 45d020c..dd0cf6c 100644 (file)
@@ -45,6 +45,7 @@ package net.systemeD.potlatch2.utils {
                                        for (key in dr.values) {
                                                v=dr.values[key];
                                                while (v.substr(v.length-1,1)==" ") v=v.substr(0,v.length-1);
+                                               while (v.substr(0,1)==" ") v=v.substr(1);
                                                if (v!='') tags[key.toLowerCase()]=v;
                                        }
 
index 6fec5f7..0c02f61 100644 (file)
@@ -5,7 +5,9 @@ relation[type=restriction] node { z-index:11; icon-image: icons/restriction.png;
 /* Interactive way behaviour */
 
 way::highlight :hover  { z-index: 2; width: eval('_width+10'); color: #ffff99; }
+way::highlight :hover :background { color: lightcyan; }
 way::highlight :selected { z-index: 2; width: eval('_width+10'); color: yellow; opacity: 0.7;}
+way::highlight :selected :background { color: cyan; }
 way::highlight :restrictfrom { z-index: -1; width: eval('_width+10'); color: red; opacity: 0.7;}
 way::highlight :restrictto { z-index: -1; width: eval('_width+10'); color: blue; opacity: 0.7;}
 /*way !:drawn !:hasTags{ z-index:10; width: 0.5; color: red; }*/
@@ -21,4 +23,5 @@ node !:drawn :hasTags { z-index: 9; icon-image: circle; icon-width: 4; color: bl
 node :hasTags :selectedway { z-index: 9; icon-image: square; icon-width: 8; color: black; layer: 5; }
 node !:drawn :selectedway { z-index: 9; icon-image: square; icon-width: 8; color: red; casing-color: #cc0000; casing-width: 1; layer: 5; }
 node::selectedNode :selected { z-index: 1; icon-image: square; icon-width: eval('_width+10'); color: yellow; interactive: no; layer: 5; }
+node::selectedNode :selected :background { color: cyan; }
 node::junctionNode :junction :selectedway { z-index: 8; icon-image: square; icon-width: 12; casing-color: black; casing-width: 1; layer: 5; }