Merge remote-tracking branch 'gravitystorm/form-layout' into form-layout
authorRichard Fairhurst <richard@systemeD.net>
Sun, 4 Mar 2012 15:12:48 +0000 (15:12 +0000)
committerRichard Fairhurst <richard@systemeD.net>
Sun, 4 Mar 2012 15:12:48 +0000 (15:12 +0000)
1  2 
net/systemeD/potlatch2/TagViewer.mxml

index bbca135b9170cd8350fc5cb32be7e6b9a8bf87a3,8d4f7fb36b4e7517a2689fc26b8f20d53ed219d0..693bc6569cc53801775f2228a658517d1c946667
@@@ -1,10 -1,4 +1,10 @@@
  <?xml version="1.0" encoding="utf-8"?>
 +<!---
 +  The TagViewer is the container for the entire sidebar. It has a number of components, and subpanels, in a ViewStack that change
 +  depending on what is selected, i.e. the ControllerState.
 +
 +  @see net.systemeD.potlatch2.controller.ControllerState
 +    -->
  <mx:VBox
      xmlns:fx="http://ns.adobe.com/mxml/2009"
        xmlns:mx="library://ns.adobe.com/flex/mx"
@@@ -38,8 -32,6 +38,8 @@@
                                                        import mx.core.DragSource;
  
                                                        private function dragPOI(event:MouseEvent, tags:Array):void {
 +                                                              if (outerDocument.controller.map.dragstate==outerDocument.controller.map.DRAGGING) return;
 +
                                                                // Get the drag initiator component from the event object.
                                                                var dragInitiator:Image = event.currentTarget as Image;
                                                                var dragSource:DragSource = new DragSource();
        import net.systemeD.controls.CollapsiblePanel;
  
        import mx.collections.*;
-       import mx.containers.*;
+       import mx.containers.VBox;
+       import mx.containers.HBox;
+       import mx.containers.TabNavigator;
+       import mx.containers.Accordion;
        import mx.events.*;
        import mx.core.*;
        import mx.managers.PopUpManager;
        import mx.managers.DragManager;
        import mx.core.DragSource;
        import mx.controls.TabBar;
+       import spark.components.Form;
+       import spark.layouts.FormLayout;
  //    import flexlib.containers.SuperTabNavigator;
  
        [Bindable] [Embed(source="../../../embedded/tab_basic.png"       )] private var tabIconBasic:Class;
                markerPanelContents.init(selectedEntity, layer);
                sidebar.selectedChild = markerPanel;
              } else if (connection is SnapshotConnection) {
 -              backgroundPanelContents.init(selectedEntity, layer);
 +              backgroundPanelContents.init(selectedEntity);
                sidebar.selectedChild = backgroundPanel;
              } else {
                refreshFeatureIcon();
                        // Add to basic editor box first
                        if ( factory.presence.isEditorPresent(factory, selectedEntity, null) ) {
                                var editor:DisplayObject = factory.createEditorInstance(selectedEntity);
-                               if (editor) basicEditorBox.addChild(editor);
+                               if (editor) Form(basicEditorBox.getChildByName("form")).addElement(UIComponent(editor));
                        }
  
                        // Then prepare to add to category panel
                                        subpanel.styleName="subcategoryPanel";
                                        subpanel.title=subcategory;
                                        subpanels[category][subcategory]=subpanel;
+                                       var form:Form = new Form();
+                                       form.name = "form";
+                                       form.layout = getFormLayout();
+                                       subpanel.addChild(form);
                                        tabComponents[tab].push(subpanel);
                                }
-                               subpanel.addChild(catEditor);
+                               Form(subpanel.getChildByName("form")).addElement(UIComponent(catEditor));
                        } else {
                                tabComponents[tab].push(catEditor);
                        }
            box.percentWidth = 100;
            box.percentHeight = 100;
            box.styleName = "dndEditorContainer";
+           var form:Form = new Form();
+           form.name = "form";
+           form.layout = getFormLayout();
+           box.addChild(form);
            return box;
        }
  
            if ( components == null || tab == null || tab.numChildren >= components.length )
                return;
            for each (var component:DisplayObject in components ) {
-               tab.addChild(component);
+               Form(tab.getChildByName("form")).addElement(UIComponent(component));
            }
        }
  
                        if      ( entity is Node     ) entityText = "Node";
                        else if ( entity is Way      ) entityText = "Way";
                        else if ( entity is Relation ) entityText = "Relation";
 -                      advancedID.htmlText = entityText+": <b>"+entity.id+"</b>";
 +                      advancedID.htmlText = entityText+": <b>"+entity.id+"</b> "+(entity.status ? entity.status : '');
                }
  
                removeRelationListeners();
        }
  
          public function addNewTag():void {
 -              if (stack.selectedChild!=advancedContainer) { return; }
 -              advancedTagGrid.addNewTag();
 +              if (sidebar.selectedChild==multiplePanel) { multiAdvancedTagGrid.addNewTag(); }
 +              else if (stack.selectedChild==advancedContainer) { advancedTagGrid.addNewTag(); }
          }
  
        private function addedToRelation(event:RelationMemberEvent):void {
                if (rows!=Math.floor(rows)) { rows=Math.floor(rows+1); }
                event.target.height=rows*(event.target.rowHeight+1);
        }
+     private function getFormLayout():FormLayout {
+         var layout:FormLayout = new FormLayout();
+           // This is ugly, and should really be done with a skin. See
+           // http://stackoverflow.com/questions/5126756/flex-spark-form-item-gap
+         layout.gap = -8;
+         return layout;
+     }
    ]]></fx:Script>
  </mx:VBox>