From 0ca253856ba179531ccd88ad73f2ab9399a71b9f Mon Sep 17 00:00:00 2001 From: jules Date: Mon, 7 Aug 2017 09:54:49 +0100 Subject: [PATCH] Added a method DrawableButton::getEdgeIndent() --- .../buttons/juce_DrawableButton.cpp | 15 ++++++--------- .../juce_gui_basics/buttons/juce_DrawableButton.h | 7 +++++-- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/modules/juce_gui_basics/buttons/juce_DrawableButton.cpp b/modules/juce_gui_basics/buttons/juce_DrawableButton.cpp index 988b22a58c..3fa94c0c85 100644 --- a/modules/juce_gui_basics/buttons/juce_DrawableButton.cpp +++ b/modules/juce_gui_basics/buttons/juce_DrawableButton.cpp @@ -25,10 +25,7 @@ */ DrawableButton::DrawableButton (const String& name, const DrawableButton::ButtonStyle buttonStyle) - : Button (name), - style (buttonStyle), - currentImage (nullptr), - edgeIndent (3) + : Button (name), style (buttonStyle) { } @@ -85,12 +82,12 @@ void DrawableButton::setEdgeIndent (const int numPixelsIndent) Rectangle DrawableButton::getImageBounds() const { - Rectangle r (getLocalBounds()); + auto r = getLocalBounds(); if (style != ImageStretched) { - int indentX = jmin (edgeIndent, proportionOfWidth (0.3f)); - int indentY = jmin (edgeIndent, proportionOfHeight (0.3f)); + auto indentX = jmin (edgeIndent, proportionOfWidth (0.3f)); + auto indentY = jmin (edgeIndent, proportionOfHeight (0.3f)); if (style == ImageOnButtonBackground) { @@ -178,7 +175,7 @@ void DrawableButton::paintButton (Graphics& g, const bool isMouseOverButton, const bool isButtonDown) { - LookAndFeel& lf = getLookAndFeel(); + auto& lf = getLookAndFeel(); if (style == ImageOnButtonBackground) lf.drawButtonBackground (g, *this, @@ -217,7 +214,7 @@ Drawable* DrawableButton::getOverImage() const noexcept Drawable* DrawableButton::getDownImage() const noexcept { - if (Drawable* const d = getToggleState() ? downImageOn : downImage) + if (auto* d = getToggleState() ? downImageOn.get() : downImage.get()) return d; return getOverImage(); diff --git a/modules/juce_gui_basics/buttons/juce_DrawableButton.h b/modules/juce_gui_basics/buttons/juce_DrawableButton.h index 91e332eb51..44124c2b58 100644 --- a/modules/juce_gui_basics/buttons/juce_DrawableButton.h +++ b/modules/juce_gui_basics/buttons/juce_DrawableButton.h @@ -122,6 +122,9 @@ public: */ void setEdgeIndent (int numPixelsIndent); + /** Returns the current edge indent size. */ + int getEdgeIndent() const noexcept { return edgeIndent; } + //============================================================================== /** Returns the image that the button is currently displaying. */ Drawable* getCurrentImage() const noexcept; @@ -179,8 +182,8 @@ private: ButtonStyle style; ScopedPointer normalImage, overImage, downImage, disabledImage, normalImageOn, overImageOn, downImageOn, disabledImageOn; - Drawable* currentImage; - int edgeIndent; + Drawable* currentImage = nullptr; + int edgeIndent = 3; JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (DrawableButton) };