Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Itemlist: Fix text_overrun when using fixed_icon_size #102603

Merged

Conversation

havi05
Copy link
Contributor

@havi05 havi05 commented Feb 8, 2025

Fixes #102581 which is a regression from #101899 where I forgot to check for the fixed_icon_size.

@havi05 havi05 requested a review from a team as a code owner February 8, 2025 22:22
@KoBeWi KoBeWi added this to the 4.4 milestone Feb 8, 2025
@akien-mga akien-mga requested a review from bruvzg February 10, 2025 09:59
Copy link
Member

@bruvzg bruvzg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems to be working as expected.

The icon_size is already calculated in the same function, so this can be simplified a bit:

diff --git a/scene/gui/item_list.cpp b/scene/gui/item_list.cpp
index 0613c70c11..8feacd4c2c 100644
--- a/scene/gui/item_list.cpp
+++ b/scene/gui/item_list.cpp
@@ -1282,10 +1282,8 @@ void ItemList::_notification(int p_what) {
 				}
 
 				Vector2 text_ofs;
+				Size2 icon_size;
 				if (items[i].icon.is_valid()) {
-					Size2 icon_size;
-					//= _adjust_to_max_size(items[i].get_icon_size(),fixed_icon_size) * icon_scale;
-
 					if (fixed_icon_size.x > 0 && fixed_icon_size.y > 0) {
 						icon_size = fixed_icon_size * icon_scale;
 					} else {
@@ -1401,11 +1399,6 @@ void ItemList::_notification(int p_what) {
 
 						items[i].text_buf->draw(get_canvas_item(), text_ofs, txt_modulate);
 					} else {
-						Size2 icon_size = items[i].get_icon_size() * icon_scale;
-						if (icon_size != Size2() && fixed_icon_size.x > 0 && fixed_icon_size.y > 0) {
-							icon_size = fixed_icon_size * icon_scale;
-						}
-
 						if (fixed_column_width > 0) {
 							size2.x = MIN(size2.x, fixed_column_width);
 						}

@havi05 havi05 force-pushed the itemlist-fix-textoverrun-fixed-icon branch from bfb9899 to e43756c Compare February 10, 2025 10:34
@Repiteo Repiteo merged commit c89ded2 into godotengine:master Feb 10, 2025
20 checks passed
@Repiteo
Copy link
Contributor

Repiteo commented Feb 10, 2025

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ItemList trims item text too much in specific cases
4 participants