Skip to content

Commit

Permalink
Refactor button and slider placement in top row panel
Browse files Browse the repository at this point in the history
  • Loading branch information
JoseDiazRohena committed Apr 22, 2024
1 parent 0726acd commit f206548
Showing 1 changed file with 22 additions and 24 deletions.
46 changes: 22 additions & 24 deletions src/gui/panels/ValentineTopRowPanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit f206548

Please sign in to comment.