Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit f7a7015

Browse files
committedNov 9, 2023
Merge pull request godotengine#84662 from YuriSizov/gui-warn-about-autowrapping
Warn about autowrapped labels in containers
2 parents 19db930 + 58a3cfa commit f7a7015

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed
 

‎scene/gui/control.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -1653,6 +1653,7 @@ void Control::set_custom_minimum_size(const Size2 &p_custom) {
16531653

16541654
data.custom_minimum_size = p_custom;
16551655
update_minimum_size();
1656+
update_configuration_warnings();
16561657
}
16571658

16581659
Size2 Control::get_custom_minimum_size() const {

‎scene/gui/label.cpp

+15
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
#include "core/config/project_settings.h"
3434
#include "core/string/print_string.h"
3535
#include "core/string/translation.h"
36+
#include "scene/gui/container.h"
3637
#include "scene/theme/theme_db.h"
3738
#include "servers/text_server.h"
3839

@@ -44,6 +45,7 @@ void Label::set_autowrap_mode(TextServer::AutowrapMode p_mode) {
4445
autowrap_mode = p_mode;
4546
lines_dirty = true;
4647
queue_redraw();
48+
update_configuration_warnings();
4749

4850
if (clip || overrun_behavior != TextServer::OVERRUN_NO_TRIMMING) {
4951
update_minimum_size();
@@ -327,6 +329,19 @@ inline void draw_glyph_outline(const Glyph &p_gl, const RID &p_canvas, const Col
327329
PackedStringArray Label::get_configuration_warnings() const {
328330
PackedStringArray warnings = Control::get_configuration_warnings();
329331

332+
// FIXME: This is not ideal and the sizing model should be fixed,
333+
// but for now we have to warn about this impossible to resolve combination.
334+
// See GH-83546.
335+
if (is_inside_tree() && get_tree()->get_edited_scene_root() != this) {
336+
// If the Label happens to be the root node of the edited scene, we don't need
337+
// to check what its parent is. It's going to be some node from the editor tree
338+
// and it can be a container, but that makes no difference to the user.
339+
Container *parent_container = Object::cast_to<Container>(get_parent_control());
340+
if (parent_container && autowrap_mode != TextServer::AUTOWRAP_OFF && get_custom_minimum_size() == Size2()) {
341+
warnings.push_back(RTR("Labels with autowrapping enabled must have a custom minimum size configured to work correctly inside a container."));
342+
}
343+
}
344+
330345
// Ensure that the font can render all of the required glyphs.
331346
Ref<Font> font;
332347
if (settings.is_valid()) {

0 commit comments

Comments
 (0)
Please sign in to comment.