From 56ea97916d5ae2d14e4671dfef64e3a75f504247 Mon Sep 17 00:00:00 2001 From: Legaeli Date: Thu, 6 Nov 2025 11:05:30 +0100 Subject: [PATCH] Fixed bypass icon colour bug, added hoverfactor and removed text. --- CrystalizerEQ/AXIOMDesignSystem.h | 55 ++++++++++++++++--------------- CrystalizerEQ/PluginEditor.cpp | 4 --- 2 files changed, 28 insertions(+), 31 deletions(-) diff --git a/CrystalizerEQ/AXIOMDesignSystem.h b/CrystalizerEQ/AXIOMDesignSystem.h index 4fa044f..e75b68e 100644 --- a/CrystalizerEQ/AXIOMDesignSystem.h +++ b/CrystalizerEQ/AXIOMDesignSystem.h @@ -530,48 +530,49 @@ namespace AXIOM { class BypassButtonLookAndFeel : public juce::LookAndFeel_V4 { public: BypassButtonLookAndFeel() - { - // SVG aus BinaryData laden - if (auto svgData = juce::XmlDocument::parse( - BinaryData::bypass_icon_svg)) // Dein Dateiname ohne Extension - { - bypassIcon = juce::Drawable::createFromSVG(*svgData); - } + svgXml = juce::XmlDocument::parse(BinaryData::bypass_icon_svg); } void drawToggleButton(juce::Graphics& g, juce::ToggleButton& button, bool shouldDrawButtonAsHighlighted, bool shouldDrawButtonAsDown) override { + bool isHovered = button.isMouseOverOrDragging(); + bool isToggled = button.getToggleState(); auto bounds = button.getLocalBounds().toFloat(); auto iconSize = juce::jmin(bounds.getWidth(), bounds.getHeight()) * 0.5f; + auto hoverFactor = isHovered ? 1.05f : 1.0f; - // Icon-Bereich (links vom Text) - auto iconBounds = bounds.removeFromLeft(iconSize).reduced(4.0f); - //TODO ERKENNT TOGGLESTATE NICHT; FARBE ÄNDERT SICH NICHT. - if (bypassIcon != nullptr) - { - // Farbe basierend auf Toggle-Status - auto colour = button.getToggleState() - ? Colours::ACCENTCOLOUR - : Colours::SURFACECOLOUR; + auto iconBounds = juce::Rectangle(iconSize * hoverFactor, iconSize * hoverFactor) + .withCentre(bounds.getCentre()); - // Icon zeichnen - bypassIcon->replaceColour(juce::Colours::black, colour); - bypassIcon->drawWithin(g, iconBounds, - juce::RectanglePlacement::centred, 1.0f); + + if (svgXml != nullptr) { + // WICHTIG: Erstelle für jeden Frame ein NEUES Drawable! + auto icon = juce::Drawable::createFromSVG(*svgXml); + //TODO ON MASTERBYPASS SET TO HOVER COLOUR + if (icon != nullptr) + { + juce::Colour colour; + if (isHovered) { + colour = isToggled ? Colours::SURFACEHOVER : Colours::ACCENTHOVER; + } else { + colour = isToggled + ? Colours::SURFACECOLOUR + : Colours::ACCENTCOLOUR; + } + + // Icon zeichnen + icon->replaceColour(juce::Colours::black, colour); + icon->drawWithin(g, iconBounds, + juce::RectanglePlacement::centred, 1.0f); + } } - - // Text zeichnen - g.setColour(button.findColour(juce::ToggleButton::textColourId)); - g.setFont(Typography::getFont(Typography::Style::Small)); - g.drawText(button.getButtonText(), bounds, - juce::Justification::centredLeft, true); } private: - std::unique_ptr bypassIcon; + std::unique_ptr svgXml; }; struct ButtonStyles { diff --git a/CrystalizerEQ/PluginEditor.cpp b/CrystalizerEQ/PluginEditor.cpp index e11fa79..f9eedd2 100644 --- a/CrystalizerEQ/PluginEditor.cpp +++ b/CrystalizerEQ/PluginEditor.cpp @@ -150,19 +150,16 @@ void CrystalizerEQAudioProcessorEditor::setupDisplayNames() { peak1GainSlider.setTextValueSuffix("\ndB"); //peak1QSlider.setTextValueSuffix("\nQ"); peak1BypassButton.setName("peak1Bypass"); - peak1BypassButton.setButtonText("Low-Mid Bypass"); //peak2FreqSlider.setTextValueSuffix("\nHz"); peak2GainSlider.setTextValueSuffix("\ndB"); //peak2QSlider.setTextValueSuffix("\nQ"); peak2BypassButton.setName("peak2Bypass"); - peak2BypassButton.setButtonText("Mid Bypass"); //peak3FreqSlider.setTextValueSuffix("\nHz"); peak3GainSlider.setTextValueSuffix("\ndB"); //peak3QSlider.setTextValueSuffix("\nQ"); peak3BypassButton.setName("peak3Bypass"); - peak3BypassButton.setButtonText("High-Mid Bypass"); //highBandFreqSlider.setTextValueSuffix ("\nHz"); highBandSlopeSlider.setTextValueSuffix ("\ndB/Oct"); @@ -182,7 +179,6 @@ void CrystalizerEQAudioProcessorEditor::setupDisplayNames() { resetButton.setButtonText("Reset"); masterBypassButton.setName("MasterBypass"); - masterBypassButton.setButtonText("Master Bypass"); savePresetButton.setName("SavePresetButton"); savePresetButton.setButtonText("Save Preset");