MapCSS in progress. Vast amounts still to do, but the meat of it is here. POIs are...
[potlatch2.git] / halcyon.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
61         public var theMap:Map;
62
63                 private function initApp():void {
64
65                         Globals.vars.map_area=map_area;
66                         Globals.vars.root=map_area.rawChildren;                 // set up global reference to root level
67                         var _root:IChildList=map_area.rawChildren;              // convenient local shorthand
68
69                         // map backdrop object
70             var w:uint = map_area.width;
71             var h:uint = map_area.height;
72             var b:Sprite = new Sprite();
73             b.height=h; b.width=w;
74             b.graphics.beginFill(0xFFFFEA,100); 
75             b.graphics.drawRect(0,0,w,h); 
76             b.graphics.endFill();
77                         _root.addChild(b);
78
79                         // add map
80                         theMap=new Map(this.loaderInfo.parameters);
81                         theMap.backdrop=b;
82                         _root.addChild(theMap);
83             theMap.updateSize(w, h);
84
85                         // add mask for map
86                         var s:Sprite=new Sprite();
87                         s.graphics.beginFill(0xFFFFFF,100);
88                         s.graphics.drawRect(0,0,w,h);
89                         s.graphics.endFill();
90                         _root.addChild(s);
91                         theMap.mask=s;
92
93                         // add crosshair
94                         /*s=new Sprite();
95                         s.graphics.lineStyle(2,0);
96                         s.graphics.moveTo(stage.stageWidth/2-20,stage.stageHeight/2);
97                         s.graphics.lineTo(stage.stageWidth/2+20,stage.stageHeight/2);
98                         s.graphics.moveTo(stage.stageWidth/2,stage.stageHeight/2-20);
99                         s.graphics.lineTo(stage.stageWidth/2,stage.stageHeight/2+20);
100                         _root.addChild(s);*/
101
102                         // mouse-up handler attached to stage, so the user can release outside the map
103                         stage.addEventListener(MouseEvent.MOUSE_UP, theMap.mouseUpHandler);
104                         Globals.vars.map_area.addEventListener(MouseEvent.MOUSE_MOVE, theMap.mouseMoveHandler);
105                         Globals.vars.map_area.addEventListener(MouseEvent.MOUSE_DOWN, theMap.mouseDownHandler);
106
107                         // keyboard event attached to stage
108                         stage.addEventListener(KeyboardEvent.KEY_UP, theMap.keyUpHandler);
109
110                         // example listener event
111                         var myListenerObj:Object = new Object();
112                         myListenerObj.mapHandler=function(event:MapEvent):void {
113                                 Globals.vars.debug.appendText("Download event fired - "+event.minlat+","+event.minlon+"\n");
114                         };
115                         theMap.addEventListener(MapEvent.DOWNLOAD, myListenerObj.mapHandler);
116
117                         // add debug field
118                         var t:TextField=new TextField();
119                         t.width=400; t.height=100; t.border=true;
120                         t.multiline=true;
121                         _root.addChild(t);
122                         Globals.vars.debug=t;
123             t.visible = loaderInfo.parameters["show_debug"] == 'true';
124                         Globals.vars.root=theMap;       // just for the addDebug function
125
126             var controller:EditController = new EditController(theMap, tagViewer);
127             controller.setActive();
128             
129             var conn:Connection = Connection.getConnectionInstance();
130             conn.addEventListener(Connection.LOAD_STARTED, onDataStart);
131             conn.addEventListener(Connection.LOAD_COMPLETED, onDataComplete);
132                 }
133
134         public function onResizeMap():void {
135             if ( theMap != null )
136                 theMap.updateSize(map_area.width, map_area.height);
137         }
138
139         private function onDataStart(event:Event):void {
140             dataWorking.text = event.type == Connection.LOAD_STARTED ? "Loading data..." : "Saving Data...";
141             dataWorking.visible = true;
142         }
143         private function onDataComplete(event:Event):void {
144             dataWorking.visible = false;
145         }
146         ]]></mx:Script>
147
148 </mx:Application>
149