continuing to expand and rework selection stuff. Not finished yet but getting there
[potlatch2.git] / potlatch2.mxml
1 <?xml version="1.0" encoding="utf-8"?>
2 <mx:Application 
3         xmlns:mx="http://www.adobe.com/2006/mxml" 
4         xmlns:halcyon="net.systemeD.halcyon.*"
5         xmlns:potlatch2="net.systemeD.potlatch2.*"
6         layout="vertical"
7         horizontalAlign="center" 
8         addedToStage="initApp()">
9         
10         <mx:Style source="styles/Application.css"/>
11
12     <mx:Glow id="glowImage" duration="100" 
13         alphaFrom="0.3" alphaTo="1.0" 
14         blurXFrom="0.0" blurXTo="5.0" 
15         blurYFrom="0.0" blurYTo="5.0" 
16         color="0xFF8000"/>
17     <mx:Glow id="unglowImage" duration="100" 
18         alphaFrom="1.0" alphaTo="0.3" 
19         blurXFrom="5.0" blurXTo="0.0" 
20         blurYFrom="5.0" blurYTo="0.0" 
21         color="0xFF8000"/>
22     <mx:WipeLeft id="wipeOut" duration="250"/>
23     <mx:WipeRight id="wipeIn" duration="250"/>
24
25     <mx:ApplicationControlBar dock="true">
26         <mx:Spacer width="100%"/>
27         <mx:Button label="Save" icon="@Embed('embedded/save.svg')" click="SaveManager.saveChanges();"/>
28     </mx:ApplicationControlBar>
29     
30     <mx:HDividedBox width="100%" height="100%">
31
32       <mx:VBox height="100%" width="25%" horizontalAlign="right">
33         <potlatch2:TagViewer width="100%" height="100%" id="tagViewer"/>
34       </mx:VBox>
35       <mx:Canvas width="75%" height="100%">
36         <mx:Canvas id="map_area" resize="onResizeMap()"
37             top="0" left="0" width="100%" height="100%">
38         </mx:Canvas>
39         <mx:Image source="@Embed('embedded/zoomIn.svg')" right="3" top="3" click="theMap.zoomIn();"
40             rollOverEffect="glowImage" rollOutEffect="unglowImage"/>
41         <mx:Image source="@Embed('embedded/zoomOut.svg')" right="3" top="20" click="theMap.zoomOut();"
42             rollOverEffect="glowImage" rollOutEffect="unglowImage"/>
43         <mx:Label id="dataWorking" text="" right="20" top="3"
44             showEffect="{wipeIn}" hideEffect="{wipeOut}"/>
45       </mx:Canvas>
46     </mx:HDividedBox>
47
48         <mx:Script><![CDATA[
49                 import net.systemeD.halcyon.*;
50                 import net.systemeD.halcyon.connection.*;
51                 import net.systemeD.potlatch2.*;
52                 import net.systemeD.potlatch2.save.SaveManager;
53                 import flash.system.Security;
54                 import flash.net.*;
55                 import flash.events.MouseEvent;
56                 import flash.display.Sprite;
57                 import mx.core.IChildList;
58         import mx.containers.Canvas;
59                 import mx.core.Application;
60                 import com.yahoo.maps.api.YahooMap;
61                 import com.yahoo.maps.api.YahooMapEvent;
62                 import com.yahoo.maps.api.core.location.LatLon;
63
64         public var theMap:Map;
65
66                 private function initApp():void {
67
68                         Globals.vars.map_area=map_area;
69                         Globals.vars.root=map_area.rawChildren;                 // set up global reference to root level
70                         var _root:IChildList=map_area.rawChildren;              // convenient local shorthand
71
72                         // map backdrop object
73             var w:uint = map_area.width;
74             var h:uint = map_area.height;
75             var b:Sprite = new Sprite();
76             b.height=h; b.width=w;
77             b.graphics.beginFill(0xFFFFEA,100); 
78             b.graphics.drawRect(0,0,w,h); 
79             b.graphics.endFill();
80                         _root.addChild(b);
81
82 /*                      // Add Yahoo! background
83                         var yahoo:YahooMap = new YahooMap(); 
84                         yahoo.init("f0a.sejV34HnhgIbNSmVHmndXFpijgGeun0fSIMG9428hW_ifF3pYKwbV6r9iaXojl1lU_dakekR", w, h);  
85                         yahoo.mapType="satellite";
86                         _root.addChild(yahoo);
87
88                         // Yahoo! listeners
89                         var yahooListener:Object = new Object();
90                         yahooListener.yahooInit=function(event:YahooMapEvent):void {
91                                 yahoo.zoomLevel = 18-theMap.scale;
92                                 yahoo.centerLatLon = new LatLon(theMap.centre_lat, theMap.centre_lon);
93
94                                 yahooListener.moveHandler=function(event:MapEvent):void {
95                                         yahoo.zoomLevel=18-event.params.scale;
96                                         yahoo.centerLatLon=new LatLon(event.params.lat, event.params.lon);
97                                 };
98                                 theMap.addEventListener(MapEvent.MOVE, yahooListener.moveHandler);
99
100                                 yahooListener.resizeHandler=function(event:MapEvent):void {
101                                         yahoo.setSize(event.params.width, event.params.height);
102                                 };
103                                 theMap.addEventListener(MapEvent.RESIZE, yahooListener.resizeHandler);
104                         }
105                         yahoo.addEventListener(YahooMapEvent.MAP_INITIALIZE, yahooListener.yahooInit);
106 */
107                         // add map
108                         theMap=new Map(this.loaderInfo.parameters);
109                         theMap.backdrop=b;
110                         _root.addChild(theMap);
111             theMap.updateSize(w, h);
112
113                         // add mask for map
114                         var s:Sprite=new Sprite();
115                         s.graphics.beginFill(0xFFFFFF,100);
116                         s.graphics.drawRect(0,0,w,h);
117                         s.graphics.endFill();
118                         _root.addChild(s);
119                         theMap.mask=s;
120
121                         // add crosshair
122                         /*s=new Sprite();
123                         s.graphics.lineStyle(2,0);
124                         s.graphics.moveTo(stage.stageWidth/2-20,stage.stageHeight/2);
125                         s.graphics.lineTo(stage.stageWidth/2+20,stage.stageHeight/2);
126                         s.graphics.moveTo(stage.stageWidth/2,stage.stageHeight/2-20);
127                         s.graphics.lineTo(stage.stageWidth/2,stage.stageHeight/2+20);
128                         _root.addChild(s);*/
129
130                         // mouse-up handler attached to stage, so the user can release outside the map
131                         stage.addEventListener(MouseEvent.MOUSE_UP, theMap.mouseUpHandler);
132                         Globals.vars.map_area.addEventListener(MouseEvent.MOUSE_MOVE, theMap.mouseMoveHandler);
133                         Globals.vars.map_area.addEventListener(MouseEvent.MOUSE_DOWN, theMap.mouseDownHandler);
134
135                         // keyboard event attached to stage
136                         stage.addEventListener(KeyboardEvent.KEY_UP, theMap.keyUpHandler);
137
138                         // example listener event
139                         var myListenerObj:Object = new Object();
140                         myListenerObj.mapHandler=function(event:MapEvent):void {
141                                 Globals.vars.debug.appendText("Download event fired - "+event.params.minlat+","+event.params.minlon+"\n");
142                         };
143                         theMap.addEventListener(MapEvent.DOWNLOAD, myListenerObj.mapHandler);
144
145                         // add debug field
146                         var t:TextField=new TextField();
147                         t.width=500; t.height=150; t.border=true;
148                         t.multiline=true;
149                         _root.addChild(t);
150                         Globals.vars.debug=t;
151             t.visible = loaderInfo.parameters["show_debug"] == 'true';
152                         Globals.vars.root=theMap;       // just for the addDebug function
153
154             var controller:EditController = new EditController(theMap, tagViewer);
155             controller.setActive();
156             
157             var conn:Connection = Connection.getConnectionInstance();
158             conn.addEventListener(Connection.LOAD_STARTED, onDataStart);
159             conn.addEventListener(Connection.LOAD_COMPLETED, onDataComplete);
160                 }
161
162         public function onResizeMap():void {
163             if ( theMap != null )
164                 theMap.updateSize(map_area.width, map_area.height);
165         }
166
167         private function onDataStart(event:Event):void {
168             dataWorking.text = event.type == Connection.LOAD_STARTED ? "Loading data..." : "Saving Data...";
169             dataWorking.visible = true;
170         }
171         private function onDataComplete(event:Event):void {
172             dataWorking.visible = false;
173         }
174         ]]></mx:Script>
175
176 </mx:Application>
177