From bd7cf87b8e6e5705ac68b8b0dfc121e7c0858c32 Mon Sep 17 00:00:00 2001 From: Michael Alexsander Date: Thu, 12 Dec 2019 18:46:04 -0300 Subject: Make Button and co. take internal margins into account when clipping text --- scene/gui/button.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/scene/gui/button.cpp b/scene/gui/button.cpp index ca4c255855..a68462f4d4 100644 --- a/scene/gui/button.cpp +++ b/scene/gui/button.cpp @@ -190,6 +190,13 @@ void Button::_notification(int p_what) { Point2 icon_ofs = !_icon.is_null() ? Point2(icon_region.size.width + get_constant("hseparation"), 0) : Point2(); int text_clip = size.width - style->get_minimum_size().width - icon_ofs.width; + if (_internal_margin[MARGIN_LEFT] > 0) { + text_clip -= _internal_margin[MARGIN_LEFT] + get_constant("hseparation"); + } + if (_internal_margin[MARGIN_RIGHT] > 0) { + text_clip -= _internal_margin[MARGIN_RIGHT] + get_constant("hseparation"); + } + Point2 text_ofs = (size - style->get_minimum_size() - icon_ofs - font->get_string_size(xl_text) - Point2(_internal_margin[MARGIN_RIGHT] - _internal_margin[MARGIN_LEFT], 0)) / 2.0; switch (align) { -- cgit v1.2.3