fix tab selection issue, and remove annoying flash of drag-and-drop panel when going...
authorRichard Fairhurst <richard@systemed.net>
Tue, 15 Jun 2010 17:43:45 +0000 (17:43 +0000)
committerRichard Fairhurst <richard@systemed.net>
Tue, 15 Jun 2010 17:43:45 +0000 (17:43 +0000)
14 files changed:
TODO.txt
net/systemeD/potlatch2/EditController.as
net/systemeD/potlatch2/TagViewer.mxml
net/systemeD/potlatch2/controller/ControllerState.as
net/systemeD/potlatch2/controller/DragBackground.as
net/systemeD/potlatch2/controller/DragPOINode.as
net/systemeD/potlatch2/controller/DragWay.as
net/systemeD/potlatch2/controller/DragWayNode.as
net/systemeD/potlatch2/controller/DrawWay.as
net/systemeD/potlatch2/controller/NoSelection.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

index ced24e3..43c1567 100644 (file)
--- a/TODO.txt
+++ b/TODO.txt
@@ -28,7 +28,6 @@ Potlatch 2: main outstanding issues
 
 == Tag editing ==
 
-** Doesn't always update selected tab when you select a new entity
 * Dynamic reloading of stylesheet/map_features, so that you don't need to reload the full page when editing them
 * If a select name is too long then, the select menu seems to give a horizontal scrollbar instead of the name of the item e.g. cuisine#Coffee Shop
 * If you have both inputSets names and buildingAddress, and name= key is filled in then the basic tab will get both, surely only name should be shown and building name should be ignored e.g. cafes. [Actually this was an issue of addr: being missing from one of them, however this may still be a problem for other overlapping inputSets]
index 9591f75..099697c 100644 (file)
@@ -103,7 +103,7 @@ package net.systemeD.potlatch2 {
                 return;
                 
             if ( state != null )
-                state.exitState();
+                state.exitState(newState);
             newState.setController(this);
             newState.setPreviousState(state);
             state = newState;
index b3cd05f..b9196cb 100644 (file)
@@ -52,6 +52,7 @@
         </mx:HBox>
         <flexlib:SuperTabNavigator id="editorStack" width="100%" height="100%" paddingLeft="2" paddingRight="2"
             allowTabSqueezing="false" minTabWidth="10" closePolicy="close_never"
+                       updateComplete="tabSelected()" 
             scrollSpeed="20" change="ensureEditorsPopulated(IndexChangedEvent(event).relatedObject as VBox)"/>
       </mx:VBox>
 
               tab.addChild(component);
           }
       }
+
+       private function tabSelected():void {
+               if (editorStack.selectedIndex<0) { return; }
+               // This fixes a Flex TabNavigator bug where the tab would be selected, but not actually skinned properly
+               for (var i:uint=0; i<editorStack.numChildren; i++) {
+                       editorStack.getTabAt(i).selected=(i==editorStack.selectedIndex);
+               }
+       }
       
       private function checkAdvanced():void {
           if ( selectedEntity != null )
index 67f6572..b7f0b59 100644 (file)
@@ -26,6 +26,10 @@ package net.systemeD.potlatch2.controller {
                 this.previousState = previousState;
         }
    
+               public function isSelectionState():Boolean {
+                       return true;
+               }
+
         public function processMouseEvent(event:MouseEvent, entity:Entity):ControllerState {
             return this;
         }
@@ -39,7 +43,7 @@ package net.systemeD.potlatch2.controller {
                }
 
         public function enterState():void {}
-        public function exitState():void {}
+        public function exitState(newState:ControllerState):void {}
 
                public function toString():String {
                        return "(No state)";
index 222e40f..307695d 100644 (file)
@@ -38,7 +38,7 @@ package net.systemeD.potlatch2.controller {
                        controller.map.draggable=false;
                        Globals.vars.root.addDebug("**** -> "+this);
         }
-        override public function exitState():void {
+        override public function exitState(newState:ControllerState):void {
                        controller.map.draggable=true;
                        Globals.vars.root.addDebug("**** <- "+this);
         }
index 59e693e..e8cc8f9 100644 (file)
@@ -57,7 +57,7 @@ package net.systemeD.potlatch2.controller {
             controller.map.setHighlight(selectedNode, { highlight: true } );
                        Globals.vars.root.addDebug("**** -> "+this);
         }
-        override public function exitState():void {
+        override public function exitState(newState:ControllerState):void {
             controller.map.setHighlight(selectedNode, { highlight: false } );
                        Globals.vars.root.addDebug("**** <- "+this);
         }
index 5eeb30d..0e6e811 100644 (file)
@@ -64,7 +64,7 @@ package net.systemeD.potlatch2.controller {
             controller.map.setHighlight(selectedWay, { highlight: true } );
                        Globals.vars.root.addDebug("**** -> "+this);
         }
-        override public function exitState():void {
+        override public function exitState(newState:ControllerState):void {
             controller.map.setHighlight(selectedWay, { highlight: false } );
                        Globals.vars.root.addDebug("**** <- "+this);
         }
index 8957daf..e3d42d0 100644 (file)
@@ -81,7 +81,7 @@ package net.systemeD.potlatch2.controller {
             controller.map.setHighlight(selectedWay, { showNodes: true } );
                        Globals.vars.root.addDebug("**** -> "+this);
         }
-        override public function exitState():void {
+        override public function exitState(newState:ControllerState):void {
             controller.map.setHighlight(selectedWay, { showNodes: false } );
                        Globals.vars.root.addDebug("**** <- "+this);
         }
index eca24c9..bae555f 100644 (file)
@@ -196,8 +196,8 @@ package net.systemeD.potlatch2.controller {
                        controller.setCursor(controller.pen);
                        Globals.vars.root.addDebug("**** -> "+this);
                }
-               override public function exitState():void {
-                       super.exitState();
+               override public function exitState(newState:ControllerState):void {
+                       super.exitState(newState);
                        controller.setCursor(null);
                        elastic.removeSprites();
                        elastic = null;
index e40eaa0..bc8d082 100644 (file)
@@ -13,6 +13,10 @@ package net.systemeD.potlatch2.controller {
                public function NoSelection() {
                }
 
+               override public function isSelectionState():Boolean {
+                       return false;
+               }
+               
                override public function processMouseEvent(event:MouseEvent, entity:Entity):ControllerState {
                        var focus:Entity = getTopLevelFocusEntity(entity);
 
@@ -39,7 +43,7 @@ package net.systemeD.potlatch2.controller {
         override public function enterState():void {
                        Globals.vars.root.addDebug("**** -> "+this);
         }
-        override public function exitState():void {
+        override public function exitState(newState:ControllerState):void {
                        Globals.vars.root.addDebug("**** <- "+this);
         }
                override public function toString():String {
index 3eb14b3..fa278fd 100644 (file)
@@ -7,7 +7,7 @@ package net.systemeD.potlatch2.controller {
 
     public class SelectedPOINode extends ControllerState {
         protected var initNode:Node;
-        
+
         public function SelectedPOINode(node:Node) {
             initNode = node;
         }
@@ -16,17 +16,17 @@ package net.systemeD.potlatch2.controller {
             if ( node == selectedNode )
                 return;
 
-            clearSelection();
+            clearSelection(this);
             controller.setSelectedEntity(node);
             controller.map.setHighlight(node, { selected: true });
             selectedNode = node;
             initNode = node;
         }
                 
-        protected function clearSelection():void {
+        protected function clearSelection(newState:ControllerState):void {
             if ( selectedNode != null ) {
                 controller.map.setHighlight(selectedNode, { selected: false });
-                controller.setSelectedEntity(null);
+                if (!newState.isSelectionState()) { controller.setSelectedEntity(null); }
                 selectedNode = null;
             }
         }
@@ -57,9 +57,9 @@ package net.systemeD.potlatch2.controller {
             selectNode(initNode);
                        Globals.vars.root.addDebug("**** -> "+this);
         }
-        override public function exitState():void {
+        override public function exitState(newState:ControllerState):void {
                        controller.clipboards['node']=selectedNode.getTagsCopy();
-            clearSelection();
+            clearSelection(newState);
                        Globals.vars.root.addDebug("**** <- "+this);
         }
 
index 50ce67b..9720579 100644 (file)
@@ -77,8 +77,8 @@ package net.systemeD.potlatch2.controller {
                        startlatp=controller.map.coord2latp(controller.map.mouseY);
                        Globals.vars.root.addDebug("**** -> "+this);
         }
-               override public function exitState():void {
-            clearSelection();
+               override public function exitState(newState:ControllerState):void {
+            clearSelection(newState);
                        Globals.vars.root.addDebug("**** <- "+this);
         }
 
index 8228a0f..9c6a777 100644 (file)
@@ -22,17 +22,17 @@ package net.systemeD.potlatch2.controller {
             if ( way == selectedWay )
                 return;
 
-            clearSelection();
+            clearSelection(this);
             controller.setSelectedEntity(way);
             controller.map.setHighlight(way, { selected: true, showNodes: true, hover: false });
             selectedWay = way;
             initWay = way;
         }
 
-        protected function clearSelection():void {
+        protected function clearSelection(newState:ControllerState):void {
             if ( selectedWay != null ) {
                controller.map.setHighlight(selectedWay, { selected: false, showNodes: false, hover: false });
-                controller.setSelectedEntity(null);
+                if (!newState.isSelectionState()) { controller.setSelectedEntity(null); }
                 selectedWay = null;
             }
         }
@@ -121,9 +121,9 @@ package net.systemeD.potlatch2.controller {
             selectWay(initWay);
                        Globals.vars.root.addDebug("**** -> "+this+" "+selectedWay.id);
         }
-        override public function exitState():void {
+        override public function exitState(newState:ControllerState):void {
                        controller.clipboards['way']=selectedWay.getTagsCopy();
-            clearSelection();
+            clearSelection(newState);
                        Globals.vars.root.addDebug("**** <- "+this);
         }
 
index c87ac54..d6b96b5 100644 (file)
@@ -20,7 +20,7 @@ package net.systemeD.potlatch2.controller {
             if ( way == selectedWay && node == selectedNode )
                 return;
 
-            clearSelection();
+            clearSelection(this);
             controller.setSelectedEntity(node);
             controller.map.setHighlight(way, { showNodes: true, nodeSelected: node.id });
             selectedWay = way; initWay = way;
@@ -28,10 +28,10 @@ package net.systemeD.potlatch2.controller {
             selectedNode = node;
         }
                 
-        override protected function clearSelection():void {
+        override protected function clearSelection(newState:ControllerState):void {
             if ( selectedNode != null ) {
                controller.map.setHighlight(selectedWay, { selected: false, showNodes: false, nodeSelected: null });
-                controller.setSelectedEntity(null);
+                if (!newState.isSelectionState()) { controller.setSelectedEntity(null); }
                 selectedNode = null;
                                selectedWay = null;
             }
@@ -75,9 +75,9 @@ package net.systemeD.potlatch2.controller {
             selectNode(initWay,initIndex);
                        Globals.vars.root.addDebug("**** -> "+this);
         }
-               override public function exitState():void {
+               override public function exitState(newState:ControllerState):void {
                        controller.clipboards['node']=selectedNode.getTagsCopy();
-            clearSelection();
+            clearSelection(newState);
                        Globals.vars.root.addDebug("**** <- "+this);
         }