Merge branch 'master' of github.com:systemed/potlatch2
[potlatch2.git] / net / systemeD / potlatch2 / dialogs / OptionsDialog.mxml
1 <?xml version="1.0" encoding="utf-8"?>
2 <s:TitleWindow
3         xmlns:fx="http://ns.adobe.com/mxml/2009"
4         xmlns:mx="library://ns.adobe.com/flex/mx"
5         xmlns:s="library://ns.adobe.com/flex/spark"
6         title="Options"
7         width="350" height="250">
8
9     <s:layout>
10       <s:VerticalLayout
11           paddingLeft="5" paddingRight="5"
12           paddingTop="5" paddingBottom="5" />
13     </s:layout>
14
15         <s:CheckBox width="100%" label="Show toolbox" selected="true" id="tbcheck"
16             change="FlexGlobals.topLevelApplication.toolbox.toggle()" />
17
18         <s:CheckBox width="100%" label="Use custom cursors" selected="true" id="cursorcheck"
19             change="FlexGlobals.topLevelApplication.theController.cursorsEnabled=cursorcheck.selected" />
20
21     <s:CheckBox width="100%" label="Highlight unedited TIGER (US roads)" selected="false" id="tigercheck"
22         change="tigerToggle()" />
23
24     <s:CheckBox width="100%" label="Show contextual help" selected="true" id="contextcheck"
25         change="contextToggle()" />
26
27         <s:CheckBox width="100%" label="Show mouse latitude/longitude" selected="false" id="latlongcheck"
28                 change="FlexGlobals.topLevelApplication.coordsbox.visible=latlongcheck.selected" />
29
30         <s:HGroup width="100%" verticalAlign="middle">
31       <s:Label text="Simplify accuracy: "/>
32       <mx:HSlider id="simplifyslider"
33                 minimum="1" maximum="5"
34                 dataTipPlacement="top" tickColor="black" labels="[High,Low]"
35                 snapInterval="1" tickInterval="1"
36                 allowTrackClick="true" liveDragging="true"
37                 change="simplifySet();"/>
38         </s:HGroup>
39
40     <s:controlBarContent>
41       <s:Button id="ok" label="OK" click="PopUpManager.removePopUp(this);" styleName="titleWindowButton" />
42     </s:controlBarContent>
43
44     <s:controlBarLayout>
45       <s:HorizontalLayout horizontalAlign="right"
46           paddingLeft="5" paddingRight="5"
47           paddingTop="5" paddingBottom="5" />
48     </s:controlBarLayout>
49
50   <fx:Script><![CDATA[
51     import mx.managers.PopUpManager;
52     import mx.events.CloseEvent;
53     import mx.core.Application;
54     import mx.core.FlexGlobals;
55     import net.systemeD.halcyon.Globals;
56     import net.systemeD.halcyon.Map;
57     import net.systemeD.halcyon.connection.Connection;
58     import net.systemeD.halcyon.connection.StatusFetcher;
59
60         private var userState:SharedObject=SharedObject.getLocal("user_state","/");
61     
62     public function init():void {
63         PopUpManager.addPopUp(this, Application(FlexGlobals.topLevelApplication), true);
64         PopUpManager.centerPopUp(this);
65         this.addEventListener(CloseEvent.CLOSE, optionsDialog_close);
66
67         tbcheck.selected = FlexGlobals.topLevelApplication.toolbox.visible;
68         cursorcheck.selected = FlexGlobals.topLevelApplication.theController.cursorsEnabled;
69         tigercheck.selected = userState.data['tiger_highlighted'];
70         latlongcheck.selected = FlexGlobals.topLevelApplication.coordsbox.visible;
71                 contextcheck.selected = FlexGlobals.topLevelApplication.contextHelp.visible;
72                 simplifyslider.value = userState.data['simplify_tolerance'] ? userState.data['simplify_tolerance']/0.00001 : 5;
73     }
74     
75     private function optionsDialog_close(evt:CloseEvent):void {
76         PopUpManager.removePopUp(this);
77     }
78
79     private function tigerToggle():void {
80         Globals.vars.highlightTiger = tigercheck.selected;
81         FlexGlobals.topLevelApplication.theMap.redraw();
82
83         userState.setProperty("tiger_highlighted",tigercheck.selected);
84         try { userState.flush(); } catch (e:Error) {}
85     }
86
87         private function contextToggle():void {
88                 FlexGlobals.topLevelApplication.contextHelp.visible = contextcheck.selected;
89                 FlexGlobals.topLevelApplication.contextHelp.height  = contextcheck.selected ? 30 : 0;
90                 userState.setProperty("hide_context_help",!contextcheck.selected);
91                 try { userState.flush(); } catch (e:Error) {}
92         }
93
94         private function simplifySet():void {
95         userState.setProperty("simplify_tolerance",simplifyslider.value*0.00001);
96         try { userState.flush(); } catch (e:Error) {}
97         }
98         
99               ]]>
100   </fx:Script>
101 </s:TitleWindow>