Gjorde det möjligt att slå på/stänga av alla olika effekter samt fixade ikon för MacOS

This commit is contained in:
crille committed 2026-11-25 17:18:41 +01:00
1 parent f5e6eadcd4
commit ba29890105
10 files changed
+643 -188

No files matched your search

+192 -53
View File
@@ -212,6 +212,61 @@ void CrilleBassStripAudioProcessorEditor::LevelMeter::paint(
);
}
CrilleBassStripAudioProcessorEditor::SectionToggleButton::
SectionToggleButton(
const juce::String& sectionName,
juce::Colour activeColour)
: juce::ToggleButton(sectionName),
sectionColour(activeColour)
{
setClickingTogglesState(true);
setMouseCursor(juce::MouseCursor::PointingHandCursor);
}
void CrilleBassStripAudioProcessorEditor::SectionToggleButton::paintButton(
juce::Graphics& g,
bool shouldDrawButtonAsHighlighted,
bool shouldDrawButtonAsDown)
{
const bool active = getToggleState();
const auto bounds = getLocalBounds().toFloat();
const float ledSize = 9.0f;
auto ledBounds = juce::Rectangle<float>(
5.0f,
(bounds.getHeight() - ledSize) * 0.5f,
ledSize,
ledSize);
auto ledColour = active
? sectionColour
: juce::Colour(0xff454a51);
if (shouldDrawButtonAsDown)
ledColour = ledColour.brighter(0.25f);
else if (shouldDrawButtonAsHighlighted)
ledColour = ledColour.brighter(0.12f);
g.setColour(ledColour.withAlpha(active ? 0.25f : 0.12f));
g.fillEllipse(ledBounds.expanded(3.0f));
g.setColour(ledColour);
g.fillEllipse(ledBounds);
g.setColour(active
? juce::Colour(0xfff0f1f2)
: juce::Colour(0xff686e76));
g.setFont(juce::Font(15.0f, juce::Font::bold));
g.drawText(
getButtonText(),
20,
0,
getWidth() - 25,
getHeight(),
juce::Justification::centred);
}
CrilleBassStripAudioProcessorEditor::
CrilleBassStripAudioProcessorEditor(
CrilleBassStripAudioProcessor& p)
@@ -251,6 +306,43 @@ CrilleBassStripAudioProcessorEditor(
downTuneButton
);
addAndMakeVisible(gateToggleButton);
addAndMakeVisible(compressorToggleButton);
addAndMakeVisible(distortionToggleButton);
addAndMakeVisible(eqToggleButton);
gateToggleAttachment =
std::make_unique<
juce::AudioProcessorValueTreeState::ButtonAttachment
>(
processor.apvts,
"gateOn",
gateToggleButton);
compressorToggleAttachment =
std::make_unique<
juce::AudioProcessorValueTreeState::ButtonAttachment
>(
processor.apvts,
"compressorOn",
compressorToggleButton);
distortionToggleAttachment =
std::make_unique<
juce::AudioProcessorValueTreeState::ButtonAttachment
>(
processor.apvts,
"distortionOn",
distortionToggleButton);
eqToggleAttachment =
std::make_unique<
juce::AudioProcessorValueTreeState::ButtonAttachment
>(
processor.apvts,
"eqOn",
eqToggleButton);
addKnob(
"gateThreshold",
"THRESHOLD"
@@ -325,6 +417,8 @@ CrilleBassStripAudioProcessorEditor(
addAndMakeVisible(compressorInputMeter);
addAndMakeVisible(compressorReductionMeter);
updateSectionStates();
setSize(760, 720);
startTimerHz(30);
}
@@ -399,6 +493,40 @@ void CrilleBassStripAudioProcessorEditor::addKnob(
knobs.push_back(std::move(k));
}
void CrilleBassStripAudioProcessorEditor::setKnobSectionEnabled(
int firstKnob,
int numberOfKnobs,
bool enabled)
{
const float alpha = enabled ? 1.0f : 0.35f;
for (int i = firstKnob;
i < firstKnob + numberOfKnobs;
++i)
{
knobs[static_cast<std::size_t>(i)]->slider.setEnabled(enabled);
knobs[static_cast<std::size_t>(i)]->slider.setAlpha(alpha);
knobs[static_cast<std::size_t>(i)]->label.setAlpha(alpha);
}
}
void CrilleBassStripAudioProcessorEditor::updateSectionStates()
{
const bool gateEnabled = gateToggleButton.getToggleState();
const bool compressorEnabled = compressorToggleButton.getToggleState();
const bool distortionEnabled = distortionToggleButton.getToggleState();
const bool eqEnabled = eqToggleButton.getToggleState();
setKnobSectionEnabled(0, 3, gateEnabled);
setKnobSectionEnabled(3, 3, compressorEnabled);
setKnobSectionEnabled(6, 3, distortionEnabled);
setKnobSectionEnabled(9, 5, eqEnabled);
gateInputMeter.setAlpha(gateEnabled ? 1.0f : 0.25f);
compressorInputMeter.setAlpha(compressorEnabled ? 1.0f : 0.25f);
compressorReductionMeter.setAlpha(compressorEnabled ? 1.0f : 0.25f);
}
float CrilleBassStripAudioProcessorEditor::smoothMeter(
float current,
float target,
@@ -414,6 +542,8 @@ float CrilleBassStripAudioProcessorEditor::smoothMeter(
void CrilleBassStripAudioProcessorEditor::timerCallback()
{
updateSectionStates();
smoothedGateDb =
smoothMeter(
smoothedGateDb,
@@ -499,70 +629,55 @@ void CrilleBassStripAudioProcessorEditor::paint(
juce::Justification::centredLeft
);
const struct
const bool panelStates[]
{
juce::Rectangle<int> bounds;
juce::String title;
juce::Colour border;
}
panels[]
{
{
{ 15, 85, 180, 300 },
"DOWNTUNE",
juce::Colour(0xff4b79a8)
},
{
{ 205, 85, 265, 300 },
"NOISE GATE",
juce::Colour(0xff3c424a)
},
{
{ 480, 85, 265, 300 },
"COMPRESSOR",
juce::Colour(0xff3c424a)
},
{
{ 15, 395, 300, 310 },
"DISTORTION",
juce::Colour(0xffb85c45)
},
{
{ 325, 395, 420, 310 },
"EQUALIZER",
juce::Colour(0xff3c424a)
}
downTuneButton.getToggleState(),
gateToggleButton.getToggleState(),
compressorToggleButton.getToggleState(),
distortionToggleButton.getToggleState(),
eqToggleButton.getToggleState()
};
for (const auto& panel : panels)
const juce::Rectangle<int> panelBounds[]
{
auto bounds = panel.bounds;
{ 15, 85, 180, 300 },
{ 205, 85, 265, 300 },
{ 480, 85, 265, 300 },
{ 15, 395, 300, 310 },
{ 325, 395, 420, 310 }
};
g.setColour(juce::Colour(0xff1b1f24));
for (int i = 0; i < 5; ++i)
{
const auto bounds = panelBounds[i].toFloat();
const bool active = panelStates[i];
g.fillRoundedRectangle(
bounds.toFloat(),
10.0f
);
g.setColour(active
? juce::Colour(0xff1b1f24)
: juce::Colour(0xff171a1e));
g.setColour(panel.border);
g.fillRoundedRectangle(bounds, 10.0f);
g.drawRoundedRectangle(
bounds.toFloat(),
10.0f,
2.0f
);
g.setColour(active
? juce::Colour(0xff4a5058)
: juce::Colour(0xff2a2e34));
g.setColour(juce::Colour(0xfff0f1f2));
g.setFont(15.0f);
g.drawText(
panel.title,
bounds.removeFromTop(38),
juce::Justification::centred
);
g.drawRoundedRectangle(bounds, 10.0f, 2.0f);
}
g.setColour(downTuneButton.getToggleState()
? juce::Colour(0xfff0f1f2)
: juce::Colour(0xff686e76));
g.setFont(juce::Font(15.0f, juce::Font::bold));
g.drawText(
"DOWNTUNE",
15,
85,
180,
38,
juce::Justification::centred);
const float inputFrequency =
processor.getDetectedFrequencyHz();
@@ -722,6 +837,30 @@ void CrilleBassStripAudioProcessorEditor::paint(
void CrilleBassStripAudioProcessorEditor::resized()
{
gateToggleButton.setBounds(
245,
91,
185,
28);
compressorToggleButton.setBounds(
520,
91,
185,
28);
distortionToggleButton.setBounds(
70,
401,
190,
28);
eqToggleButton.setBounds(
435,
401,
200,
28);
downTuneButton.setBounds(
35,
135,