diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2019-12-13 00:30:27 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-12-13 00:30:27 +0100 |
commit | ec97535ea34456607c0c53607d41e34f272890ec (patch) | |
tree | 24be5caf862d0fcd9da9c3dafb5510d2697be4dc | |
parent | aab70008d3593f9ef06045fb8eae1143b07ea15f (diff) | |
parent | bd7cf87b8e6e5705ac68b8b0dfc121e7c0858c32 (diff) |
Merge pull request #34314 from YeldhamDev/button_internal_margin_clip
Make Button and co. take internal margins into account when clipping text
-rw-r--r-- | scene/gui/button.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
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) { |