summaryrefslogtreecommitdiff
path: root/scene/gui
diff options
context:
space:
mode:
authorPouleyKetchoupp <pouleyketchoup@gmail.com>2019-11-04 10:12:15 +0100
committerPouleyKetchoupp <pouleyketchoup@gmail.com>2019-11-04 10:12:36 +0100
commit13c88878c4c6daae1f5ce83b516f15fdd8a45dd6 (patch)
tree0a2e9ea617da9b73f2f6f8821457401e5a3327cc /scene/gui
parent5dac35a300504bfa193e98102eac727b287323ea (diff)
Fixed cases where labels with autowrap can overflow the editor ui
Fixes #33155
Diffstat (limited to 'scene/gui')
-rw-r--r--scene/gui/label.cpp13
1 files changed, 10 insertions, 3 deletions
diff --git a/scene/gui/label.cpp b/scene/gui/label.cpp
index 4edd4b8530..9e2cd9e941 100644
--- a/scene/gui/label.cpp
+++ b/scene/gui/label.cpp
@@ -296,8 +296,9 @@ Size2 Label::get_minimum_size() const {
Size2 min_style = get_stylebox("normal")->get_minimum_size();
// don't want to mutable everything
- if (word_cache_dirty)
+ if (word_cache_dirty) {
const_cast<Label *>(this)->regenerate_word_cache();
+ }
if (autowrap)
return Size2(1, clip ? 1 : minsize.height) + min_style;
@@ -377,8 +378,14 @@ void Label::regenerate_word_cache() {
memdelete(current);
}
- Ref<StyleBox> style = get_stylebox("normal");
- int width = autowrap ? (get_size().width - style->get_minimum_size().width) : get_longest_line_width();
+ int width;
+ if (autowrap) {
+ Ref<StyleBox> style = get_stylebox("normal");
+ width = MAX(get_size().width, get_custom_minimum_size().width) - style->get_minimum_size().width;
+ } else {
+ width = get_longest_line_width();
+ }
+
Ref<Font> font = get_font("font");
int current_word_size = 0;