Reduce plugin width by 102px and fix bottom panel layout to scale proportionally

This commit is contained in:
Armin 2026-07-22 23:10:55 +02:00
commit f035e89ba9
9 changed files with 305 additions and 106 deletions

View file

@ -3,6 +3,103 @@
#include "PluginProcessor.h"
#include "WaveformDisplay.h"
class MonoslicerLookAndFeel : public juce::LookAndFeel_V4
{
public:
void drawButtonBackground(juce::Graphics& g, juce::Button& button,
const juce::Colour& backgroundColour,
bool isMouseOverButton, bool isButtonDown) override
{
if (backgroundColour.getAlpha() == 0)
return;
auto bounds = button.getLocalBounds().toFloat().reduced(0.5f);
auto cornerSize = 4.0f;
auto baseColour = backgroundColour.withMultipliedAlpha(button.isEnabled() ? 1.0f : 0.5f);
g.setColour(baseColour);
g.fillRoundedRectangle(bounds, cornerSize);
g.setColour(juce::Colour(0xff444466));
g.drawRoundedRectangle(bounds, cornerSize, 1.0f);
}
void drawButtonText(juce::Graphics& g, juce::TextButton& button,
bool isMouseOverButton, bool isButtonDown) override
{
auto font = getTextButtonFont(button, button.getHeight());
g.setFont(font);
g.setColour(button.findColour(button.getToggleState() ? juce::TextButton::textColourOnId
: juce::TextButton::textColourOffId)
.withMultipliedAlpha(button.isEnabled() ? 1.0f : 0.5f));
auto textArea = button.getLocalBounds().reduced(6, 1);
g.drawText(button.getButtonText(), textArea, juce::Justification::centredLeft, true);
}
};
class VuMeter : public juce::Component, public juce::Timer
{
public:
VuMeter(MonoslicerProcessor& p) : processor(p) { startTimerHz(30); }
~VuMeter() override { stopTimer(); }
void paint(juce::Graphics& g) override
{
auto bounds = getLocalBounds().toFloat();
float legendW = 20.0f;
float legendGap = 5.0f;
float barH = (bounds.getHeight() - 6.0f) / 2.0f;
float gap = 6.0f;
float barX = bounds.getX() + legendW + legendGap;
float barW = bounds.getWidth() - legendW - legendGap;
float levelL = processor.outputLevelL.load();
float levelR = processor.outputLevelR.load();
// Apply falloff decay
peakL = juce::jmax(levelL, peakL - decayRate);
peakR = juce::jmax(levelR, peakR - decayRate);
if (levelL > peakL) peakL = levelL;
if (levelR > peakR) peakR = levelR;
auto drawBar = [&](float y, float level, float peak, const juce::String& legend)
{
float frac = juce::jlimit(0.0f, 1.0f, level);
float peakFrac = juce::jlimit(0.0f, 1.0f, peak);
// Legend text
g.setColour(juce::Colour(0xff888888));
g.setFont(juce::Font(10.0f));
g.drawText(legend, bounds.getX(), y, legendW, barH, juce::Justification::centredRight);
// Inactive background
g.setColour(juce::Colour(0xff1a192d));
g.fillRoundedRectangle(barX, y, barW, barH, 2.0f);
// Active fill from left
float fillW = barW * frac;
g.setColour(juce::Colour(0xff3a73e5));
g.fillRoundedRectangle(barX, y, fillW, barH, 2.0f);
// Peak hold indicator
float peakX = barX + barW * peakFrac - 2.0f;
g.setColour(juce::Colour(0xff6699cc));
g.fillRect(peakX, y + 2.0f, 2.0f, barH - 4.0f);
};
drawBar(bounds.getY(), levelL, peakL, "L");
drawBar(bounds.getY() + barH + gap, levelR, peakR, "R");
}
void timerCallback() override { repaint(); }
private:
MonoslicerProcessor& processor;
float peakL = 0.0f, peakR = 0.0f;
float decayRate = 0.02f;
};
class MonoslicerEditor : public juce::AudioProcessorEditor,
private juce::FileDragAndDropTarget,
private juce::Button::Listener,
@ -23,6 +120,7 @@ public:
void timerCallback() override;
private:
MonoslicerLookAndFeel lnf;
MonoslicerProcessor& processorRef;
WaveformDisplay waveformDisplay;
@ -46,8 +144,8 @@ private:
juce::ComboBox scaleComboBox;
juce::ComboBox octaveComboBox;
static constexpr int baseWidth = 1100;
static constexpr int baseHeight = 570;
static constexpr int baseWidth = 920;
static constexpr int baseHeight = 606;
// Slice knobs
juce::Slider bassSlider, trebleSlider, sensitivitySlider;
@ -59,6 +157,7 @@ private:
// Filter type selector
juce::ComboBox filterTypeComboBox;
juce::Label filterTypeLabel;
// Filter knobs
juce::Slider filterCutoffSlider, filterResoSlider, filterEnvDepthSlider;
@ -77,6 +176,7 @@ private:
juce::TextButton stretchButton { "Match Length" };
juce::ComboBox keyShiftComboBox;
juce::Label keyShiftLabel;
VuMeter vuMeter;
std::unique_ptr<SliderAttachment> stretchBpmAttachment;
std::unique_ptr<ComboBoxAttachment> stretchBeatsAttachment;
std::unique_ptr<ComboBoxAttachment> keyShiftAttachment;