Skip to content

Commit

Permalink
Start rewrite of preset panel component placement
Browse files Browse the repository at this point in the history
Easier this way. Leaving a space for totie :)
  • Loading branch information
JoseDiazRohena committed Feb 8, 2024
1 parent ba37669 commit 7b9cd52
Showing 1 changed file with 12 additions and 46 deletions.
58 changes: 12 additions & 46 deletions libs/tote_bag/juce_gui/components/panels/PresetPanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,54 +115,20 @@ void PresetPanel::resized()
const auto margin = juce::roundToInt (area.getHeight() * .1f);
borderThickness = juce::roundToInt (margin * .4f);

// Adjust width to account for margins
const auto actualWidth = area.getWidth() - (margin * 6);
const auto buttonAreaWidth = actualWidth * .5f;

// Get width button groups on left side. Coefficients should sum to 1.
const auto saveLoadAreaWidth = buttonAreaWidth * .7f;
const auto bypassAreaWidth = buttonAreaWidth * .2f;
const auto incrementDecrementAreaWidth = buttonAreaWidth * .1f;

auto x = area.getX() + margin; // We update this while we place components
const auto y = area.getY() + margin;
const auto h = juce::roundToInt (area.getHeight() - (margin * 2.0f));

// Place bypass button
const auto bypassButtonWidth = juce::roundToInt (bypassAreaWidth);
juce::Rectangle<int> bypassBounds {x, y, bypassButtonWidth, h};
mBypassButton.setBounds (bypassBounds);
x += (bypassButtonWidth + margin);

// Place save and load buttons
const auto saveLoadButtonWidth = juce::roundToInt (saveLoadAreaWidth * .5f);
juce::Rectangle<int> saveLoadBounds;
for (auto button : {&mSavePresetButton, &mLoadPresetButton})
{
saveLoadBounds.setBounds (x, y, saveLoadButtonWidth, h);
button->setBounds (saveLoadBounds);
x += (saveLoadButtonWidth + margin);
}
auto presetBounds = area.reduced (borderThickness);

// Place increment and decrement buttons
juce::Rectangle<int> incrementDecrementBounds;
const auto incrementDecrementButtonWidth =
juce::roundToInt (incrementDecrementAreaWidth * .5f);
for (auto button : {&mPreviousPreset, &mNextPreset})
{
incrementDecrementBounds.setBounds (x, y, incrementDecrementButtonWidth, h);
button->setBounds (incrementDecrementBounds);
x += (incrementDecrementButtonWidth + margin);
}
const auto presetBoundsWidth = presetBounds.getWidth();
const auto totieButtonWidth = juce::roundToInt (presetBoundsWidth * .045f);
const auto bypassButtonWidth = juce::roundToInt (presetBoundsWidth * .11f);

presetBounds.removeFromLeft (juce::roundToInt (presetBoundsWidth * .02f));

presetBounds.removeFromLeft (juce::roundToInt (totieButtonWidth));

presetBounds.removeFromLeft (juce::roundToInt (presetBoundsWidth * .01f));

// Place preset selection window
const auto presetAreaWidth = actualWidth - buttonAreaWidth;
juce::Rectangle<int> presetSelectorBounds {x,
y,
juce::roundToInt (presetAreaWidth)
- margin,
h};
mPresetDisplay.setBounds (presetSelectorBounds);
mBypassButton.setBounds (
presetBounds.removeFromLeft (juce::roundToInt (bypassButtonWidth)));
}

void PresetPanel::setupPresetIncrementButtons()
Expand Down

0 comments on commit 7b9cd52

Please sign in to comment.