diff --git a/src/gui/panels/ValentineTopRowPanel.cpp b/src/gui/panels/ValentineTopRowPanel.cpp index 8bb09be7..e088a1eb 100644 --- a/src/gui/panels/ValentineTopRowPanel.cpp +++ b/src/gui/panels/ValentineTopRowPanel.cpp @@ -58,31 +58,29 @@ void TopRowPanel::resized() auto sliders = bounds.removeFromLeft (juce::roundToInt (bounds.getWidth() * .65f)); const auto buttonWidth = juce::roundToInt (sliders.getWidth() * .033f); const auto adjustedComponentWidth = sliders.getWidth() - (buttonWidth * 2.0f); - const auto sliderWidth = juce::roundToInt (adjustedComponentWidth / 3.0f); - - const auto buttonSpacer = - juce::roundToInt ((sliders.getHeight() - buttonWidth) * .5f); - - // See below note about horizontal LabelSlider dimensions and button placement. + const auto sliderInitialWidth = juce::roundToInt (adjustedComponentWidth / 3.0f); const auto buttonNudge = juce::roundToInt (buttonWidth / 5.0f); - const auto initialCrushButtonX = sliders.getX(); - const auto crushEnableButtonBounds = sliders.removeFromLeft (buttonWidth) - .reduced (0, buttonSpacer) - .withX (initialCrushButtonX + buttonNudge); - - crushEnableButton.setBounds (crushEnableButtonBounds); - crushSlider.setBounds (sliders.removeFromLeft (sliderWidth).reduced (buttonNudge, 0)); - compressSlider.setBounds (sliders.removeFromLeft (sliderWidth)); - - const auto initialSaturateButtonX = sliders.getX(); - const auto saturateEnableButtonBounds = - sliders.removeFromLeft (buttonWidth) - .reduced (0, buttonSpacer) - .withX (initialSaturateButtonX + buttonNudge); - - saturateEnableButton.setBounds (saturateEnableButtonBounds); - saturateSlider.setBounds ( - sliders.removeFromLeft (sliderWidth).reduced (buttonNudge, 0)); + + const auto setButtonAndSliderBounds = [&] (auto& button, auto& slider) { + const auto initialX = sliders.getX(); + const auto x = initialX + buttonNudge; + const auto y = sliders.getCentreY() - buttonWidth / 2; + + button.setBounds (sliders.removeFromLeft (buttonWidth) + .withX (x) + .withY (y) + .withHeight (buttonWidth)); + + const auto sliderInitialX = sliders.getX(); + const auto sliderX = sliderInitialX + buttonNudge; + const auto sliderWidth = sliderInitialWidth - buttonNudge; + slider.setBounds ( + sliders.removeFromLeft (sliderWidth).withX (sliderX).withWidth (sliderWidth)); + }; + + setButtonAndSliderBounds (crushEnableButton, crushSlider); + compressSlider.setBounds (sliders.removeFromLeft (sliderInitialWidth)); + setButtonAndSliderBounds (saturateEnableButton, saturateSlider); const auto logoHeight = bounds.getHeight() * .25f; const auto logoWidth = bounds.getWidth() * .75f;