speed up selection by making editors added lazily with tabs
authorDave Stubbs <osm@randomjunk.co.uk>
Sun, 10 Jan 2010 11:29:27 +0000 (11:29 +0000)
committerDave Stubbs <osm@randomjunk.co.uk>
Sun, 10 Jan 2010 11:29:27 +0000 (11:29 +0000)
net/systemeD/potlatch2/CategorySelector.mxml
net/systemeD/potlatch2/TagViewer.mxml

index 69fdbf3..c7647d7 100644 (file)
@@ -1,7 +1,8 @@
 <?xml version="1.0" encoding="utf-8"?>
 <mx:VBox
        xmlns:mx="http://www.adobe.com/2006/mxml" 
-       xmlns:halcyon="net.systemeD.halcyon.*">
+       xmlns:halcyon="net.systemeD.halcyon.*"
+       backgroundColor="white" borderStyle="inset">
 
   <mx:HBox horizontalGap="0"> 
   <mx:ToggleButtonBar height="100%" dataProvider="{categoryStack}" direction="vertical"/>
index f8ee6b7..d76b2dc 100644 (file)
@@ -17,7 +17,7 @@
     </mx:HBox>
     <flexlib:SuperTabNavigator id="editorStack" width="100%" height="100%" paddingLeft="2" paddingRight="2"
         allowTabSqueezing="false" minTabWidth="10" closePolicy="close_never"
-        scrollSpeed="20"/>
+        scrollSpeed="20" change="ensureEditorsPopulated(IndexChangedEvent(event).relatedObject as VBox)"/>
   </mx:VBox>
 
   <mx:VBox width="100%" height="100%" label="Advanced" initialize="checkAdvanced()" verticalGap="1">
           helpLabel.visible = false;
       }
 
+      private var tabComponents:Object = {};
+      
       private function initialiseEditors():void {
           editorStack.removeAllChildren();
           if ( selectedEntity == null || feature == null )
           editorStack.addChild(editorBox);
           
           var tabs:Object = {};
+          tabComponents = {};
           
           for each (var factory:EditorFactory in feature.editors) {
               if ( factory.presence.isEditorPresent(factory, selectedEntity, null) ) {
                   tab.label = category;
                   editorStack.addChild(tab);
                   tabs[category] = tab;
+                  tabComponents[tab] = [];
               }
               var catEditor:DisplayObject = factory.createEditorInstance(selectedEntity);
               if ( catEditor != null )
-                  tab.addChild(catEditor);
+                  tabComponents[tab].push(catEditor);
+              //    tab.addChild(catEditor);
           }
       }
       
           return box;
       }
 
+      private function ensureEditorsPopulated(tab:VBox):void {
+          var components:Array = tabComponents[tab];
+          if ( components == null || tab == null || tab.numChildren >= components.length )
+              return;
+          for each (var component:DisplayObject in components ) {
+              tab.addChild(component);
+          }
+      }
+      
       private function checkAdvanced():void {
           if ( selectedEntity != null )
              setupAdvanced(selectedEntity);