mirror of
https://codeberg.org/armin/gelyk.git
synced 2026-10-11 17:01:53 +02:00
Complete Gelyk EQ plugin (dark/cyber/neon, scaling UI, git status bar)
This commit is contained in:
parent
13863f4522
commit
580fcf7fec
7 changed files with 145 additions and 113 deletions
|
|
@ -3,6 +3,12 @@
|
|||
namespace gelyk
|
||||
{
|
||||
|
||||
static juce::Font monoFont(float height)
|
||||
{
|
||||
return juce::Font(juce::FontOptions(juce::Font::getDefaultMonospacedFontName(), height,
|
||||
juce::Font::plain));
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// NeonLookAndFeel
|
||||
// ---------------------------------------------------------------------------
|
||||
|
|
@ -26,23 +32,15 @@ void NeonLookAndFeel::drawLinearSlider(juce::Graphics& g, int x, int y, int widt
|
|||
const float cx = x + width * 0.5f;
|
||||
|
||||
// Track
|
||||
juce::Path track;
|
||||
if (vertical)
|
||||
{
|
||||
const float tw = 2.0f;
|
||||
juce::Path track;
|
||||
track.addRoundedRectangle(cx - tw * 0.5f, (float) y, tw, (float) height, 1.0f);
|
||||
}
|
||||
else
|
||||
{
|
||||
const float th = 2.0f;
|
||||
track.addRoundedRectangle((float) x, y + height * 0.5f - th * 0.5f, (float) width, th, 1.0f);
|
||||
}
|
||||
g.setColour(line);
|
||||
g.fillPath(track);
|
||||
g.setColour(line);
|
||||
g.fillPath(track);
|
||||
|
||||
// Filled region from centre (0 dB) down to the handle, glowing.
|
||||
if (vertical)
|
||||
{
|
||||
// Filled region from centre (0 dB) down to the handle, glowing.
|
||||
const float midY = y + height * 0.5f;
|
||||
const float top = juce::jmin(midY, sliderPos);
|
||||
const float bottom = juce::jmax(midY, sliderPos);
|
||||
|
|
@ -52,15 +50,20 @@ void NeonLookAndFeel::drawLinearSlider(juce::Graphics& g, int x, int y, int widt
|
|||
g.fillPath(fill);
|
||||
|
||||
// Handle.
|
||||
g.setColour(slider.isEnabled() && isMouseOverOrDragging(true) ? violet : cyan);
|
||||
g.setColour(slider.isMouseOverOrDragging(true) ? violet : cyan);
|
||||
g.fillEllipse(cx - 5.0f, sliderPos - 5.0f, 10.0f, 10.0f);
|
||||
g.setColour(bg);
|
||||
g.fillEllipse(cx - 2.0f, sliderPos - 2.0f, 4.0f, 4.0f);
|
||||
}
|
||||
else
|
||||
{
|
||||
const float th = 2.0f;
|
||||
juce::Path track;
|
||||
track.addRoundedRectangle((float) x, y + height * 0.5f - th * 0.5f, (float) width, th, 1.0f);
|
||||
g.setColour(line);
|
||||
g.fillPath(track);
|
||||
g.setColour(cyan);
|
||||
g.fillRect(x, y + height * 0.5f - 3.0f, (float) width, 6.0f);
|
||||
g.drawHorizontalLine((int) (y + height * 0.5f), sliderPos - 5.0f, sliderPos + 5.0f);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -86,7 +89,7 @@ void NeonLookAndFeel::drawComboBox(juce::Graphics& g, int width, int height, boo
|
|||
void NeonLookAndFeel::positionComboBoxText(juce::ComboBox& box, juce::Label& label)
|
||||
{
|
||||
label.setBounds(2, 1, box.getWidth() - 22, box.getHeight() - 2);
|
||||
label.setFont(juce::FontOptions(13.0f).setTypefaceName(juce::Font::getDefaultMonospacedFontName()));
|
||||
label.setFont(monoFont(13.0f));
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
|
@ -95,17 +98,14 @@ void NeonLookAndFeel::positionComboBoxText(juce::ComboBox& box, juce::Label& lab
|
|||
|
||||
GelykEQAudioProcessorEditor::GelykEQAudioProcessorEditor(GelykEQAudioProcessor& p)
|
||||
: AudioProcessorEditor(&p),
|
||||
processor(p),
|
||||
analyserAttachment(processor.getAPVTS().parameterState,
|
||||
"analyserEnabled",
|
||||
[this](float v) { processor.getAnalyser().setEnabled(v > 0.5f); })
|
||||
processor(p)
|
||||
{
|
||||
setLookAndFeel(&lookAndFeel);
|
||||
setOpaque(true);
|
||||
|
||||
titleLabel = std::make_unique<juce::Label>("title", "GELYKEQ");
|
||||
titleLabel->setFont(juce::FontOptions(26.0f).setTypefaceName(juce::Font::getDefaultMonospacedFontName()));
|
||||
titleLabel->setColour(juce::Label::textColourId, cyan);
|
||||
titleLabel->setFont(monoFont(26.0f));
|
||||
titleLabel->setColour(juce::Label::textColourId, lookAndFeel.cyan);
|
||||
titleLabel->setJustificationType(juce::Justification::centredLeft);
|
||||
addAndMakeVisible(*titleLabel);
|
||||
|
||||
|
|
@ -116,25 +116,25 @@ GelykEQAudioProcessorEditor::GelykEQAudioProcessorEditor(GelykEQAudioProcessor&
|
|||
scaleBox->addItem("175%", 175);
|
||||
scaleBox->addItem("200%", 200);
|
||||
scaleBox->setSelectedId(100, juce::dontSendNotification);
|
||||
scaleBox->setTooltip("UI scaling");
|
||||
scaleBox->onChange = [this] { scaleUI((float) scaleBox->getSelectedId()); };
|
||||
addAndMakeVisible(*scaleBox);
|
||||
|
||||
// Master gain (vertical fader, far right).
|
||||
masterLabel = std::make_unique<juce::Label>("mlab", "MASTER");
|
||||
masterLabel->setFont(juce::FontOptions(11.0f).setTypefaceName(juce::Font::getDefaultMonospacedFontName()));
|
||||
masterLabel->setColour(juce::Label::textColourId, magenta);
|
||||
masterLabel->setFont(monoFont(11.0f));
|
||||
masterLabel->setColour(juce::Label::textColourId, lookAndFeel.magenta);
|
||||
masterLabel->setJustificationType(juce::Justification::centred);
|
||||
master = std::make_unique<juce::Slider>(juce::Slider::LinearVertical,
|
||||
juce::Slider::TextBoxBelow);
|
||||
master = std::make_unique<juce::Slider>(juce::Slider::LinearVertical, juce::Slider::TextBoxBelow);
|
||||
master->setLookAndFeel(&lookAndFeel);
|
||||
master->setSliderStyle(juce::Slider::LinearVertical);
|
||||
master->setTextBoxStyle(juce::Slider::TextBoxBelow, false, 40, 14);
|
||||
master->setRange(-24.0, 24.0, 0.01);
|
||||
master->setDoubleClickReturnValue(true, 0.0);
|
||||
addAndMakeVisible(*masterLabel);
|
||||
addAndMakeVisible(*master);
|
||||
masterAttachment = std::make_unique<juce::AudioProcessorValueTreeState::SliderAttachment>(
|
||||
processor.getAPVTS(), "master", *master);
|
||||
|
||||
// Band faders.
|
||||
const char* const names[numBands] = { "LOW", "LOW-MID", "MID", "HIGH-MID", "HIGH" };
|
||||
const char* const freqs[numBands] = { "60", "200", "1K", "4K", "10K" };
|
||||
|
|
@ -143,13 +143,14 @@ GelykEQAudioProcessorEditor::GelykEQAudioProcessorEditor(GelykEQAudioProcessor&
|
|||
auto& w = bands[i];
|
||||
|
||||
w.freqLabel = std::make_unique<juce::Label>("freq", freqs[i]);
|
||||
w.freqLabel->setFont(juce::FontOptions(13.0f).setTypefaceName(juce::Font::getDefaultMonospacedFontName()));
|
||||
w.freqLabel->setColour(juce::Label::textColourId, textDim);
|
||||
w.freqLabel->setFont(monoFont(13.0f));
|
||||
w.freqLabel->setColour(juce::Label::textColourId, lookAndFeel.textDim);
|
||||
w.freqLabel->setJustificationType(juce::Justification::centred);
|
||||
|
||||
w.gainLabel = std::make_unique<juce::Label>("gname", names[i]);
|
||||
w.gainLabel->setFont(juce::FontOptions(11.0f).setTypefaceName(juce::Font::getDefaultMonospacedFontName()));
|
||||
w.gainLabel->setColour(juce::Label::textColourId, i % 2 == 0 ? cyan : magenta);
|
||||
w.gainLabel->setFont(monoFont(11.0f));
|
||||
w.gainLabel->setColour(juce::Label::textColourId,
|
||||
i % 2 == 0 ? lookAndFeel.cyan : lookAndFeel.magenta);
|
||||
w.gainLabel->setJustificationType(juce::Justification::centred);
|
||||
|
||||
w.gain = std::make_unique<juce::Slider>(juce::Slider::LinearVertical, juce::Slider::TextBoxBelow);
|
||||
|
|
@ -177,14 +178,14 @@ GelykEQAudioProcessorEditor::GelykEQAudioProcessorEditor(GelykEQAudioProcessor&
|
|||
|
||||
// Status bar.
|
||||
statusGit = std::make_unique<juce::Label>("git", processor.getGitInfo());
|
||||
statusGit->setFont(juce::FontOptions(11.0f).setTypefaceName(juce::Font::getDefaultMonospacedFontName()));
|
||||
statusGit->setColour(juce::Label::textColourId, textDim);
|
||||
statusGit->setFont(monoFont(11.0f));
|
||||
statusGit->setColour(juce::Label::textColourId, lookAndFeel.textDim);
|
||||
statusGit->setJustificationType(juce::Justification::centredRight);
|
||||
|
||||
statusBar = std::make_unique<juce::Label>("status",
|
||||
"GELYKEQ v" + juce::String(ProjectInfo::versionString) + " | AU / VST3 ");
|
||||
statusBar->setFont(juce::FontOptions(11.0f).setTypefaceName(juce::Font::getDefaultMonospacedFontName()));
|
||||
statusBar->setColour(juce::Label::textColourId, textDim);
|
||||
"GELYKEQ v" + juce::String(ProjectInfo::versionString) + " | ANALYSER");
|
||||
statusBar->setFont(monoFont(11.0f));
|
||||
statusBar->setColour(juce::Label::textColourId, lookAndFeel.cyan.withAlpha(0.8f));
|
||||
statusBar->setJustificationType(juce::Justification::centredLeft);
|
||||
addAndMakeVisible(*statusBar);
|
||||
addAndMakeVisible(*statusGit);
|
||||
|
|
@ -193,7 +194,6 @@ GelykEQAudioProcessorEditor::GelykEQAudioProcessorEditor(GelykEQAudioProcessor&
|
|||
freqBins.ensureStorageAllocated(128);
|
||||
|
||||
startTimerHz(30);
|
||||
rebuildFaders();
|
||||
scaleUI(100.0f);
|
||||
}
|
||||
|
||||
|
|
@ -211,7 +211,6 @@ void GelykEQAudioProcessorEditor::timerCallback()
|
|||
|
||||
void GelykEQAudioProcessorEditor::rebuildFaders()
|
||||
{
|
||||
// Nothing needed at construction; sliders are attachments.
|
||||
}
|
||||
|
||||
void GelykEQAudioProcessorEditor::scaleUI(float percent)
|
||||
|
|
@ -233,7 +232,7 @@ void GelykEQAudioProcessorEditor::resized()
|
|||
|
||||
// Header.
|
||||
juce::Rectangle<int> header = area.removeFromTop(headerH);
|
||||
titleLabel->setBounds(header.removeFromLeft((int) (160 * s)).reduced(pad, 0));
|
||||
titleLabel->setBounds(header.removeFromLeft((int) (170 * s)).reduced(pad, 0));
|
||||
scaleBox->setBounds(header.removeFromRight((int) (90 * s)).reduced((int)(6*s), (int)(9*s)));
|
||||
|
||||
// Footer.
|
||||
|
|
@ -244,12 +243,12 @@ void GelykEQAudioProcessorEditor::resized()
|
|||
|
||||
// Main grid.
|
||||
const int masterW = (int) (64 * s);
|
||||
juce::Rectangle<int> mainArea = area;
|
||||
juce::Rectangle<int> masterArea = mainArea.removeFromRight(masterW);
|
||||
juce::Rectangle<int> masterArea = area.removeFromRight(masterW);
|
||||
|
||||
const int x0 = mainArea.getX();
|
||||
const int y0 = mainArea.getY();
|
||||
const int totalW = mainArea.getWidth();
|
||||
const int x0 = area.getX();
|
||||
const int y0 = area.getY();
|
||||
const int totalW = area.getWidth();
|
||||
const int height = area.getHeight();
|
||||
|
||||
const int gap = (int) (10 * s);
|
||||
const int colW = (totalW - gap * (numBands - 1)) / numBands;
|
||||
|
|
@ -257,35 +256,37 @@ void GelykEQAudioProcessorEditor::resized()
|
|||
for (int i = 0; i < numBands; ++i)
|
||||
{
|
||||
auto& w = bands[i];
|
||||
juce::Rectangle<int> col(x0 + i * (colW + gap), y0, colW, mainArea.getHeight());
|
||||
juce::Rectangle<int> col(x0 + i * (colW + gap), y0, colW, height);
|
||||
|
||||
const int topLabelH = (int) (18 * s);
|
||||
const int topLabelH = (int) (20 * s);
|
||||
const int freqH = (int) (16 * s);
|
||||
const int gainH = (int) (14 * s);
|
||||
const int gainSliderH = (int) (58 * s);
|
||||
const int qH = (int) (18 * s);
|
||||
|
||||
juce::Rectangle<int> sub = col.reduced((int)(8*s), 0);
|
||||
w.gainLabel->setBounds(sub.removeFromTop(topLabelH));
|
||||
w.gainLabel->setBounds(col.removeFromTop(topLabelH));
|
||||
|
||||
juce::Rectangle<int> analyserArea = sub.removeFromTop(sub.getHeight() - freqH - gainH - (int)(18*s) - (int)(10*s));
|
||||
const int analyserH = col.getHeight() - freqH - gainSliderH - qH - (int)(8*s);
|
||||
// reserve analyser space by subtracting it (faders sit on top of the spectrum)
|
||||
col.removeFromTop(juce::jmax(0, analyserH));
|
||||
|
||||
w.freqLabel->setBounds(sub.removeFromTop(freqH));
|
||||
w.gain->setBounds(sub.removeFromTop(gainH + (int)(34*s)));
|
||||
w.freqLabel->setBounds(col.removeFromTop(freqH));
|
||||
w.gain->setBounds(col.removeFromTop(gainSliderH));
|
||||
|
||||
w.q->setBounds(col.removeFromBottom((int)(18*s)).reduced((int)(8*s), 0));
|
||||
juce::Rectangle<int> qArea = col.removeFromBottom(qH);
|
||||
w.q->setBounds(qArea.reduced((int)(12*s), 0));
|
||||
}
|
||||
|
||||
// Master column.
|
||||
juce::Rectangle<int> msub = masterArea.reduced((int)(14*s), 0);
|
||||
masterLabel->setBounds(msub.removeFromTop((int) (18 * s)));
|
||||
juce::Rectangle<int> msub = masterArea.reduced((int)(14*s), (int)(6*s));
|
||||
masterLabel->setBounds(msub.removeFromTop((int) (20 * s)));
|
||||
master->setBounds(msub);
|
||||
}
|
||||
|
||||
void GelykEQAudioProcessorEditor::paint(juce::Graphics& g)
|
||||
{
|
||||
const float s = scaling.load();
|
||||
g.fillAll(bg);
|
||||
g.fillAll(lookAndFeel.bg);
|
||||
|
||||
// Analyser canvas area matches fader columns.
|
||||
juce::Rectangle<int> area = getLocalBounds();
|
||||
const int headerH = (int) (46 * s);
|
||||
const int footerH = (int) (26 * s);
|
||||
|
|
@ -294,38 +295,37 @@ void GelykEQAudioProcessorEditor::paint(juce::Graphics& g)
|
|||
mainArea.removeFromBottom(footerH);
|
||||
mainArea.removeFromRight((int) (64 * s));
|
||||
|
||||
// Neon grid lines behind faders.
|
||||
g.setColour(line);
|
||||
for (int i = 0; i < 4; ++i)
|
||||
const int topPad = (int) (20 * s);
|
||||
const int botPad = (int) (28 * s);
|
||||
const float topY = (float) (mainArea.getY() + topPad);
|
||||
const float botY = (float) (mainArea.getY() + mainArea.getHeight() - botPad);
|
||||
|
||||
// Neon grid lines.
|
||||
g.setColour(lookAndFeel.line);
|
||||
for (int i = 1; i <= 4; ++i)
|
||||
{
|
||||
float f = (i + 1) / 5.0f;
|
||||
// 0 dB line.
|
||||
if (i == 2)
|
||||
continue;
|
||||
float yy = mainArea.getY() + 18.0f * s + (mainArea.getHeight() - 18.0f * s - 60.0f * s) * f;
|
||||
g.drawHorizontalLine((int) yy + (int)(18*s), (float) mainArea.getX(), (float) mainArea.getRight());
|
||||
if (i == 3) continue; // skip the 0 dB centre (drawn separately)
|
||||
float yy = topY + (botY - topY) * (i / 5.0f);
|
||||
g.drawHorizontalLine((int) yy, (float) mainArea.getX(), (float) mainArea.getRight());
|
||||
}
|
||||
|
||||
// The 0 dB centre line (glowing).
|
||||
const float centreLineY = mainArea.getY() + (int)(18*s) +
|
||||
(mainArea.getHeight() - (int)(18*s) - (int)(60*s)) * 0.5f;
|
||||
g.setColour(cyan.withAlpha(0.55f));
|
||||
// 0 dB centre line (glowing cyan).
|
||||
const float centreLineY = topY + (botY - topY) * 0.5f;
|
||||
g.setColour(lookAndFeel.cyan.withAlpha(0.55f));
|
||||
g.drawHorizontalLine((int) centreLineY, (float) mainArea.getX(), (float) mainArea.getRight());
|
||||
|
||||
// Spectrum overlay.
|
||||
if (spectrum.size() > 2)
|
||||
{
|
||||
juce::Path path;
|
||||
const int x0 = mainArea.getX();
|
||||
const int width = mainArea.getWidth();
|
||||
const float topY = mainArea.getY() + 18.0f * s;
|
||||
const float botY = mainArea.getY() + (int)(8*s) + (mainArea.getHeight() - (int)(18*s) - (int)(60*s)) * 0.92f;
|
||||
const float x0 = (float) mainArea.getX();
|
||||
const float width = (float) mainArea.getWidth();
|
||||
|
||||
for (int i = 0; i < spectrum.size(); ++i)
|
||||
{
|
||||
float db = juce::jlimit(-72.0f, 12.0f, spectrum[i]);
|
||||
float norm = (db + 72.0f) / 84.0f; // 0..1 up
|
||||
float xx = (float) x0 + (float) i / (float) (spectrum.size() - 1) * width;
|
||||
float xx = x0 + (float) i / (float) (spectrum.size() - 1) * width;
|
||||
float yy = botY - norm * (botY - topY);
|
||||
if (i == 0) path.startNewSubPath(xx, yy);
|
||||
else path.lineTo(xx, yy);
|
||||
|
|
@ -336,11 +336,12 @@ void GelykEQAudioProcessorEditor::paint(juce::Graphics& g)
|
|||
filled.lineTo((float) mainArea.getX(), botY);
|
||||
filled.closeSubPath();
|
||||
|
||||
g.setGradientFill(juce::ColourGradient(magenta.withAlpha(0.35f), (float) mainArea.getX(), topY,
|
||||
magenta.withAlpha(0.05f), (float) mainArea.getX(), botY,
|
||||
false));
|
||||
g.setGradientFill(juce::ColourGradient(lookAndFeel.magenta.withAlpha(0.30f),
|
||||
(float) mainArea.getX(), topY,
|
||||
lookAndFeel.magenta.withAlpha(0.05f),
|
||||
(float) mainArea.getX(), botY, false));
|
||||
g.fillPath(filled);
|
||||
g.setColour(cyan.withAlpha(0.9f));
|
||||
g.setColour(lookAndFeel.cyan.withAlpha(0.9f));
|
||||
g.strokePath(path, juce::PathStrokeType(1.6f * s));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue