From 718712a5a555c6e98c9f9b44b91eb2ab31e00ba7 Mon Sep 17 00:00:00 2001 From: ed Date: Tue, 25 Jun 2019 10:53:20 +0100 Subject: [PATCH] Ensure that the button background is drawn for DrawableButton::ButtonStyle::ImageOnButtonBackgroundOriginalSize --- modules/juce_gui_basics/buttons/juce_DrawableButton.cpp | 4 ++-- modules/juce_gui_basics/buttons/juce_DrawableButton.h | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/modules/juce_gui_basics/buttons/juce_DrawableButton.cpp b/modules/juce_gui_basics/buttons/juce_DrawableButton.cpp index d906d12d59..c6a583dba8 100644 --- a/modules/juce_gui_basics/buttons/juce_DrawableButton.cpp +++ b/modules/juce_gui_basics/buttons/juce_DrawableButton.cpp @@ -96,7 +96,7 @@ Rectangle DrawableButton::getImageBounds() const auto indentX = jmin (edgeIndent, proportionOfWidth (0.3f)); auto indentY = jmin (edgeIndent, proportionOfHeight (0.3f)); - if (style == ImageOnButtonBackground) + if (shouldDrawButtonBackground()) { indentX = jmax (getWidth() / 4, indentX); indentY = jmax (getHeight() / 4, indentY); @@ -200,7 +200,7 @@ void DrawableButton::paintButton (Graphics& g, { auto& lf = getLookAndFeel(); - if (style == ImageOnButtonBackground) + if (shouldDrawButtonBackground()) lf.drawButtonBackground (g, *this, findColour (getToggleState() ? TextButton::buttonOnColourId : TextButton::buttonColourId), diff --git a/modules/juce_gui_basics/buttons/juce_DrawableButton.h b/modules/juce_gui_basics/buttons/juce_DrawableButton.h index d826b49415..b8bf21b9f3 100644 --- a/modules/juce_gui_basics/buttons/juce_DrawableButton.h +++ b/modules/juce_gui_basics/buttons/juce_DrawableButton.h @@ -182,6 +182,9 @@ public: void colourChanged() override; private: + //============================================================================== + bool shouldDrawButtonBackground() const { return style == ImageOnButtonBackground || style == ImageOnButtonBackgroundOriginalSize; } + //============================================================================== ButtonStyle style; std::unique_ptr normalImage, overImage, downImage, disabledImage,