Fixed bypass icon colour bug, added hoverfactor and removed text.
This commit is contained in:
parent
9cdaf6bb8a
commit
56ea97916d
@ -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<float>(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<juce::Drawable> bypassIcon;
|
||||
std::unique_ptr<juce::XmlElement> svgXml;
|
||||
};
|
||||
|
||||
struct ButtonStyles {
|
||||
|
||||
@ -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");
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user