Merge branch 'master' into history
[potlatch2.git] / net / systemeD / potlatch2 / options / OptionsDialog.mxml
1 <?xml version="1.0" encoding="utf-8"?>
2 <mx:TitleWindow
3         xmlns:fx="http://ns.adobe.com/mxml/2009"
4         xmlns:mx="library://ns.adobe.com/flex/mx"
5         layout="vertical" showCloseButton="true"
6         horizontalAlign="center" title="Options"
7         width="350" height="250" verticalGap="0">
8   <fx:Script><![CDATA[
9     import mx.managers.PopUpManager;
10     import mx.events.CloseEvent;
11     import mx.core.Application;
12     import mx.core.FlexGlobals;
13     import net.systemeD.halcyon.Globals;
14     import net.systemeD.halcyon.Map;
15     import net.systemeD.halcyon.connection.Connection;
16     import net.systemeD.halcyon.connection.StatusFetcher;
17
18         private var userState:SharedObject=SharedObject.getLocal("user_state");
19     
20     public function init():void {
21         PopUpManager.addPopUp(this, Application(FlexGlobals.topLevelApplication), true);
22         PopUpManager.centerPopUp(this);
23         this.addEventListener(CloseEvent.CLOSE, optionsDialog_close);
24
25         tbcheck.selected = FlexGlobals.topLevelApplication.toolbox.visible;
26         cursorcheck.selected = FlexGlobals.topLevelApplication.theController.cursorsEnabled;
27         tigercheck.selected = userState.data['tiger_highlighted'];
28         latlongcheck.selected = FlexGlobals.topLevelApplication.coordsbox.visible;
29                 licencecheck.selected = Map(Globals.vars.root).editableLayer.connection.statusFetcher!=null;
30                 simplifyslider.value = userState.data['simplify_tolerance'] ? userState.data['simplify_tolerance']/0.00001 : 5;
31     }
32     
33     private function optionsDialog_close(evt:CloseEvent):void {
34         PopUpManager.removePopUp(this);
35     }
36
37     private function tigerToggle():void {
38         Globals.vars.highlightTiger = tigercheck.selected;
39         FlexGlobals.topLevelApplication.theMap.redraw();
40
41         userState.setProperty("tiger_highlighted",tigercheck.selected);
42         userState.flush();
43     }
44
45         private function simplifySet():void {
46         userState.setProperty("simplify_tolerance",simplifyslider.value*0.00001);
47         userState.flush();
48         }
49
50         private function licenceToggle():void {
51                 // ** FIXME: this is an inelegant patch for the short-term issue of highlighting licensing status
52                 var conn:Connection=Map(Globals.vars.root).editableLayer.connection;
53                 if (conn.statusFetcher) {
54                         conn.statusFetcher=null;
55                         userState.setProperty("licence_status",false);
56                 } else {
57                         conn.statusFetcher=new StatusFetcher("http://wtfe.gryph.de/api/0.6/problems",conn);
58                         conn.statusFetcher.fetch(conn.getAllLoadedEntities());
59                         userState.setProperty("licence_status",true);
60                         // ** FIXME: needs to also switch map style
61                 }
62         }
63         
64               ]]>
65   </fx:Script>
66         <mx:CheckBox width="100%" label="Show toolbox" selected="true" id="tbcheck"
67             change="FlexGlobals.topLevelApplication.toolbox.toggle()" />
68
69         <mx:CheckBox width="100%" label="Use custom cursors" selected="true" id="cursorcheck"
70             change="FlexGlobals.topLevelApplication.theController.cursorsEnabled=cursorcheck.selected" />
71
72     <mx:CheckBox width="100%" label="Highlight unedited TIGER (US roads)" selected="false" id="tigercheck"
73         change="tigerToggle()" />
74
75         <mx:CheckBox width="100%" label="Show mouse latitude/longitude" selected="false" id="latlongcheck" 
76                 change="FlexGlobals.topLevelApplication.coordsbox.visible=latlongcheck.selected" />
77
78     <mx:CheckBox width="100%" label="Show licence status" selected="false" id="licencecheck"
79         change="licenceToggle()" />
80
81         <mx:HBox width="100%" verticalAlign="middle">
82     <mx:Label text="Simplify accuracy: "/>
83         <mx:HSlider id="simplifyslider"
84                 minimum="1" maximum="5"
85                 dataTipPlacement="top" tickColor="black" labels="[High,Low]" 
86                 snapInterval="1" tickInterval="1"
87                 allowTrackClick="true" liveDragging="true"
88                 change="simplifySet();"/>
89         </mx:HBox>
90
91   <mx:ControlBar>
92     <mx:Spacer width="100%"/>
93     <mx:Button id="ok" label="Ok" click="PopUpManager.removePopUp(this);" styleName="titleWindowButton" />
94   </mx:ControlBar>
95
96 </mx:TitleWindow>