From 857e0655fd7c2f9d1233c3e25838f0e6553663a3 Mon Sep 17 00:00:00 2001 From: Legaeli Date: Sat, 8 Nov 2025 00:15:46 +0100 Subject: [PATCH] Added preset menu button. --- CrystalizerEQ/AXIOMDesignSystem.h | 59 ++++++++++- CrystalizerEQ/JuceLibraryCode/BinaryData.cpp | 4 +- CrystalizerEQ/JuceLibraryCode/BinaryData.h | 2 +- CrystalizerEQ/PluginEditor.cpp | 101 ++++++++++--------- CrystalizerEQ/PluginEditor.h | 3 + 5 files changed, 116 insertions(+), 53 deletions(-) diff --git a/CrystalizerEQ/AXIOMDesignSystem.h b/CrystalizerEQ/AXIOMDesignSystem.h index 2fcc92f..0bd392a 100644 --- a/CrystalizerEQ/AXIOMDesignSystem.h +++ b/CrystalizerEQ/AXIOMDesignSystem.h @@ -531,8 +531,7 @@ namespace AXIOM { public: BypassButtonLookAndFeel() { - svgXml = juce::XmlDocument::parse(BinaryData::bypass_icon_svg); - } + svgXml = juce::XmlDocument::parse(BinaryData::bypass_icon_svg);} @@ -578,12 +577,64 @@ namespace AXIOM { juce::RectanglePlacement::centred, bypassOpacity); } } + } private: std::unique_ptr svgXml; }; +class PresetMenuButtonLookAndFeel : public juce::LookAndFeel_V4 { + public: + PresetMenuButtonLookAndFeel() + { + presetMenuButton = juce::XmlDocument::parse(BinaryData::preset_menu_icon_svg); + } + + void drawToggleButton(juce::Graphics& g, juce::ToggleButton& button, + bool shouldDrawButtonAsHighlighted, + bool shouldDrawButtonAsDown) override + { + + bool isHovered = button.isMouseOverOrDragging(); + bool isToggled = button.getToggleState(); + bool isEnabled = button.isEnabled(); + auto bounds = button.getLocalBounds().toFloat(); + auto iconSize = juce::jmin(bounds.getWidth(), bounds.getHeight()) * 1.5f; + auto hoverFactor = isHovered ? 1.05f : 1.0f; + + auto iconBounds = juce::Rectangle(iconSize * hoverFactor, iconSize * hoverFactor) + .withCentre(bounds.getCentre()) + .withX(bounds.getX()); +// ganz links im Button starten +; + + float bypassOpacity = 1.0f; + + if (presetMenuButton != nullptr) { + auto menuIcon = juce::Drawable::createFromSVG(*presetMenuButton); + juce::Colour colour; + if (isHovered) { + colour = isToggled ? Colours::ACCENTHOVER : Colours::BACKGROUNDHOVER; + } else { + colour = isToggled + ? Colours::ACCENTCOLOUR + : Colours::BACKGROUNDCOLOUR; + } + + + // Icon zeichnen + menuIcon->replaceColour(juce::Colours::black, colour); + menuIcon->drawWithin(g, iconBounds, + juce::RectanglePlacement::centred, 1.0f); + } + + } + + private: + std::unique_ptr presetMenuButton; + }; + class SvgToggleButtonLookAndFeel : public juce::LookAndFeel_V4 { public: SvgToggleButtonLookAndFeel() { @@ -982,7 +1033,9 @@ namespace AXIOM { int rowStart, int colStart, int rowEnd, int colEnd) { - return juce::GridItem(c).withArea(rowStart, colStart, rowEnd, colEnd); + return juce::GridItem(c) + .withArea(rowStart, colStart, rowEnd, colEnd); + } static void grid(juce::Rectangle bounds, diff --git a/CrystalizerEQ/JuceLibraryCode/BinaryData.cpp b/CrystalizerEQ/JuceLibraryCode/BinaryData.cpp index 006e9fc..123b58d 100644 --- a/CrystalizerEQ/JuceLibraryCode/BinaryData.cpp +++ b/CrystalizerEQ/JuceLibraryCode/BinaryData.cpp @@ -11416,7 +11416,7 @@ const char* RobotoRegular_ttf = (const char*) temp_binary_data_6; //================== preset_menu_icon.svg ================== static const unsigned char temp_binary_data_7[] = ""; +"L 3 14 z M 3 21 A 1.0001 1.0001 0 1 0 3 23 L 27 23 A 1.0001 1.0001 0 1 0 27 21 L 3 21 z\" fill=\"black\"/>"; const char* preset_menu_icon_svg = (const char*) temp_binary_data_7; @@ -11501,7 +11501,7 @@ const char* getNamedResource (const char* resourceNameUTF8, int& numBytes) case 0xcbceafb3: numBytes = 24668; return OrbitronBold_ttf; case 0x9c8232dc: numBytes = 24716; return OrbitronRegular_ttf; case 0x93fe9a1e: numBytes = 146004; return RobotoRegular_ttf; - case 0x4df4bf1e: numBytes = 337; return preset_menu_icon_svg; + 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 0xe49e0f15: numBytes = 406; return bypass_icon_svg; diff --git a/CrystalizerEQ/JuceLibraryCode/BinaryData.h b/CrystalizerEQ/JuceLibraryCode/BinaryData.h index 641ff49..1489d69 100644 --- a/CrystalizerEQ/JuceLibraryCode/BinaryData.h +++ b/CrystalizerEQ/JuceLibraryCode/BinaryData.h @@ -30,7 +30,7 @@ namespace BinaryData const int RobotoRegular_ttfSize = 146004; extern const char* preset_menu_icon_svg; - const int preset_menu_icon_svgSize = 337; + const int preset_menu_icon_svgSize = 350; extern const char* crystalize_button_active_icon_svg; const int crystalize_button_active_icon_svgSize = 2478; diff --git a/CrystalizerEQ/PluginEditor.cpp b/CrystalizerEQ/PluginEditor.cpp index 29a051b..6517957 100644 --- a/CrystalizerEQ/PluginEditor.cpp +++ b/CrystalizerEQ/PluginEditor.cpp @@ -192,6 +192,7 @@ void CrystalizerEQAudioProcessorEditor::setupDisplayNames() { void CrystalizerEQAudioProcessorEditor::setupToggleButtons() { bypassButtonLookAndFeel = std::make_unique(); svgToggleButtonLookAndFeel = std::make_unique(); + presetMenuButtonLookAndFeel = std::make_unique(); peak1BypassButton.setLookAndFeel(bypassButtonLookAndFeel.get()); peak2BypassButton.setLookAndFeel(bypassButtonLookAndFeel.get()); @@ -199,6 +200,7 @@ void CrystalizerEQAudioProcessorEditor::setupToggleButtons() { masterBypassButton.setLookAndFeel(bypassButtonLookAndFeel.get()); crystalizeButton.setLookAndFeel(svgToggleButtonLookAndFeel.get()); + presetMenuButton.setLookAndFeel(presetMenuButtonLookAndFeel.get()); for (auto* b : {&peak1BypassButton, &peak2BypassButton, &peak3BypassButton, &crystalizeButton, &masterBypassButton}) { b->onClick = [this, b]() { @@ -601,7 +603,6 @@ void CrystalizerEQAudioProcessorEditor::initPresetSystem() { presetBox.setSelectedId(1, juce::dontSendNotification); presetMenuButton.setName("PresetMenuButton"); - presetMenuButton.setButtonText("Preset Menu"); presetMenuButton.setColour (juce::ToggleButton::textColourId, juce::Colours::black); presetMenuButton.setColour(juce::ToggleButton::tickColourId, juce::Colours::black); presetMenuButton.setToggleState(false, juce::dontSendNotification); @@ -668,6 +669,7 @@ CrystalizerEQAudioProcessorEditor::~CrystalizerEQAudioProcessorEditor() { peak3BypassButton.setLookAndFeel(nullptr); masterBypassButton.setLookAndFeel(nullptr); crystalizeButton.setLookAndFeel(nullptr); + presetMenuButton.setLookAndFeel(nullptr); }; //region paintAnalyzer @@ -695,6 +697,55 @@ void CrystalizerEQAudioProcessorEditor::paint (juce::Graphics& g) g.fillAll (Colours::BACKGROUNDCOLOUR); g.setColour (AXIOM::DesignSystem::Colours::FOREGROUNDCOLOUR); + + const auto mP = getLocalArea(&mainPanel, mainPanel.getLocalBounds()); + auto mPX = mP.getX(); + auto mPY = mP.getY(); + auto mPW = mP.getWidth(); + auto mPH = mP.getHeight(); + + paintAnalyzer(g); + g.setColour(Colours::SURFACEBYPASS); + const auto hB = getLocalArea(&headerBar, headerBar.getLocalBounds()); + auto hBX = hB.getX(); + auto hBY = hB.getY(); + auto hBW = hB.getWidth(); + auto hBH = hB.getHeight(); + auto hBPad = ((hBY + mPY) - hBH) / 2; + g.fillRect(hBX, hBY, hBW, mPY - hBPad); + paintBorderLines(g); + + + g.setColour(Colours::SURFACECOLOUR); + const auto pA = getLocalArea(&presetArea, presetArea.getLocalBounds()); + auto pAX = pA.getX(); + auto pAY = pA.getY(); + auto pAWidth = pA.getWidth(); + auto pAHeight = pA.getHeight(); + g.fillRoundedRectangle(pAX, pAY - 10.f, pAWidth, pAHeight + 10.f, 10.0f); + paintBorderLines(g); + + const auto fA = getLocalArea(&filterArea, filterArea.getLocalBounds()); + const int fABorderWidth = 3; + auto fABorder = fA.withSizeKeepingCentre(fA.getWidth() + fABorderWidth, fA.getHeight() + fABorderWidth); + fABorder = fABorder.withX(fABorder.getX() + fABorderWidth).withY(fABorder.getY() + fABorderWidth); + + + g.setColour(Colours::SURFACECOLOUR); + g.fillRect(fABorder); + + fABorder = fABorder.withX(fABorder.getX() - 2* fABorderWidth).withY(fABorder.getY() - 2 * fABorderWidth); + //g.setColour(Colours::FOREGROUNDBYPASS); + g.fillRect(fABorder); + + g.setColour(Colours::BACKGROUNDBYPASS); + g.fillRect(fA); + paintBorderLines(g); + + g.setColour(Colours::SURFACEBYPASS); + const auto fB = getLocalArea(&footerBar, footerBar.getLocalBounds()); + g.fillRect(fB); + if constexpr (false) // -> auf false setzen, wenn nicht gebraucht { for (auto* c : getChildren()) // headerBar, mainPanel, footerBar @@ -819,51 +870,6 @@ void CrystalizerEQAudioProcessorEditor::paint (juce::Graphics& g) } } - const auto mP = getLocalArea(&mainPanel, mainPanel.getLocalBounds()); - auto mPX = mP.getX(); - auto mPY = mP.getY(); - auto mPW = mP.getWidth(); - auto mPH = mP.getHeight(); - - paintAnalyzer(g); - g.setColour(Colours::SURFACEBYPASS); - const auto hB = getLocalArea(&headerBar, headerBar.getLocalBounds()); - auto hBX = hB.getX(); - auto hBY = hB.getY(); - auto hBW = hB.getWidth(); - auto hBH = hB.getHeight(); - auto hBPad = ((hBY + mPY) - hBH) / 2; - g.fillRect(hBX, hBY, hBW, mPY - hBPad); - paintBorderLines(g); - - - g.setColour(Colours::SURFACECOLOUR); - const auto pA = getLocalArea(&presetArea, presetArea.getLocalBounds()); - auto pAX = pA.getX(); - auto pAY = pA.getY(); - auto pAWidth = pA.getWidth(); - auto pAHeight = pA.getHeight(); - g.fillRoundedRectangle(pAX, pAY - 10.f, pAWidth, pAHeight + 10.f, 10.0f); - paintBorderLines(g); - - const auto fA = getLocalArea(&filterArea, filterArea.getLocalBounds()); - const int fABorderWidth = 3; - //TODO: BORDER OF FILTERAREA - auto fABorder = fA.withSizeKeepingCentre(fA.getWidth() + fABorderWidth, fA.getHeight() + fABorderWidth); - fABorder = fABorder.withX(fABorder.getX() + fABorderWidth).withY(fABorder.getY() + fABorderWidth); - - - g.setColour(Colours::SURFACECOLOUR); - g.fillRect(fABorder); - - fABorder = fABorder.withX(fABorder.getX() - 2* fABorderWidth).withY(fABorder.getY() - 2 * fABorderWidth); - //g.setColour(Colours::FOREGROUNDBYPASS); - g.fillRect(fABorder); - - g.setColour(Colours::BACKGROUNDBYPASS); - g.fillRect(fA); - paintBorderLines(g); - } //region paintBorderLines @@ -1088,7 +1094,8 @@ void CrystalizerEQAudioProcessorEditor::setupHeader() { Layout::area(presetBox, 2, 2, 3, 3), Layout::area(resetButton, 2, 1, 2, 2), // MenĂ¼taste unten rechts (row2, col2) - Layout::area(presetMenuButton, 2, 3, 3, 4), + Layout::area(presetMenuButton, 2, 3, 3, 4) + , }); diff --git a/CrystalizerEQ/PluginEditor.h b/CrystalizerEQ/PluginEditor.h index 09b5265..bb32007 100644 --- a/CrystalizerEQ/PluginEditor.h +++ b/CrystalizerEQ/PluginEditor.h @@ -253,8 +253,11 @@ private: std::unique_ptr freqQLookAndFeel; std::unique_ptr globalLookAndFeel; std::unique_ptr bypassButtonLookAndFeel; + std::unique_ptr presetMenuButtonLookAndFeel; + std::unique_ptr svgToggleButtonLookAndFeel; + //SPECRTRUM ANALYZER