move bg and style selection to top bar, and give a choice of styles
authorDave Stubbs <osm@randomjunk.co.uk>
Thu, 24 Dec 2009 12:29:32 +0000 (12:29 +0000)
committerDave Stubbs <osm@randomjunk.co.uk>
Thu, 24 Dec 2009 12:29:32 +0000 (12:29 +0000)
net/systemeD/halcyon/Map.as
net/systemeD/halcyon/styleparser/RuleSet.as
net/systemeD/potlatch2/BackgroundSelector.mxml [new file with mode: 0644]
net/systemeD/potlatch2/CategorySelector.mxml
net/systemeD/potlatch2/StyleSelector.mxml [new file with mode: 0644]
potlatch2.mxml
resources/wireframe.css [new file with mode: 0644]

index d8267825cca25f645c8f055cbd894b3dac0c2baa..58e93bef9ad9ed28f49f654f6f7d1e678ae4e1ae 100755 (executable)
@@ -344,6 +344,13 @@ package net.systemeD.halcyon {
                private function reportPosition():void {
                        addDebug("lon "+coord2lon(mouseX)+", lat "+coord2lat(mouseY));
                }
+               
+               public function setStyle(style:String):void {
+                       if (style) {
+                               ruleset=new RuleSet(this,redrawPOIs);
+                               ruleset.loadFromCSS(style);
+                       }
+        }
 
                // ------------------------------------------------------------------------------------------
                // Export (experimental)
index d21706dbd8df1adbda49da23d915691df2ace9a6..68fbc00447895ed2ba5cbcaaa6223653c82883a4 100644 (file)
@@ -20,9 +20,9 @@ package net.systemeD.halcyon.styleparser {
 
                // variables for name, author etc.
 
-               public function RuleSet(m:Map,f:Function=null):void {
-                       map=m;
-                       iconCallback=f;
+               public function RuleSet(m:Map,iconLoadedCallback:Function=null):void {
+                       map = m;
+                       iconCallback = iconLoadedCallback;
                }
 
                // Get styles for an object
@@ -63,6 +63,7 @@ package net.systemeD.halcyon.styleparser {
 //                     Inspector.getInstance().show();
 //                     Inspector.getInstance().shelf('Choosers', choosers);
                        loadImages();
+                       map.redraw();
                }
 
 
diff --git a/net/systemeD/potlatch2/BackgroundSelector.mxml b/net/systemeD/potlatch2/BackgroundSelector.mxml
new file mode 100644 (file)
index 0000000..e85737e
--- /dev/null
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="utf-8"?>
+<mx:VBox
+       xmlns:mx="http://www.adobe.com/2006/mxml"
+       paddingTop="10" paddingLeft="10" paddingRight="10" paddingBottom="10"
+       horizontalAlign="left" backgroundColor="white" >
+       
+       <mx:List width="100%" height="100%" id="background" change="updateBackground();"> 
+           <!-- This should be pulled in from an XML file rather than sitting in the source -->
+           <mx:dataProvider>
+               <mx:Object label="None" data="" />
+               <mx:Object label="Yahoo!" data="yahoo" />
+               <mx:Object label="New Popular Edition" data="http://npe.openstreetmap.org/$z/$x/$y.png" />
+               <mx:Object label="OpenCycleMap" data="http://andy.sandbox.cloudmade.com/tiles/cycle/$z/$x/$y.png" />
+           </mx:dataProvider>
+       </mx:List>
+       <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:Script><![CDATA[
+               import net.systemeD.halcyon.*;
+               import net.systemeD.halcyon.connection.*;
+               import net.systemeD.potlatch2.*;
+               import com.yahoo.maps.api.YahooMap;
+               import com.yahoo.maps.api.YahooMapEvent;
+               import com.yahoo.maps.api.core.location.LatLon;
+
+               private function updateBackground():void {
+            var theMap:Map = Globals.vars.root;
+            var yahoo:YahooMap = Globals.vars.yahoo;
+                       var bg:String=background.selectedItem.data;
+                       if (bg=='yahoo') {
+                               theMap.tileset.init('',false);
+                               yahoo.visible=true;
+                               yahoo.zoomLevel = 18-theMap.scale;
+                               yahoo.centerLatLon = new LatLon(theMap.centre_lat, theMap.centre_lon);
+                       } else {
+                               theMap.tileset.init(background.selectedItem.data,true);
+                               yahoo.visible=false;
+                       }
+               }
+
+    ]]></mx:Script>    
+</mx:VBox>
+
index 9a334c972bcf990fdb6bcfea6ebc51a95b962e64..52fa42c715483db9513110f6daaaf4bf9ffad45e 100644 (file)
@@ -28,7 +28,7 @@
   </mx:ViewStack>
   </mx:HBox>
   
-  <mx:Label id="hoverInfo" text="Hover Info goes here"/>
+  <!-- mx:Label id="hoverInfo" text="Hover Info goes here"/>-->
   
   <mx:Script><![CDATA[
       import net.systemeD.halcyon.connection.*;
diff --git a/net/systemeD/potlatch2/StyleSelector.mxml b/net/systemeD/potlatch2/StyleSelector.mxml
new file mode 100644 (file)
index 0000000..e9f6f01
--- /dev/null
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="utf-8"?>
+<mx:VBox
+       xmlns:mx="http://www.adobe.com/2006/mxml"
+       paddingTop="10" paddingLeft="10" paddingRight="10" paddingBottom="10"
+       horizontalAlign="left" backgroundColor="white" >
+       
+       <mx:List width="100%" height="100%" id="mapStyle" change="updateMapStyle();"> 
+           <!-- This should be pulled in from an XML file rather than sitting in the source -->
+           <mx:dataProvider>
+               <mx:Object label="Potlatch" data="potlatch.css" />
+               <mx:Object label="Wireframe" data="wireframe.css" />
+           </mx:dataProvider>
+       </mx:List>
+
+       <mx:Script><![CDATA[
+               import net.systemeD.halcyon.*;
+               import net.systemeD.halcyon.connection.*;
+               import net.systemeD.potlatch2.*;
+
+               private function updateMapStyle():void {
+            var theMap:Map = Globals.vars.root;
+                       var style:String=mapStyle.selectedItem.data;
+                       theMap.setStyle(style);
+               }
+
+    ]]></mx:Script>    
+</mx:VBox>
+
index 668388a9cea87be29230659993e76c8af027057c..9357df0923969e5608779612714c6415d851dbad 100755 (executable)
     <mx:WipeRight id="wipeIn" duration="250"/>
 
     <mx:ApplicationControlBar dock="true">
+        <mx:PopUpButton id="bgButton" label="Background" openAlways="true"
+            creationComplete="bgButton.popUp = new BackgroundSelector();"/>
+        <mx:PopUpButton id="styleButton" label="Map Style" openAlways="true"
+            creationComplete="styleButton.popUp = new StyleSelector();"/>
         <mx:Spacer width="100%"/>
         <mx:Button label="Help" click="new HelpDialog().init();" />
         <mx:Button label="Options" click="new OptionsDialog().init();" />
     
     <mx:HDividedBox width="100%" height="100%">
 
-       <!-- The left-hand accordion is to give access to a small number of options that the user 
-            may want to change rapidly: tags, of course; stylesheet; and background layer. Lesser-
-            used options should go in the options dialogue. Tools (e.g. split ways) should probably 
-            go in a floating palette or somesuch, so that there is access no matter which accordion 
-            pane is open. -->
-
-       <mx:Accordion height="100%" width="25%" headerStyleName="header">
-
-               <!-- Tag viewer -->
-               <mx:VBox height="100%" width="100%" horizontalAlign="right" label="Tags">
-                       <potlatch2:TagViewer width="100%" height="100%" id="tagViewer"/>
-               </mx:VBox>
-
-               <!-- Stylesheet -->
-               <!-- should be pretty much the same as the background selector below, with the
-                    added ability to enter your own stylesheet URL -->
-               <mx:VBox label="Map style" width="100%">
-               </mx:VBox>
-
-               <!-- Background -->
-               <mx:VBox label="Background" width="100%">
-           <mx:List width="100%" height="100%" id="background" change="updateBackground();"> 
-                       <!-- This should be pulled in from an XML file rather than sitting in the source -->
-               <mx:dataProvider>
-                   <mx:Object label="None" data="" />
-                   <mx:Object label="Yahoo!" data="yahoo" />
-                   <mx:Object label="New Popular Edition" data="http://npe.openstreetmap.org/$z/$x/$y.png" />
-                   <mx:Object label="OpenCycleMap" data="http://andy.sandbox.cloudmade.com/tiles/cycle/$z/$x/$y.png" />
-               </mx:dataProvider>
-           </mx:List>
-               <mx:CheckBox width="100%" label="Dim background" selected="true" id="dim" change="theMap.tileset.setDimming(dim.selected); yahoo.alpha = dim.selected ? 0.5 : 1" />
-               </mx:VBox>
-
-       </mx:Accordion>
+         <!-- Tag viewer -->
+         <potlatch2:TagViewer width="25%" height="100%" id="tagViewer"/>
 
       <mx:Canvas width="75%" height="100%">
         <mx:Canvas id="map_area" resize="onResizeMap()"
 
                private function initApp():void {
 
-                       Globals.vars.map_area=map_area;
-                       Globals.vars.root=map_area.rawChildren;                 // set up global reference to root level
-                       var _root:IChildList=map_area.rawChildren;              // convenient local shorthand
+                       Globals.vars.map_area = map_area;
+                       Globals.vars.yahoo = yahoo;
+                       Globals.vars.root = map_area.rawChildren;                       // set up global reference to root level
+                       var _root:IChildList = map_area.rawChildren;            // convenient local shorthand
 
                        // map backdrop object
             var w:uint = map_area.width;
         private function onDataComplete(event:Event):void {
             dataWorking.visible = false;
         }
-
-               private function updateBackground():void {
-                       var bg:String=background.selectedItem.data;
-                       if (bg=='yahoo') {
-                               theMap.tileset.init('',false);
-                               yahoo.visible=true;
-                               yahoo.zoomLevel = 18-theMap.scale;
-                               yahoo.centerLatLon = new LatLon(theMap.centre_lat, theMap.centre_lon);
-                       } else {
-                               theMap.tileset.init(background.selectedItem.data,true);
-                               yahoo.visible=false;
-                       }
-               }
-               
        ]]></mx:Script>
 
 </mx:Application>
diff --git a/resources/wireframe.css b/resources/wireframe.css
new file mode 100644 (file)
index 0000000..e2ac883
--- /dev/null
@@ -0,0 +1,15 @@
+/*
+
+       Stylesheet that does simple wireframe display
+       
+*/
+
+way :hover     { z-index: 2; width: 1; color: blue; }
+way :selected { z-index: 2; width: 1; color: red; }
+way !:drawn { z-index:10; width: 1; color: black; } 
+
+node :selectedway { z-index: 8; icon-image: square; icon-width: 6; color: green; }
+node :hoverway { z-index: 9; icon-image: square; icon-width: 6; color: blue; }
+node :selected { z-index: 9; icon-image: square; icon-width: 6; color: red; casing-color: black; casing-width: 1; }
+node !:drawn :poi { z-index: 2; icon-image: square; icon-width: 4; color: green; casing-color: black; casing-width: 1; }
+