Time dialog refinements.
Added combobox for the month (using name). Added sliders for all date components (year is between 1971 and 2037 to avoid invalid values in time_t). Relabelled easing, added a bit of layout context with some ruling.
This commit is contained in:
parent
0fed5b2f6b
commit
24699c5a24
1 changed files with 169 additions and 57 deletions
|
@ -40,64 +40,142 @@
|
||||||
<stretch>true</stretch>
|
<stretch>true</stretch>
|
||||||
</empty>
|
</empty>
|
||||||
<group>
|
<group>
|
||||||
<layout>hbox</layout>
|
<layout>table</layout>
|
||||||
<!-- Date setting. Use the split out properties in the dialog load, this way these will remain constant when the dialog
|
<name>date_group</name>
|
||||||
|
<!-- Date setting. Use the split out properties in the dialog load, this way these will remain constant when the dialog
|
||||||
is opened. Set these automatically when changed - however there appears to be a timezone/dst issue that subtracts an hour.
|
is opened. Set these automatically when changed - however there appears to be a timezone/dst issue that subtracts an hour.
|
||||||
-->
|
-->
|
||||||
<group>
|
<text>
|
||||||
<layout>vbox</layout>
|
<row>0</row>
|
||||||
<text>
|
<col>0</col>
|
||||||
<label>Year</label>
|
<label>Year</label>
|
||||||
</text>
|
</text>
|
||||||
<input>
|
|
||||||
<property>/sim/time/demand-year</property>
|
|
||||||
<binding>
|
|
||||||
<command>dialog-apply</command>
|
|
||||||
</binding>
|
|
||||||
<binding>
|
|
||||||
<command>nasal</command>
|
|
||||||
<script>
|
|
||||||
setprop("/sim/time/gmt",getprop("/sim/time/demand-year")~"-"~getprop("/sim/time/demand-month")~"-"~getprop("/sim/time/demand-day")~"T "~substr(getprop("/sim/time/gmt"),11));
|
|
||||||
</script>
|
|
||||||
</binding>
|
|
||||||
</input>
|
|
||||||
</group>
|
|
||||||
<group>
|
|
||||||
<layout>vbox</layout>
|
|
||||||
<text>
|
|
||||||
<label>Month</label>
|
|
||||||
</text>
|
|
||||||
<input>
|
<input>
|
||||||
<property>/sim/time/demand-month</property>
|
<row>1</row>
|
||||||
<binding>
|
<col>0</col>
|
||||||
<command>dialog-apply</command>
|
<live>1</live>
|
||||||
</binding>
|
<name>demand-year</name>
|
||||||
<binding>
|
<property>/sim/time/demand-year</property>
|
||||||
<command>nasal</command>
|
|
||||||
<script>
|
|
||||||
setprop("/sim/time/gmt",getprop("/sim/time/demand-year")~"-"~getprop("/sim/time/demand-month")~"-"~getprop("/sim/time/demand-day")~"T "~substr(getprop("/sim/time/gmt"),11));
|
|
||||||
</script>
|
|
||||||
</binding>
|
|
||||||
</input>
|
|
||||||
</group>
|
|
||||||
<group>
|
|
||||||
<layout>vbox</layout>
|
|
||||||
<text>
|
|
||||||
<label>Day</label>
|
|
||||||
</text>
|
|
||||||
<input>
|
|
||||||
<property>/sim/time/demand-day</property>
|
|
||||||
<binding>
|
<binding>
|
||||||
<command>dialog-apply</command>
|
<command>dialog-apply</command>
|
||||||
|
<object-name>demand-year</object-name>
|
||||||
</binding>
|
</binding>
|
||||||
<binding>
|
<binding>
|
||||||
<command>nasal</command>
|
<command>nasal</command>
|
||||||
<script>
|
<script>
|
||||||
setprop("/sim/time/gmt",getprop("/sim/time/demand-year")~"-"~getprop("/sim/time/demand-month")~"-"~getprop("/sim/time/demand-day")~"T "~substr(getprop("/sim/time/gmt"),11));
|
tod_setdate();
|
||||||
</script>
|
</script>
|
||||||
</binding>
|
</binding>
|
||||||
</input>
|
</input>
|
||||||
</group>
|
<slider>
|
||||||
|
<row>2</row>
|
||||||
|
<col>0</col>
|
||||||
|
<name>sl_year</name>
|
||||||
|
<property>/sim/time/demand-year</property>
|
||||||
|
<live>1</live>
|
||||||
|
<min>1971</min>
|
||||||
|
<max>2037</max>
|
||||||
|
<step>1</step>
|
||||||
|
<binding>
|
||||||
|
<command>dialog-apply</command>
|
||||||
|
<object-name>sl_year</object-name>
|
||||||
|
</binding>
|
||||||
|
<binding>
|
||||||
|
<command>nasal</command>
|
||||||
|
<script>
|
||||||
|
tod_setdate();
|
||||||
|
</script>
|
||||||
|
</binding>
|
||||||
|
</slider>
|
||||||
|
<text>
|
||||||
|
<row>0</row>
|
||||||
|
<col>1</col>
|
||||||
|
<label>Month</label>
|
||||||
|
</text>
|
||||||
|
<combo>
|
||||||
|
<row>1</row>
|
||||||
|
<col>1</col>
|
||||||
|
<live>1</live>
|
||||||
|
<name>month-combo</name>
|
||||||
|
<property>/sim/time/demand-month</property>
|
||||||
|
<editable>false</editable>
|
||||||
|
<pref-width>130</pref-width>
|
||||||
|
<halign>fill</halign>
|
||||||
|
<binding>
|
||||||
|
<command>dialog-apply</command>
|
||||||
|
<object-name>month-combo</object-name>
|
||||||
|
</binding>
|
||||||
|
<binding>
|
||||||
|
<command>nasal</command>
|
||||||
|
<script>
|
||||||
|
tod_setdate();
|
||||||
|
</script>
|
||||||
|
</binding>
|
||||||
|
</combo>
|
||||||
|
<slider>
|
||||||
|
<row>2</row>
|
||||||
|
<col>1</col>
|
||||||
|
<name>sl_month</name>
|
||||||
|
<property>/sim/time/demand-month-idx</property>
|
||||||
|
<live>1</live>
|
||||||
|
<min>0</min>
|
||||||
|
<max>11</max>
|
||||||
|
<step>1</step>
|
||||||
|
<binding>
|
||||||
|
<object-name>sl_month</object-name>
|
||||||
|
<command>dialog-apply</command>
|
||||||
|
</binding>
|
||||||
|
<binding>
|
||||||
|
<command>nasal</command>
|
||||||
|
<script>
|
||||||
|
setprop("/sim/time/demand-month",months[getprop("/sim/time/demand-month-idx")]);
|
||||||
|
tod_setdate();
|
||||||
|
</script>
|
||||||
|
</binding>
|
||||||
|
</slider>
|
||||||
|
|
||||||
|
<text>
|
||||||
|
<row>0</row>
|
||||||
|
<col>2</col>
|
||||||
|
<label>Day</label>
|
||||||
|
</text>
|
||||||
|
<input>
|
||||||
|
<row>1</row>
|
||||||
|
<col>2</col>
|
||||||
|
<name>demand-day</name>
|
||||||
|
<property>/sim/time/demand-day</property>
|
||||||
|
<live>1</live>
|
||||||
|
<binding>
|
||||||
|
<command>dialog-apply</command>
|
||||||
|
<object-name>demand-day</object-name>
|
||||||
|
</binding>
|
||||||
|
<binding>
|
||||||
|
<command>nasal</command>
|
||||||
|
<script>
|
||||||
|
tod_setdate();
|
||||||
|
</script>
|
||||||
|
</binding>
|
||||||
|
</input>
|
||||||
|
<slider>
|
||||||
|
<row>2</row>
|
||||||
|
<col>2</col>
|
||||||
|
<name>sl_day</name>
|
||||||
|
<property>/sim/time/demand-day</property>
|
||||||
|
<live>1</live>
|
||||||
|
<min>1</min>
|
||||||
|
<max>31</max>
|
||||||
|
<step>1</step>
|
||||||
|
<binding>
|
||||||
|
<command>dialog-apply</command>
|
||||||
|
<object-name>sl_day</object-name>
|
||||||
|
</binding>
|
||||||
|
<binding>
|
||||||
|
<command>nasal</command>
|
||||||
|
<script>
|
||||||
|
tod_setdate();
|
||||||
|
</script>
|
||||||
|
</binding>
|
||||||
|
</slider>
|
||||||
</group>
|
</group>
|
||||||
<!-- end of date setting -->
|
<!-- end of date setting -->
|
||||||
<empty>
|
<empty>
|
||||||
|
@ -233,10 +311,18 @@
|
||||||
<pref-width>2</pref-width>
|
<pref-width>2</pref-width>
|
||||||
</empty>
|
</empty>
|
||||||
|
|
||||||
<group>
|
<vrule/>
|
||||||
<layout>vbox</layout>
|
<group>
|
||||||
|
<padding>5</padding>
|
||||||
|
<layout>vbox</layout>
|
||||||
<default-padding>0</default-padding>
|
<default-padding>0</default-padding>
|
||||||
<button>
|
<text>
|
||||||
|
<halign>center</halign>
|
||||||
|
<default-padding>0</default-padding>
|
||||||
|
<label>Time Presets</label>
|
||||||
|
</text>
|
||||||
|
<hrule/>
|
||||||
|
<button>
|
||||||
<legend>Clock Time</legend>
|
<legend>Clock Time</legend>
|
||||||
<equal>true</equal>
|
<equal>true</equal>
|
||||||
<binding>
|
<binding>
|
||||||
|
@ -318,7 +404,7 @@
|
||||||
</binding>
|
</binding>
|
||||||
</checkbox>
|
</checkbox>
|
||||||
<text>
|
<text>
|
||||||
<label>Easing</label>
|
<label>Smooth transition</label>
|
||||||
</text>
|
</text>
|
||||||
</group>
|
</group>
|
||||||
</group>
|
</group>
|
||||||
|
@ -338,13 +424,39 @@
|
||||||
<open>
|
<open>
|
||||||
<![CDATA[
|
<![CDATA[
|
||||||
# Extract the year month day into properties
|
# Extract the year month day into properties
|
||||||
var dtv = getprop("/sim/time/gmt");
|
var dlgRoot = cmdarg();
|
||||||
var year = substr(dtv,0,4);
|
var cb_month = gui.findElementByName(dlgRoot, "month-combo");
|
||||||
var month = substr(dtv,5,2);
|
var dtv = getprop("/sim/time/gmt");
|
||||||
var day = substr(dtv,8,2);
|
var year = substr(dtv,0,4);
|
||||||
setprop("/sim/time/demand-year",year);
|
var month = substr(dtv,5,2);
|
||||||
setprop("/sim/time/demand-month",month);
|
var day = substr(dtv,8,2);
|
||||||
setprop("/sim/time/demand-day",day);
|
var months = ["January","February","March","April","May","June","July","August","September","October","November","December"];
|
||||||
|
|
||||||
|
#
|
||||||
|
# populate the combo box with the months
|
||||||
|
forindex(var idx; months)
|
||||||
|
cb_month.getChild("value", idx, 1).setValue(months[idx]);
|
||||||
|
|
||||||
|
setprop("/sim/time/demand-year",year);
|
||||||
|
setprop("/sim/time/demand-month",months[month-1]);
|
||||||
|
setprop("/sim/time/demand-month-idx",month-1);
|
||||||
|
setprop("/sim/time/demand-day",day);
|
||||||
|
|
||||||
|
#
|
||||||
|
# method to set the time of day based on the dialog values
|
||||||
|
tod_setdate = func{
|
||||||
|
forindex (var idx; months) {
|
||||||
|
if (months[idx] == getprop("/sim/time/demand-month"))
|
||||||
|
month=idx+1;
|
||||||
|
}
|
||||||
|
setprop("/sim/time/demand-month-idx",month-1);
|
||||||
|
setprop("/sim/time/demand-month",months[month-1]);
|
||||||
|
var hour = substr(dtv,11,2);
|
||||||
|
var minute = substr(dtv,14,2);
|
||||||
|
var second = substr(dtv,18,2);
|
||||||
|
var new_dt=sprintf("%04d-%02d-%02dT%02d:%02d:%02d",getprop("/sim/time/demand-year"),month,getprop("/sim/time/demand-day"),hour,minute,second*1);
|
||||||
|
setprop("/sim/time/gmt",new_dt);
|
||||||
|
}
|
||||||
]]>
|
]]>
|
||||||
</open>
|
</open>
|
||||||
</nasal>
|
</nasal>
|
||||||
|
|
Loading…
Add table
Reference in a new issue