From 9f1999d7b29509b371fe8ea853296079663d2383 Mon Sep 17 00:00:00 2001 From: Legaeli Date: Mon, 10 Nov 2025 17:49:12 +0100 Subject: [PATCH] Replaced low and high ComboBoxes with ToggleButtons and implemented the logic for switching between modes. --- CrystalizerEQ/AXIOMDesignSystem.h | 1 + CrystalizerEQ/JuceLibraryCode/BinaryData.cpp | 113 ++++++++---- CrystalizerEQ/JuceLibraryCode/BinaryData.h | 4 +- CrystalizerEQ/PluginEditor.cpp | 184 +++++++++++++++---- CrystalizerEQ/PluginEditor.h | 18 +- CrystalizerEQ/PluginProcessor.cpp | 4 +- 6 files changed, 246 insertions(+), 78 deletions(-) diff --git a/CrystalizerEQ/AXIOMDesignSystem.h b/CrystalizerEQ/AXIOMDesignSystem.h index 0bd392a..5bf6565 100644 --- a/CrystalizerEQ/AXIOMDesignSystem.h +++ b/CrystalizerEQ/AXIOMDesignSystem.h @@ -671,6 +671,7 @@ class PresetMenuButtonLookAndFeel : public juce::LookAndFeel_V4 { } + } private: diff --git a/CrystalizerEQ/JuceLibraryCode/BinaryData.cpp b/CrystalizerEQ/JuceLibraryCode/BinaryData.cpp index 123b58d..6e39053 100644 --- a/CrystalizerEQ/JuceLibraryCode/BinaryData.cpp +++ b/CrystalizerEQ/JuceLibraryCode/BinaryData.cpp @@ -11423,24 +11423,43 @@ const char* preset_menu_icon_svg = (const char*) temp_binary_data_7; //================== crystalize_button_active_icon.svg ================== static const unsigned char temp_binary_data_8[] = "\n" -"\n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" +"\n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" " \n" ""; @@ -11449,24 +11468,42 @@ const char* crystalize_button_active_icon_svg = (const char*) temp_binary_data_8 //================== crystalize_button_passive_icon.svg ================== static const unsigned char temp_binary_data_9[] = "\n" -"\n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" +"\n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" " \n" ""; @@ -11502,8 +11539,8 @@ const char* getNamedResource (const char* resourceNameUTF8, int& numBytes) case 0x9c8232dc: numBytes = 24716; return OrbitronRegular_ttf; case 0x93fe9a1e: numBytes = 146004; return RobotoRegular_ttf; case 0x4df4bf1e: numBytes = 350; return preset_menu_icon_svg; - case 0xd842aaab: numBytes = 2478; return crystalize_button_active_icon_svg; - case 0x885a7642: numBytes = 2508; return crystalize_button_passive_icon_svg; + case 0xd842aaab: numBytes = 4212; return crystalize_button_active_icon_svg; + case 0x885a7642: numBytes = 4141; return crystalize_button_passive_icon_svg; case 0xe49e0f15: numBytes = 406; return bypass_icon_svg; default: break; } diff --git a/CrystalizerEQ/JuceLibraryCode/BinaryData.h b/CrystalizerEQ/JuceLibraryCode/BinaryData.h index 1489d69..2fea0aa 100644 --- a/CrystalizerEQ/JuceLibraryCode/BinaryData.h +++ b/CrystalizerEQ/JuceLibraryCode/BinaryData.h @@ -33,10 +33,10 @@ namespace BinaryData const int preset_menu_icon_svgSize = 350; extern const char* crystalize_button_active_icon_svg; - const int crystalize_button_active_icon_svgSize = 2478; + const int crystalize_button_active_icon_svgSize = 4212; extern const char* crystalize_button_passive_icon_svg; - const int crystalize_button_passive_icon_svgSize = 2508; + const int crystalize_button_passive_icon_svgSize = 4141; extern const char* bypass_icon_svg; const int bypass_icon_svgSize = 406; diff --git a/CrystalizerEQ/PluginEditor.cpp b/CrystalizerEQ/PluginEditor.cpp index 6517957..151b5e8 100644 --- a/CrystalizerEQ/PluginEditor.cpp +++ b/CrystalizerEQ/PluginEditor.cpp @@ -21,31 +21,7 @@ using Layout = DesignSystem::Layout; using Components = DesignSystem::Components; using SliderStyles = Components::SliderStyles; -//region setupModeBoxes -void CrystalizerEQAudioProcessorEditor::setupModeBoxes() { - if (auto* choice = dynamic_cast( - audioProcessor.apvts.getParameter("LowBandModes"))) - { - lowBandModeBox.addItemList (choice->choices, 1); - lowBandModeBox.setSelectedItemIndex (choice->getIndex(), juce::dontSendNotification); - - lowBandModeAttach = std::make_unique( - audioProcessor.apvts, "LowBandModes", lowBandModeBox); - } - - if (auto* choice = dynamic_cast( - audioProcessor.apvts.getParameter("HighBandModes"))) - { - highBandModeBox.addItemList (choice->choices, 1); - - highBandModeBox.setSelectedItemIndex (choice->getIndex(), juce::dontSendNotification); - - highBandModeAttach = std::make_unique( - audioProcessor.apvts, "HighBandModes", highBandModeBox); - } -} -//endregion setupModeBoxes //region setupSliders void CrystalizerEQAudioProcessorEditor::setupSliders() { @@ -83,7 +59,6 @@ void CrystalizerEQAudioProcessorEditor::setupAttachments() { lowBandSlopeAttach = std::make_unique(audioProcessor.apvts, "LowBandSlope", lowBandSlopeSlider); lowBandGainAttach = std::make_unique(audioProcessor.apvts, "LowBandGain", lowBandGainSlider); lowBandQAttach = std::make_unique(audioProcessor.apvts, "LowBandQ", lowBandQSlider); - lowBandModeAttach = std::make_unique(audioProcessor.apvts, "LowBandModes", lowBandModeBox); peak1FreqAttach = std::make_unique(audioProcessor.apvts, "Peak1Freq", peak1FreqSlider); peak1GainAttach = std::make_unique(audioProcessor.apvts, "Peak1Gain", peak1GainSlider); @@ -101,7 +76,6 @@ void CrystalizerEQAudioProcessorEditor::setupAttachments() { highBandSlopeAttach = std::make_unique(audioProcessor.apvts, "HighBandSlope", highBandSlopeSlider); highBandGainAttach = std::make_unique(audioProcessor.apvts, "HighBandGain", highBandGainSlider); highBandQAttach = std::make_unique(audioProcessor.apvts, "HighBandQ", highBandQSlider); - highBandModeAttach = std::make_unique(audioProcessor.apvts, "HighBandModes", highBandModeBox); inputAttach = std::make_unique(audioProcessor.apvts, "InputGain", inputSlider); outputAttach = std::make_unique(audioProcessor.apvts, "OutputGain", outputSlider); @@ -114,6 +88,11 @@ void CrystalizerEQAudioProcessorEditor::setupDisplayNames() { testNoiseSlider.setName("TestNoise"); + lowBypass.setName("LowBypass"); + lowBell.setName("LowBell"); + lowCut.setName("LowCut"); + lowShelf.setName("LowShelf"); + lowBandModeBox.setName("LowBandModeBox"); lowBandFreqSlider.setName ("LowBand Freq"); lowBandSlopeSlider.setName ("LowBand Slope"); lowBandGainSlider.setName ("LowBand Gain"); @@ -131,6 +110,11 @@ void CrystalizerEQAudioProcessorEditor::setupDisplayNames() { peak3GainSlider.setName("Peak3 Gain"); peak3QSlider.setName ("Peak3 Q"); + highBypass.setName("HighBypass"); + highBell.setName("HighBell"); + highCut.setName("HighCut"); + highShelf.setName("HighShelf"); + highBandModeBox.setName("HighBandModeBox"); highBandFreqSlider.setName ("HighBand Freq"); highBandSlopeSlider.setName ("HighBand Slope"); highBandGainSlider.setName ("HighBand Gain"); @@ -161,6 +145,7 @@ void CrystalizerEQAudioProcessorEditor::setupDisplayNames() { //peak3QSlider.setTextValueSuffix("\nQ"); peak3BypassButton.setName("peak3Bypass"); + //highBandFreqSlider.setTextValueSuffix ("\nHz"); highBandSlopeSlider.setTextValueSuffix ("\ndB/Oct"); highBandGainSlider.setTextValueSuffix("\ndB"); @@ -202,6 +187,9 @@ void CrystalizerEQAudioProcessorEditor::setupToggleButtons() { crystalizeButton.setLookAndFeel(svgToggleButtonLookAndFeel.get()); presetMenuButton.setLookAndFeel(presetMenuButtonLookAndFeel.get()); + + lowShelf.setToggleState(true, juce::dontSendNotification); + highShelf.setToggleState(true, juce::dontSendNotification); for (auto* b : {&peak1BypassButton, &peak2BypassButton, &peak3BypassButton, &crystalizeButton, &masterBypassButton}) { b->onClick = [this, b]() { juce::String paramID; // nimm juce::String statt std::string @@ -390,7 +378,16 @@ void CrystalizerEQAudioProcessorEditor::addComponentsToLayout() { { filterArea.addAndMakeVisible(lowFilterArea); + + lowBandModeBox.addAndMakeVisible(lowBypass); + lowBandModeBox.addAndMakeVisible(lowCut); + lowBandModeBox.addAndMakeVisible(lowBell); + lowBandModeBox.addAndMakeVisible(lowShelf); lowFilterArea.addAndMakeVisible(lowBandModeBox); + lowBandModeButtons.add(&lowBypass, &lowCut, &lowBell, &lowShelf); + lowBandBools = {false, false, false, true}; + + lowFilterArea.addAndMakeVisible(lowBandSlopeLabel); lowFilterArea.addAndMakeVisible(lowBandGainLabel); lowFilterArea.addAndMakeVisible(lowBandQLabel); @@ -436,7 +433,15 @@ void CrystalizerEQAudioProcessorEditor::addComponentsToLayout() { { filterArea.addAndMakeVisible(highFilterArea); + + highBandModeBox.addAndMakeVisible(highBypass); + highBandModeBox.addAndMakeVisible(highCut); + highBandModeBox.addAndMakeVisible(highBell); + highBandModeBox.addAndMakeVisible(highShelf); highFilterArea.addAndMakeVisible(highBandModeBox); + highBandModeButtons.add(&highBypass, &highCut, &highBell, &highShelf); + highBandBools = {false, false, false, true}; + highFilterArea.addAndMakeVisible(highBandSlopeLabel); highFilterArea.addAndMakeVisible(highBandGainLabel); highFilterArea.addAndMakeVisible(highBandQLabel); @@ -527,6 +532,72 @@ void CrystalizerEQAudioProcessorEditor::setupSliderTextBoxes() { } //endregion setupSliderTextBoxes +//region handleLowBandModes +void CrystalizerEQAudioProcessorEditor::handleLowBandModes() { + for (int i = 0; i < lowBandModeButtons.size(); ++i) + { + lowBandModeButtons[i]->onClick = [this, i] + { + if (!lowBandBools[i]) + { + if (auto* param = audioProcessor.apvts.getParameter("LowBandModes")) + { + param->beginChangeGesture(); + + for (int j = 0; j < lowBandBools.size(); ++j) + { + if (j != i) + { + lowBandBools[j] = false; + param->setValueNotifyingHost(param->convertTo0to1(0.0f)); + lowBandModeButtons[j]->setToggleState(false, juce::dontSendNotification); + } + } + + // Aktuellen aktivieren + lowBandBools[i] = true; + param->setValueNotifyingHost(param->convertTo0to1((float)i)); + + param->endChangeGesture(); + } + } + }; + } +} +//endregion handleLowBandModes + +//region handleHighBandModes +void CrystalizerEQAudioProcessorEditor::handleHighBandModes() { + for (int i = 0; i < highBandModeButtons.size(); ++i) + { + highBandModeButtons[i]->onClick = [this, i] + { + if (!highBandBools[i]) + { + if (auto* param = audioProcessor.apvts.getParameter("HighBandModes")) + { + param->beginChangeGesture(); + + for (int j = 0; j < highBandBools.size(); ++j) + { + if (j != i) + { + highBandBools[j] = false; + param->setValueNotifyingHost(param->convertTo0to1(0.0f)); + highBandModeButtons[j]->setToggleState(false, juce::dontSendNotification); + } + } + highBandBools[i] = true; + param->setValueNotifyingHost(param->convertTo0to1((float)i)); + + param->endChangeGesture(); + } + } + }; + } +} +//endregion handleHighBandModes + //region setupEventListeners void CrystalizerEQAudioProcessorEditor::setupEventListeners() { presetMenuButton.onClick = [this]() { @@ -590,6 +661,9 @@ void CrystalizerEQAudioProcessorEditor::setupEventListeners() { presetBox.setSelectedId(1, juce::dontSendNotification); }; + handleLowBandModes(); + + handleHighBandModes(); @@ -622,7 +696,6 @@ CrystalizerEQAudioProcessorEditor::CrystalizerEQAudioProcessorEditor (Crystalize startTimerHz(60); addComponentsToLayout(); setupLabels(); - setupModeBoxes(); setupFontsWithColours(); setupAttachments(); @@ -1009,6 +1082,16 @@ void CrystalizerEQAudioProcessorEditor::resetAllCheckboxes() { peak1BypassButton.setToggleState(false, notify); peak2BypassButton.setToggleState(false, notify); peak3BypassButton.setToggleState(false, notify); + + lowBypass.setToggleState(false, notify); + lowCut.setToggleState(false, notify); + lowBell.setToggleState(false, notify); + lowShelf.setToggleState(true, notify); + + highBypass.setToggleState(false, notify); + highCut.setToggleState(false, notify); + highBell.setToggleState(false, notify); + highShelf.setToggleState(true, notify); } //endregion resetAllCheckboxes @@ -1186,8 +1269,6 @@ void CrystalizerEQAudioProcessorEditor::setupLowBandLayout() { }; Layout::grid(bounds, lowBandSpec, { - - Layout::area(lowBandFreqSlider, 2, 1, 3, 2) .withWidth(refW * freqMod * 0.8f) .withHeight(refH * freqMod * 0.8f) @@ -1212,8 +1293,7 @@ void CrystalizerEQAudioProcessorEditor::setupLowBandLayout() { .withAlignSelf(juce::GridItem::AlignSelf::center) .withJustifySelf(juce::GridItem::JustifySelf::center), - - Layout::area(lowBandModeBox, 3, 1, 4, 2), + Layout::area(lowBandModeBox, 3, 1, 4, 3), Layout::area(lowBandFreqLabel, 2, 1, 3, 2) @@ -1226,6 +1306,26 @@ void CrystalizerEQAudioProcessorEditor::setupLowBandLayout() { }); + + const auto modeBoxBounds = lowBandModeBox.getLocalBounds(); + const auto modeBoxAreaWidth = static_cast(modeBoxBounds.getWidth()); + const auto modeBoxAreaHeight = static_cast(modeBoxBounds.getHeight()); + const auto modeBoxButtonColWidth = modeBoxAreaWidth / 4.0f; + + Layout::GridSpec lowBandModeBoxSpec{ + /* cols */ { Layout::fr(1), Layout::pxTrack(modeBoxButtonColWidth), Layout::pxTrack(modeBoxButtonColWidth), Layout::fr(1) }, + /* rows */ { Layout::fr(1)}, + /* colGap */ Spacing::SizeMode::XS, + /* rowGap */ Spacing::SizeMode::XS, + /* pad */ Layout::padding(Spacing::SizeMode::XS) + }; + + Layout::grid(modeBoxBounds, lowBandModeBoxSpec, { + Layout::area(lowBypass, 1, 1, 2, 2), + Layout::area(lowCut, 1, 2, 2, 3), + Layout::area(lowBell, 1, 3, 2, 4), + Layout::area(lowShelf, 1, 4, 2, 5) + }); } //endregion setupLowBandLayout @@ -1418,7 +1518,7 @@ void CrystalizerEQAudioProcessorEditor::setupHighBandLayout() { .withAlignSelf(juce::GridItem::AlignSelf::center) .withJustifySelf(juce::GridItem::JustifySelf::center), - Layout::area(highBandModeBox, 3, 3, 4, 4), + Layout::area(highBandModeBox, 3, 2, 4, 4), Layout::area(highBandSlopeSlider, 3, 1, 4, 2) @@ -1436,6 +1536,26 @@ void CrystalizerEQAudioProcessorEditor::setupHighBandLayout() { .withMargin(juce::GridItem::Margin(-offSetToGainTop / 2, 0, 0, 0)), }); + + const auto modeBoxBounds = lowBandModeBox.getLocalBounds(); + const auto modeBoxAreaWidth = static_cast(modeBoxBounds.getWidth()); + const auto modeBoxAreaHeight = static_cast(modeBoxBounds.getHeight()); + const auto modeBoxButtonColWidth = modeBoxAreaWidth / 4.0f; + + Layout::GridSpec highBandModeBoxSpec{ + /* cols */ { Layout::fr(1), Layout::pxTrack(modeBoxButtonColWidth), Layout::pxTrack(modeBoxButtonColWidth), Layout::fr(1) }, + /* rows */ { Layout::fr(1)}, + /* colGap */ Spacing::SizeMode::XS, + /* rowGap */ Spacing::SizeMode::XS, + /* pad */ Layout::padding(Spacing::SizeMode::XS) + }; + + Layout::grid(modeBoxBounds, highBandModeBoxSpec, { + Layout::area(highBypass, 1, 1, 2, 2), + Layout::area(highCut, 1, 2, 2, 3), + Layout::area(highBell, 1, 3, 2, 4), + Layout::area(highShelf, 1, 4, 2, 5) + }); } //endregion setupHighBandLayout diff --git a/CrystalizerEQ/PluginEditor.h b/CrystalizerEQ/PluginEditor.h index bb32007..d1f5327 100644 --- a/CrystalizerEQ/PluginEditor.h +++ b/CrystalizerEQ/PluginEditor.h @@ -197,9 +197,17 @@ public: juce::ToggleButton masterBypassButton, crystalizeButton, peak1BypassButton, peak2BypassButton, peak3BypassButton, presetMenuButton; - juce::ComboBox lowBandModeBox, highBandModeBox, presetBox; + juce::ComboBox presetBox; - std::unique_ptr lowBandModeAttach, highBandModeAttach; + juce::Component lowBandModeBox, highBandModeBox; + + juce::Array lowBandModeButtons, highBandModeButtons; + + std::array lowBandBools, highBandBools; + + + juce::ToggleButton lowBypass, lowCut, lowBell, lowShelf, + highBypass, highCut, highBell, highShelf; juce::TextEditor presetNameInput; @@ -217,12 +225,14 @@ private: void animateCrystalizeButton(); - void setupModeBoxes(); - void setupSliders(); void setupSliderTextBoxes(); + void handleLowBandModes(); + + void handleHighBandModes(); + void setupAttachments(); void setupDisplayNames(); diff --git a/CrystalizerEQ/PluginProcessor.cpp b/CrystalizerEQ/PluginProcessor.cpp index 69630ed..78b267d 100644 --- a/CrystalizerEQ/PluginProcessor.cpp +++ b/CrystalizerEQ/PluginProcessor.cpp @@ -37,7 +37,7 @@ CrystalizerEQAudioProcessor::createParameterLayout() { "LowBandModes", // Parameter-ID "Low Band Modes", // Anzeigename juce::StringArray { "Off", "Cut", "Shelf", "Bell" }, // Einträge - 0)); + 2)); //PEAK 1 @@ -108,7 +108,7 @@ CrystalizerEQAudioProcessor::createParameterLayout() { "HighBandModes", // Parameter-ID "High Band Modes", // Anzeigename juce::StringArray { "Off", "Cut", "Shelf", "Bell" }, // Einträge - 0)); + 2)); //