From 90c88ec41608b0124ac1dfd6b4b86165fef08c65 Mon Sep 17 00:00:00 2001 From: jules Date: Mon, 23 Mar 2015 18:13:07 +0000 Subject: [PATCH] Tweaked the Label class to take its border into account when positioning relative to a target component. --- modules/juce_gui_basics/widgets/juce_Label.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/modules/juce_gui_basics/widgets/juce_Label.cpp b/modules/juce_gui_basics/widgets/juce_Label.cpp index 9bfb4fde6c..56643cb38b 100644 --- a/modules/juce_gui_basics/widgets/juce_Label.cpp +++ b/modules/juce_gui_basics/widgets/juce_Label.cpp @@ -162,7 +162,8 @@ void Label::componentMovedOrResized (Component& component, bool /*wasMoved*/, bo if (leftOfOwnerComp) { - setSize (jmin (f.getStringWidth (textValue.toString()) + 8, component.getX()), + setSize (jmin (roundToInt (f.getStringWidthFloat (textValue.toString()) + 0.5f) + getBorderSize().getLeftAndRight(), + component.getX()), component.getHeight()); setTopRightPosition (component.getX(), component.getY()); @@ -170,7 +171,7 @@ void Label::componentMovedOrResized (Component& component, bool /*wasMoved*/, bo else { setSize (component.getWidth(), - 8 + roundToInt (f.getHeight())); + getBorderSize().getTopAndBottom() + 6 + roundToInt (f.getHeight() + 0.5f)); setTopLeftPosition (component.getX(), component.getY() - getHeight()); }