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