<?xml version="1.0"?>

<PropertyList>
  <name>input-config</name>
  <default-padding>3</default-padding>

  <nasal>
    <open>
        var syncRadioState = func()
        {
            var cycle = getprop("/sim/mouse/right-button-mode-cycle-enabled");
            setprop("/sim/gui/dialogs/input-config/right-mouse-look", !cycle);
            setprop("/sim/gui/dialogs/input-config/right-mouse-cycle", cycle);
        }

        var rightMouseMode = func(newMode)
        {
            var doCycle = (newMode == "cycle");
            setprop("/sim/mouse/right-button-mode-cycle-enabled", doCycle);
            syncRadioState();
        }

        syncRadioState();
    </open>
  </nasal>

  <modal>false</modal>
  <layout>vbox</layout>

  <!-- start group 1 -->
  <group>
    <layout>hbox</layout>
    <empty><stretch>1</stretch></empty>

    <text>
      <label>Mouse Input Options</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/>

  <!-- start group 2 -->
  <group>
    <halign>left</halign>
    <valign>top</valign>
    <layout>table</layout>

    <!-- gap to left border -->
    <text>
      <halign>left</halign>
      <label> </label>
      <row>0</row>
      <col>0</col>
    </text>

    <text>
      <halign>left</halign>
      <label>Pressing TAB cycles the mouse mode through different behaviours </label>
      <row>0</row>
      <col>1</col>
    </text>
    <text>
      <label>normal / flight-controls / view direction</label>
      <row>1</row>
      <col>1</col>
    </text>

    <text>
      <halign>left</halign>
      <label> </label>
      <row>2</row>
      <col>1</col>
    </text>

    <text>
      <halign>left</halign>
      <label>The right-mouse button can be used in two different ways:</label>
      <row>3</row>
      <col>1</col>
    </text>

  <!-- end group 2 -->
  </group>

  <!-- start group 3 -->
  <group>
    <halign>left</halign>
    <valign>top</valign>
    <layout>table</layout>

    <!-- gap to left border -->
    <text>
      <halign>left</halign>
      <label>   </label>
      <row>0</row>
      <col>0</col>
    </text>

    <radio>
      <halign>left</halign>
      <label> Press and hold right mouse to look around</label>
      <property>/sim/gui/dialogs/input-config/right-mouse-look</property>
      <live>true</live>
      <binding>
        <command>nasal</command>
        <script>rightMouseMode("look")</script>
      </binding>
      <row>0</row>
      <col>1</col>
    </radio>

    <radio>
      <halign>left</halign>
      <label> Click right mouse to cycle mouse behaviour</label>
      <property>/sim/gui/dialogs/input-config/right-mouse-cycle</property>
      <live>true</live>
      <binding>
        <command>nasal</command>
        <script>rightMouseMode("cycle")</script>
      </binding>
      <row>1</row>
      <col>1</col>
    </radio>

    <!-- empty line before next -->
    <text>
      <row>3</row>
      <col>0</col>
      <label> </label>
      <halign>left</halign>
    </text>

  <!-- end group 3 -->
  </group>

  <!-- start group 4 -->
  <group>

    <halign>left</halign>
    <valign>top</valign>
    <layout>table</layout>

    <!-- gap to left border -->
    <text>
        <halign>left</halign>
        <label>   </label>
        <row>0</row>
        <col>0</col>
    </text>

    <checkbox>
      <halign>left</halign>
      <label> Disable flight-controls via mouse</label>
      <property>/sim/mouse/skip-flight-controls-mode</property>
      <binding>
        <command>dialog-apply</command>
      </binding>
      <row>0</row>
      <col>1</col>
    </checkbox>

    <text>
      <halign>left</halign>
      <label>Flight controls sensitivity</label>
      <row>1</row>
      <col>1</col>
    </text>
    <slider>
      <halign>left</halign>
      <min>0.1</min>
      <max>4.0</max>
      <step>0.1</step>
      <property>/sim/mouse/flight-controls-sensitivity</property>
      <binding>
        <command>dialog-apply</command>
      </binding>
      <row>1</row>
      <col>2</col>
    </slider>
    <text>
      <halign>left</halign>
      <format>%1.1f</format>
      <property>/sim/mouse/flight-controls-sensitivity</property>
      <live>true</live>
      <row>1</row>
      <col>3</col>
    </text>

    <!-- empty line before next -->
    <text>
      <row>2</row>
      <col>0</col>
      <label> </label>
      <halign>left</halign>
    </text>

  <!-- end group 4 -->
  </group>

  <!-- start group 5 -->
  <group>

    <halign>left</halign>
    <valign>top</valign>
    <layout>table</layout>

    <!-- gap to left border -->
    <text>
        <halign>left</halign>
        <label>   </label>
        <row>0</row>
        <col>0</col>
    </text>

    <checkbox>
      <halign>left</halign>
      <label> Reverse mouse wheel direction</label>
      <property>/sim/mouse/invert-mouse-wheel</property>
      <binding>
        <command>dialog-apply</command>
      </binding>
      <row>0</row>
      <col>1</col>
    </checkbox>

  <!-- end group 5 -->
  </group>

  <!-- start group 6 -->
  <group>

    <halign>left</halign>
    <valign>top</valign>
    <layout>table</layout>

    <!-- gap to left border -->
    <text>
        <halign>left</halign>
        <label>   </label>
        <row>0</row>
        <col>0</col>
    </text>

    <checkbox>
      <halign>left</halign>
      <label> Mouse rudder also controls elevator</label>
      <property>/sim/mouse/mouse-rudder-elevator</property>
      <binding>
        <command>dialog-apply</command>
      </binding>
      <row>0</row>
      <col>1</col>
    </checkbox>

    <!-- empty line before next -->
    <text>
      <row>1</row>
      <col>0</col>
      <label> </label>
      <halign>left</halign>
    </text>

  <!-- end group 6 -->
  </group>

  <hrule/>

  <button>
    <legend>Close</legend>
    <default>true</default>
    <key>Esc</key>
    <binding>
      <command>dialog-apply</command>
    </binding>
    <binding>
      <command>dialog-close</command>
    </binding>
  </button>

</PropertyList>