summaryrefslogtreecommitdiff
path: root/scene
diff options
context:
space:
mode:
Diffstat (limited to 'scene')
-rw-r--r--scene/gui/aspect_ratio_container.cpp12
-rw-r--r--scene/gui/label.cpp16
2 files changed, 21 insertions, 7 deletions
diff --git a/scene/gui/aspect_ratio_container.cpp b/scene/gui/aspect_ratio_container.cpp
index 802189c374..94240ccead 100644
--- a/scene/gui/aspect_ratio_container.cpp
+++ b/scene/gui/aspect_ratio_container.cpp
@@ -30,6 +30,8 @@
#include "aspect_ratio_container.h"
+#include "scene/gui/texture_rect.h"
+
Size2 AspectRatioContainer::get_minimum_size() const {
Size2 ms;
for (int i = 0; i < get_child_count(); i++) {
@@ -113,6 +115,16 @@ void AspectRatioContainer::_notification(int p_what) {
if (c->is_set_as_top_level()) {
continue;
}
+
+ // Temporary fix for editor crash.
+ TextureRect *trect = Object::cast_to<TextureRect>(c);
+ if (trect) {
+ if (trect->get_expand_mode() == TextureRect::EXPAND_FIT_WIDTH_PROPORTIONAL || trect->get_expand_mode() == TextureRect::EXPAND_FIT_HEIGHT_PROPORTIONAL) {
+ WARN_PRINT_ONCE("Proportional TextureRect is currently not supported inside AspectRatioContainer");
+ continue;
+ }
+ }
+
Size2 child_minsize = c->get_combined_minimum_size();
Size2 child_size = Size2(ratio, 1.0);
float scale_factor = 1.0;
diff --git a/scene/gui/label.cpp b/scene/gui/label.cpp
index 45218773fe..b861d7af01 100644
--- a/scene/gui/label.cpp
+++ b/scene/gui/label.cpp
@@ -139,11 +139,14 @@ bool Label::_shape() {
can_process_lines = true;
lines_dirty = false;
} else {
- // With autowrap on, we won't compute the minimum size until width is stable (two shape requests in a
- // row with the same width.) This avoids situations in which the initial width is very narrow and the label
- // would break text into many very short lines, causing a very tall label that can leave a deformed container.
-
- can_process_lines = get_size().width == stable_width || autowrap_mode == TextServer::AUTOWRAP_OFF;
+ // With autowrap on or off with trimming enabled, we won't compute the minimum size until width is stable
+ // (two shape requests in a row with the same width.) This avoids situations in which the initial width is
+ // very narrow and the label would break text into many very short lines, causing a very tall label that can
+ // leave a deformed container. In the remaining case (namely, autowrap off and no trimming), the label is
+ // free to dictate its own width, something that will be taken advtantage of.
+ bool can_dictate_width = autowrap_mode == TextServer::AUTOWRAP_OFF && overrun_behavior == TextServer::OVERRUN_NO_TRIMMING;
+ bool is_width_stable = get_size().width == stable_width;
+ can_process_lines = can_dictate_width || is_width_stable;
stable_width = get_size().width;
if (can_process_lines) {
@@ -171,14 +174,13 @@ bool Label::_shape() {
}
}
- if (autowrap_mode == TextServer::AUTOWRAP_OFF) {
+ if (can_dictate_width) {
for (int i = 0; i < lines_rid.size(); i++) {
if (minsize.width < TS->shaped_text_get_size(lines_rid[i]).x) {
minsize.width = TS->shaped_text_get_size(lines_rid[i]).x;
}
}
- // With autowrap off, by now we already know the width the label will take.
width = (minsize.width - style->get_minimum_size().width);
}