<?xml version="1.0"?>

<PropertyList>
    <name>pilot_offset</name>
    <layout>vbox</layout>
    <width>450</width>
    <nasal>
        <open>
            <![CDATA[
                var view_listener = setlistener("sim/current-view/view-number-raw", func(n) {
                    var x = getprop("sim/view["~int(n.getValue())~"]/config/x-offset-m");
                    var y = getprop("sim/view["~int(n.getValue())~"]/config/y-offset-m");
                    var z = getprop("sim/view["~int(n.getValue())~"]/config/z-offset-m");
                    setprop("sim/current-view/config/x-offset-m", x);
                    setprop("sim/current-view/config/y-offset-m", y);
                    setprop("sim/current-view/config/z-offset-m", z);

                },1,0);
            ]]>
        </open>
        <close>
            <![CDATA[
                removelistener(view_listener);
                props.getNode("sim/current-view/config/x-offset-m").remove();
                props.getNode("sim/current-view/config/y-offset-m").remove();
                props.getNode("sim/current-view/config/z-offset-m").remove();
            ]]>
        </close>
    </nasal>

    <group>
        <layout>hbox</layout>
        <empty><stretch>1</stretch></empty>
        <text>
            <label>Adjust View Position</label>
        </text>
        <empty><stretch>1</stretch></empty>
        <button>
            <pref-width>16</pref-width>
            <pref-height>16</pref-height>
            <legend></legend>
            <keynum>27</keynum>
            <border>2</border>
            <binding>
                <command>dialog-close</command>
            </binding>
        </button>
    </group>

    <hrule/>

    <group>
        <layout>table</layout>
        <text>
            <row>0</row>
            <col>0</col>
            <label>left</label>
        </text>
        <button>
            <row>0</row>
            <col>1</col>
            <pref-width>25</pref-width>
            <pref-height>25</pref-height>
            <legend>&lt;&lt;</legend>
            <binding>
                <command>property-adjust</command>
                <property>/sim/current-view/x-offset-m</property>
                <step>-0.1</step>
            </binding>
        </button>
        <button>
            <row>0</row>
            <col>2</col>
            <pref-width>25</pref-width>
            <pref-height>25</pref-height>
            <legend>&lt;</legend>
            <binding>
                <command>property-adjust</command>
                <property>/sim/current-view/x-offset-m</property>
                <step>-0.01</step>
            </binding>
        </button>
        <input>
            <row>0</row>
            <col>3</col>
            <name>offset-x</name>
            <pref-width>65</pref-width>
            <label>m</label>
            <live>true</live>
            <property>/sim/current-view/x-offset-m</property>
            <binding>
                <command>dialog-apply</command>
                <object-name>offset-x</object-name>
            </binding>
        </input>

        <button>
            <row>0</row>
            <col>4</col>
            <pref-width>25</pref-width>
            <pref-height>25</pref-height>
            <legend>&gt;</legend>
            <binding>
                <command>property-adjust</command>
                <property>/sim/current-view/x-offset-m</property>
                <step>0.01</step>
            </binding>
        </button>
        <button>
            <row>0</row>
            <col>5</col>
            <pref-width>25</pref-width>
            <pref-height>25</pref-height>
            <legend>&gt;&gt;</legend>
            <binding>
                <command>property-adjust</command>
                <property>/sim/current-view/x-offset-m</property>
                <step>0.1</step>
            </binding>
        </button>
        <text>
            <row>0</row>
            <col>6</col>
            <label>right</label>
        </text>
        <button>
            <row>0</row>
            <col>7</col>
            <legend>Reset</legend>
            <binding>
                <command>property-assign</command>
                <property>/sim/current-view/x-offset-m</property>
                <property>/sim/current-view/config/x-offset-m</property>
            </binding>
        </button>

        
        <text>
            <row>1</row>
            <col>0</col>
            <label>down</label>
        </text>
        <button>
            <row>1</row>
            <col>1</col>
            <pref-width>25</pref-width>
            <pref-height>25</pref-height>
            <legend>&lt;&lt;</legend>
            <binding>
                <command>property-adjust</command>
                <property>/sim/current-view/y-offset-m</property>
                <step>-0.1</step>
            </binding>
        </button>
        <button>
            <row>1</row>
            <col>2</col>
            <pref-width>25</pref-width>
            <pref-height>25</pref-height>
            <legend>&lt;</legend>
            <binding>
                <command>property-adjust</command>
                <property>/sim/current-view/y-offset-m</property>
                <step>-0.01</step>
            </binding>
        </button>
        <input>
            <row>1</row>
            <col>3</col>
            <name>offset-y</name>
            <pref-width>65</pref-width>
            <label>m </label>
            <live>true</live>
            <property>/sim/current-view/y-offset-m</property>
            <binding>
                <command>dialog-apply</command>
                <object-name>offset-y</object-name>
            </binding>
        </input>

        <button>
            <row>1</row>
            <col>4</col>
            <pref-width>25</pref-width>
            <pref-height>25</pref-height>
            <legend>&gt;</legend>
            <binding>
                <command>property-adjust</command>
                <property>/sim/current-view/y-offset-m</property>
                <step>0.01</step>
            </binding>
        </button>
        <button>
            <row>1</row>
            <col>5</col>
            <pref-width>25</pref-width>
            <pref-height>25</pref-height>
            <legend>&gt;&gt;</legend>
            <binding>
                <command>property-adjust</command>
                <property>/sim/current-view/y-offset-m</property>
                <step>0.1</step>
            </binding>
        </button>
        <text>
            <row>1</row>
            <col>6</col>
            <label>up</label>
        </text>
        <button>
            <row>1</row>
            <col>7</col>

            <legend>Reset</legend>
            <binding>
                <command>property-assign</command>
                <property>/sim/current-view/y-offset-m</property>
                <property>/sim/current-view/config/y-offset-m</property>
            </binding>
        </button>

        <text>
            <row>2</row>
            <col>0</col>
            <label>fwd.</label>
        </text>
        <button>
            <row>2</row>
            <col>1</col>
            <pref-width>25</pref-width>
            <pref-height>25</pref-height>
            <legend>&lt;&lt;</legend>
            <binding>
                <command>property-adjust</command>
                <property>/sim/current-view/z-offset-m</property>
                <step>-0.1</step>
            </binding>
        </button>
        <button>
            <row>2</row>
            <col>2</col>
            <pref-width>25</pref-width>
            <pref-height>25</pref-height>
            <legend>&lt;</legend>
            <binding>
                <command>property-adjust</command>
                <property>/sim/current-view/z-offset-m</property>
                <step>-0.01</step>
            </binding>
        </button>
        <input>
            <row>2</row>
            <col>3</col>
            <name>offset-z</name>
            <pref-width>65</pref-width>
            <label>m</label>
            <live>true</live>
            <property>/sim/current-view/z-offset-m</property>
            <binding>
                <command>dialog-apply</command>
                <object-name>offset-z</object-name>
            </binding>
        </input>
        <button>
            <row>2</row>
            <col>4</col>
            <pref-width>25</pref-width>
            <pref-height>25</pref-height>
            <legend>&gt;</legend>
            <binding>
                <command>property-adjust</command>
                <property>/sim/current-view/z-offset-m</property>
                <step>0.01</step>
            </binding>
        </button>
        <button>
            <row>2</row>
            <col>5</col>
            <pref-width>25</pref-width>
            <pref-height>25</pref-height>
            <legend>&gt;&gt;</legend>
            <binding>
                <command>property-adjust</command>
                <property>/sim/current-view/z-offset-m</property>
                <step>0.1</step>
            </binding>
        </button>
        <text>
            <row>2</row>
            <col>6</col>
            <label>back</label>
        </text>        
        <button>
            <row>2</row>
            <col>7</col>
            <legend>Reset</legend>
            <binding>
                <command>property-assign</command>
                <property>/sim/current-view/z-offset-m</property>
                <property>/sim/current-view/config/z-offset-m</property>
            </binding>
        </button>
    </group>

    <hrule/>

    <group>
        <layout>hbox</layout>
        <empty><stretch>true</stretch></empty>
        <button>
            <legend>Close</legend>
            <equal>true</equal>
            <default>true</default>
            <key>Esc</key>
            <binding><command>dialog-apply</command></binding>
            <binding><command>dialog-close</command></binding>
        </button>
        <empty><stretch>true</stretch></empty>
    </group>
</PropertyList>