diff options
| author | Rémi Verschelde <rverschelde@gmail.com> | 2023-11-09 18:09:25 +0100 |
|---|---|---|
| committer | Rémi Verschelde <rverschelde@gmail.com> | 2023-11-09 18:09:25 +0100 |
| commit | f7a701587e662f0906826354b2283e4dc4aa3a84 (patch) | |
| tree | e976f9e3824c3879842405e8d0760c81b7a5b20e /scene/gui | |
| parent | 19db9308ffb7a3bd3d34d6be92ab08fb54f350bb (diff) | |
| parent | 58a3cfa1927b515c0823f39aba6e44eb33d1cb6a (diff) | |
| download | redot-engine-f7a701587e662f0906826354b2283e4dc4aa3a84.tar.gz | |
Merge pull request #84662 from YuriSizov/gui-warn-about-autowrapping
Warn about autowrapped labels in containers
Diffstat (limited to 'scene/gui')
| -rw-r--r-- | scene/gui/control.cpp | 1 | ||||
| -rw-r--r-- | scene/gui/label.cpp | 15 |
2 files changed, 16 insertions, 0 deletions
diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp index 87539ef8f2..ed54bd000c 100644 --- a/scene/gui/control.cpp +++ b/scene/gui/control.cpp @@ -1653,6 +1653,7 @@ void Control::set_custom_minimum_size(const Size2 &p_custom) { data.custom_minimum_size = p_custom; update_minimum_size(); + update_configuration_warnings(); } Size2 Control::get_custom_minimum_size() const { diff --git a/scene/gui/label.cpp b/scene/gui/label.cpp index 0d48cb1549..2fbd29b048 100644 --- a/scene/gui/label.cpp +++ b/scene/gui/label.cpp @@ -33,6 +33,7 @@ #include "core/config/project_settings.h" #include "core/string/print_string.h" #include "core/string/translation.h" +#include "scene/gui/container.h" #include "scene/theme/theme_db.h" #include "servers/text_server.h" @@ -44,6 +45,7 @@ void Label::set_autowrap_mode(TextServer::AutowrapMode p_mode) { autowrap_mode = p_mode; lines_dirty = true; queue_redraw(); + update_configuration_warnings(); if (clip || overrun_behavior != TextServer::OVERRUN_NO_TRIMMING) { update_minimum_size(); @@ -327,6 +329,19 @@ inline void draw_glyph_outline(const Glyph &p_gl, const RID &p_canvas, const Col PackedStringArray Label::get_configuration_warnings() const { PackedStringArray warnings = Control::get_configuration_warnings(); + // FIXME: This is not ideal and the sizing model should be fixed, + // but for now we have to warn about this impossible to resolve combination. + // See GH-83546. + if (is_inside_tree() && get_tree()->get_edited_scene_root() != this) { + // If the Label happens to be the root node of the edited scene, we don't need + // to check what its parent is. It's going to be some node from the editor tree + // and it can be a container, but that makes no difference to the user. + Container *parent_container = Object::cast_to<Container>(get_parent_control()); + if (parent_container && autowrap_mode != TextServer::AUTOWRAP_OFF && get_custom_minimum_size() == Size2()) { + warnings.push_back(RTR("Labels with autowrapping enabled must have a custom minimum size configured to work correctly inside a container.")); + } + } + // Ensure that the font can render all of the required glyphs. Ref<Font> font; if (settings.is_valid()) { |
