custom imagery dialogue
authorRichard Fairhurst <richard@systemed.net>
Sun, 13 Jun 2010 22:07:35 +0000 (22:07 +0000)
committerRichard Fairhurst <richard@systemed.net>
Sun, 13 Jun 2010 22:07:35 +0000 (22:07 +0000)
TODO.txt
net/systemeD/potlatch2/BackgroundDialog.mxml [new file with mode: 0644]
net/systemeD/potlatch2/BackgroundSelector.mxml
net/systemeD/potlatch2/EditController.as
potlatch2.mxml

index 38d8b50..f9544dc 100644 (file)
--- a/TODO.txt
+++ b/TODO.txt
@@ -46,7 +46,7 @@ Potlatch 2: main outstanding issues
 
 ** Potlatch 1-style "floaty warnings"
 ** Should remember which background imagery layer you had previously selected
-** Dialog for adding custom imagery url
+* Custom imagery dialog fixes
 * Ctrl-clicking two areas (one inside the other) should create a multipolygon
 * B keypress for background source tag
 * Bbox-sensitive menu for background imagery
diff --git a/net/systemeD/potlatch2/BackgroundDialog.mxml b/net/systemeD/potlatch2/BackgroundDialog.mxml
new file mode 100644 (file)
index 0000000..22b9988
--- /dev/null
@@ -0,0 +1,67 @@
+<?xml version="1.0" encoding="utf-8"?>
+<mx:TitleWindow
+        xmlns:mx="http://www.adobe.com/2006/mxml" 
+        layout="vertical" showCloseButton="true"
+        horizontalAlign="center" title="Background imagery"
+        width="500" height="300" verticalGap="0">
+
+  <mx:DataGrid editable="true" width="100%" height="100%" id="imageryGrid">
+    <mx:columns>
+        <mx:DataGridColumn editable="true" dataField="label" headerText="Name"/>
+        <mx:DataGridColumn editable="true" dataField="data" headerText="URL"/>
+    </mx:columns>
+  </mx:DataGrid>        
+
+  <mx:HBox horizontalAlign="right" width="100%">
+    <mx:LinkButton label="Delete" click="removeSource()" enabled="{imageryGrid.selectedItem != null? true : false}"/>
+    <mx:LinkButton label="Add" click="addNewSource()"/>
+  </mx:HBox>
+
+  <mx:Script><![CDATA[
+
+       /*
+               Still to do:
+               - editable hotkeys for each layer
+               - editable source tag for each layer
+               - editable bbox for each layer
+               - ability to use this dialogue to select as well as edit
+               - automatically select imagery once you've edited it (i.e. itemEditEnd)
+               - save/load imagery sets into OSM preferences
+       */
+
+    import mx.managers.PopUpManager;
+    import mx.events.CloseEvent;
+    import mx.core.Application;
+       import mx.collections.ArrayCollection;
+       import mx.controls.List;
+
+       public var imageryCollection:ArrayCollection = new ArrayCollection(Application.application.theController.imagery);
+       private var menu:List;
+
+    public function init(menu:List):void {
+               this.menu=menu;
+        PopUpManager.addPopUp(this, Application(Application.application), true);
+        PopUpManager.centerPopUp(this);
+        this.addEventListener(CloseEvent.CLOSE, backgroundDialog_close);
+               imageryGrid.dataProvider=imageryCollection;
+    }
+    
+    private function backgroundDialog_close(evt:CloseEvent):void {
+        PopUpManager.removePopUp(this);
+               if (menu) { menu.invalidateList(); }
+    }
+
+       private function addNewSource():void {
+               imageryCollection.addItemAt( {label:'(new name)',data:'(new URL)'} , imageryCollection.length);
+               imageryGrid.validateNow();
+               imageryGrid.verticalScrollPosition=imageryGrid.maxVerticalScrollPosition;
+               imageryGrid.editedItemPosition = {rowIndex: imageryCollection.length-1, columnIndex: 0};
+       }
+       private function removeSource():void {
+               imageryCollection.removeItemAt(imageryGrid.selectedIndex);
+       }
+
+  ]]>
+  </mx:Script>
+
+</mx:TitleWindow>
index 1e899a7..75e3847 100644 (file)
@@ -5,11 +5,14 @@
        horizontalAlign="left" backgroundColor="white" borderStyle="inset">
        
        <mx:List width="100%" height="100%" id="background" change="updateBackground();" verticalScrollPolicy="on" 
-                dataProvider="{_layers}" />
+                dataProvider="{Application.application.theController.imagery}" />
        <mx:CheckBox width="100%" label="Dim background" selected="true" id="dim"
            change="Globals.vars.root.tileset.setDimming(dim.selected); Globals.vars.yahoo.alpha = dim.selected ? 0.5 : 1" />
 
-       <mx:Button label="Load vector file..." click="new VectorSourceDialog().init();"/>
+       <mx:HBox>
+       <mx:Button label="Edit..." click="new BackgroundDialog().init(background);" />
+       <mx:Button label="Vector file" click="new VectorSourceDialog().init();" />
+       </mx:HBox>
 
        <mx:Script><![CDATA[
                import net.systemeD.halcyon.*;
                import mx.managers.PopUpManager;
                import net.systemeD.halcyon.Globals;
 
-               [Bindable] private var _layers:Array=new Array(
-                       { label: "None", data: "" },
-                       { label: "Yahoo", data: "yahoo" } );
-
-               public function populate(xml:XML):void {
-            for each(var set:XML in xml.set) {
-                _layers.push({ label:set.child("name"), data:set.child("url") });
-            }           
-               }
-
                private function updateBackground():void {
             var theMap:Map = Globals.vars.root;
                        var bg:String=background.selectedItem.data;
index 7715f26..be7aa43 100644 (file)
@@ -18,6 +18,7 @@ package net.systemeD.potlatch2 {
         
                private var keys:Object={};
                public var clipboards:Object={};
+               public var imagery:Array=[];
 
                [Embed(source="../../../embedded/pen.png")]             public var pen:Class;
                [Embed(source="../../../embedded/pen_x.png")]           public var pen_x:Class;
index 79e0cee..b37f77f 100755 (executable)
                }
         
         private function onImageryLoad(event:Event):void {
-                       var imagery:XML = new XML(URLLoader(event.target).data);
-                       BackgroundSelector(bgButton.popUp).populate(imagery);
+                       var xml:XML = new XML(URLLoader(event.target).data);
+            theController.imagery=new Array(
+                               { label: "None", data: "" },
+                               { label: "Yahoo", data: "yahoo" } );
+                       for each(var set:XML in xml.set) {
+                theController.imagery.push({ label:set.child("name"), data:set.child("url") });
+                       }
                }
-
         
         private function dragEnterHandler(event:DragEvent):void {
             // Get the drop target component from the event object.