<!--
Description:
  The pitch container with
  * BPM display with Sync/Reset button overlay (Master sync on long-press)
  * Key display with Match/Reset and up/down button overlays
  * Pitch slider
  (* key offset indicator, not working reliably)
Variables:
  chanNum : channel number
  group   : [ChannelXY]
-->
<Template>
  <WidgetGroup><!-- RateContainer -->
    <ObjectName>RateContainer<Variable name="chanNum" /></ObjectName>
    <Layout>vertical</Layout>
    <Size>min,me</Size>
    <Children>
      <WidgetGroup><!-- BPM, Key & Pitch fader -->
        <ObjectName>RateControls</ObjectName>
        <Layout>vertical</Layout>
        <Size>50f,136f</Size>
        <Children>

          <WidgetGroup><!-- Key Display/Match + Key adjust buttons -->
            <Layout>vertical</Layout>
            <Children>
              <WidgetGroup><!-- Key adjust buttons -->
                <ObjectName>KeyControls</ObjectName>
                <Layout>horizontal</Layout>
                <Size>1me,14f</Size>
                <Children>
                  <Template src="skin:button_1state_right.xml">
                    <SetVariable name="TooltipId">pitch_down</SetVariable>
                    <SetVariable name="ObjectName">KeyDown</SetVariable>
                    <SetVariable name="Size">12me,13f</SetVariable>
                    <SetVariable name="ConfigKey"><Variable name="group"/>,pitch_down</SetVariable>
                    <SetVariable name="ConfigKeyRight"><Variable name="group"/>,pitch_down_small</SetVariable>
                  </Template>

                  <WidgetGroup><Size>2f,1min</Size></WidgetGroup>

                  <Template src="skin:button_1state_right.xml">
                    <SetVariable name="TooltipId">pitch_up</SetVariable>
                    <SetVariable name="ObjectName">KeyUp</SetVariable>
                    <SetVariable name="Size">12me,13f</SetVariable>
                    <SetVariable name="ConfigKey"><Variable name="group"/>,pitch_up</SetVariable>
                    <SetVariable name="ConfigKeyRight"><Variable name="group"/>,pitch_up_small</SetVariable>
                  </Template>
                </Children>
                <Connection>
                  <ConfigKey persist="true">[Tango],rate_key_controls</ConfigKey>
                  <BindProperty>visible</BindProperty>
                </Connection>
              </WidgetGroup><!-- /Key adjust buttons -->

              <WidgetGroup><!-- Key Display/Match -->
                <ObjectName>KeyDisplayMatch</ObjectName>
                <Layout>stacked</Layout>
                <Size>1me,14f</Size>
                <Children>
                  <!-- KeyMatch, transparent -->
                  <Template src="skin:button_1state_right.xml">
                    <SetVariable name="TooltipId">sync_reset_key</SetVariable>
                    <SetVariable name="ObjectName">KeyMatch</SetVariable>
                    <SetVariable name="Size">26me,13f</SetVariable>
                    <SetVariable name="ConfigKey"><Variable name="group"/>,sync_key</SetVariable>
                    <SetVariable name="ConfigKeyRight"><Variable name="group"/>,reset_key</SetVariable>
                  </Template>

                  <!-- Show/light up if key is not original, like with script.
                        Not working, only once per skin load.
                      Tried different controls: pitch (from script), pitch_adjust, ...
                  <WidgetGroup>
                    <ObjectName>KeyOffsetWarning</ObjectName>
                    <Size>50f,13f</Size>
                    <Layout>horizontal</Layout>
                    <Connection>
                      <ConfigKey><Variable name="group"/>,visual_key</ConfigKey>
                      <Transform><Not/><IsEqual>1</IsEqual></Transform>
                      <BindProperty>visible</BindProperty>
                    </Connection>
                  </WidgetGroup> -->

                  <Key><!-- Actual Key display -->
                    <TooltipId>visual_key</TooltipId>
                    <ObjectName>KeyDisplay</ObjectName>
                    <Channel><Variable name="chanNum"/></Channel>
                    <Size>50f,13f</Size>
                    <Alignment>center</Alignment>
                    <Elide>right</Elide>
                    <Connection>
                      <ConfigKey><Variable name="group"/>,visual_key</ConfigKey>
                    </Connection>
                  </Key>
                </Children>
              </WidgetGroup><!-- /Key Display/Match -->
            </Children>
            <Connection>
              <ConfigKey persist="true">[Tango],key_display_match</ConfigKey>
              <BindProperty>visible</BindProperty>
            </Connection>
          </WidgetGroup><!-- /Key Display/Match + Key adjust buttons -->

          <WidgetGroup><!-- BPM display & invisble sync button -->
            <ObjectName>BPM</ObjectName>
            <Layout>stacked</Layout>
            <MinimumSize>50,18</MinimumSize>
            <MaximumSize>50,25</MaximumSize>
            <SizePolicy>f,min</SizePolicy>
            <Children>
              <Template src="skin:button_2state_right.xml">
                <SetVariable name="TooltipId">sync_enabled</SetVariable>
                <SetVariable name="ObjectName">SyncButtonOverlay</SetVariable>
                <SetVariable name="Size">50f,18min</SetVariable>
                <SetVariable name="ConfigKey"><Variable name="group"/>,sync_enabled</SetVariable>
                <SetVariable name="ConfigKeyRight"><Variable name="group"/>,beatsync_phase</SetVariable>
              </Template>
              <Number>
                <ObjectName>BpmLabel</ObjectName>
                <Size>50f,18min</Size>
                <TooltipId>visual_bpm</TooltipId>
                <Channel><Variable name="chanNum" /></Channel>
                <NumberOfDigits>1</NumberOfDigits>
                <Connection>
                  <ConfigKey><Variable name="group"/>,visual_bpm</ConfigKey>
                </Connection>
              </Number>
            </Children>
          </WidgetGroup><!-- /BPM display & invisble sync button -->

          <WidgetGroup><!-- Rate adjust buttons -->
            <Layout>horizontal</Layout>
            <Size>50f,14f</Size>
            <Children>
              <WidgetGroup>
                <ObjectName>RateButtons</ObjectName>
                <Layout>horizontal</Layout>
                <Size>50f,14f</Size>
                <Children>
                  <Template src="skin:button_1state_right.xml">
                    <SetVariable name="TooltipId">rate_temp_down_rate_temp_down_small</SetVariable>
                    <SetVariable name="ObjectName">RateDown</SetVariable>
                    <SetVariable name="Size">13me,13f</SetVariable>
                    <SetVariable name="ConfigKey"><Variable name="group"/>,rate_temp_down</SetVariable>
                    <SetVariable name="ConfigKeyRight"><Variable name="group"/>,rate_temp_down_small</SetVariable>
                  </Template>

                  <WidgetGroup><Size>2f,1min</Size></WidgetGroup>

                  <Template src="skin:button_1state_right.xml">
                    <SetVariable name="TooltipId">rate_temp_up_rate_temp_up_small</SetVariable>
                    <SetVariable name="ObjectName">RateUp</SetVariable>
                    <SetVariable name="Size">13me,13f</SetVariable>
                    <SetVariable name="ConfigKey"><Variable name="group"/>,rate_temp_up</SetVariable>
                    <SetVariable name="ConfigKeyRight"><Variable name="group"/>,rate_temp_up_small</SetVariable>
                  </Template>
                </Children>
              </WidgetGroup>
            </Children>
            <Connection>
              <ConfigKey persist="true">[Tango],rate_key_controls</ConfigKey>
              <BindProperty>visible</BindProperty>
            </Connection>
          </WidgetGroup><!-- /Rate adjust buttons -->

          <SliderComposed>
            <ObjectName>PitchSlider</ObjectName>
            <MinimumSize>50,75</MinimumSize>
            <MaximumSize>50,136</MaximumSize>
            <SizePolicy>f,me</SizePolicy>
            <TooltipId>rate</TooltipId>
            <Handle scalemode="STRETCH_ASPECT">knobs_sliders/pitch_handle.svg</Handle>
            <Slider scalemode="STRETCH">knobs_sliders/pitch_scale.svg</Slider>
            <Horizontal>false</Horizontal>
            <Connection>
              <ConfigKey><Variable name="group"/>,rate</ConfigKey>
            </Connection>
          </SliderComposed><!-- /PitchSlider -->

        </Children>
      </WidgetGroup><!-- /BPM, Key & Pitch fader -->

      <WidgetGroup><Size>0min,0me</Size></WidgetGroup>

    </Children>
    <Connection>
      <ConfigKey>[Master],show_rate_control</ConfigKey>
      <BindProperty>visible</BindProperty>
    </Connection>
  </WidgetGroup><!-- /RateContainer -->
</Template>
