From ef98ae9cedcd910d6b4ea3883a09c2e77174c799 Mon Sep 17 00:00:00 2001 From: jules Date: Sat, 5 Mar 2016 15:06:43 +0000 Subject: [PATCH] Avoided an assertion in LookAndFeel_V2 with small TextButtons --- .../lookandfeel/juce_LookAndFeel_V2.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V2.cpp b/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V2.cpp index af92bd8101..39a2554fd6 100644 --- a/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V2.cpp +++ b/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V2.cpp @@ -265,13 +265,12 @@ void LookAndFeel_V2::drawButtonText (Graphics& g, TextButton& button, bool /*isM const int fontHeight = roundToInt (font.getHeight() * 0.6f); const int leftIndent = jmin (fontHeight, 2 + cornerSize / (button.isConnectedOnLeft() ? 4 : 2)); const int rightIndent = jmin (fontHeight, 2 + cornerSize / (button.isConnectedOnRight() ? 4 : 2)); + const int textWidth = button.getWidth() - leftIndent - rightIndent; - g.drawFittedText (button.getButtonText(), - leftIndent, - yIndent, - button.getWidth() - leftIndent - rightIndent, - button.getHeight() - yIndent * 2, - Justification::centred, 2); + if (textWidth > 0) + g.drawFittedText (button.getButtonText(), + leftIndent, yIndent, textWidth, button.getHeight() - yIndent * 2, + Justification::centred, 2); } void LookAndFeel_V2::drawTickBox (Graphics& g, Component& component,