From da5195fc927614aa9340bb1a1729428f0e5bbfbc Mon Sep 17 00:00:00 2001 From: Michael Alexsander Silva Dias Date: Wed, 28 Aug 2019 23:12:22 -0300 Subject: [PATCH] Fix wrong offset in Button when alignment is set to left --- doc/classes/Button.xml | 2 +- scene/gui/button.cpp | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/doc/classes/Button.xml b/doc/classes/Button.xml index adf826c26b..6a8cdcd2a8 100644 --- a/doc/classes/Button.xml +++ b/doc/classes/Button.xml @@ -15,7 +15,7 @@ Text alignment policy for the button's text, use one of the [code]ALIGN_*[/code] constants. - When this property is enabled, text that is too large to fit the button is clipped, when disabled the Button will always be wide enough to hold the text. This property is disabled by default. + When this property is enabled, text that is too large to fit the button is clipped, when disabled the Button will always be wide enough to hold the text. Flat buttons don't display decoration. diff --git a/scene/gui/button.cpp b/scene/gui/button.cpp index 65e9cccd05..4ce3f18505 100644 --- a/scene/gui/button.cpp +++ b/scene/gui/button.cpp @@ -159,7 +159,11 @@ void Button::_notification(int p_what) { switch (align) { case ALIGN_LEFT: { - text_ofs.x = style->get_margin(MARGIN_LEFT) + icon_ofs.x + _internal_margin[MARGIN_LEFT] + get_constant("hseparation"); + if (_internal_margin[MARGIN_LEFT] > 0) { + text_ofs.x = style->get_margin(MARGIN_LEFT) + icon_ofs.x + _internal_margin[MARGIN_LEFT] + get_constant("hseparation"); + } else { + text_ofs.x = style->get_margin(MARGIN_LEFT) + icon_ofs.x; + } text_ofs.y += style->get_offset().y; } break; case ALIGN_CENTER: {