summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Alexsander <michaelalexsander@protonmail.com>2019-12-12 18:46:04 -0300
committerMichael Alexsander <michaelalexsander@protonmail.com>2019-12-12 18:46:04 -0300
commitbd7cf87b8e6e5705ac68b8b0dfc121e7c0858c32 (patch)
tree0555c41e98e72c139b28958229a2bef84bfc95c7
parentf065b34e969f93e5ecc9046e01c5c14c416d2d16 (diff)
Make Button and co. take internal margins into account when clipping text
-rw-r--r--scene/gui/button.cpp7
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) {