Skip to content

Commit c89ded2

Browse files
committed
Merge pull request godotengine#102603 from havi05/itemlist-fix-textoverrun-fixed-icon
Itemlist: Fix `text_overrun` when using `fixed_icon_size`
2 parents 4b644ed + e43756c commit c89ded2

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

scene/gui/item_list.cpp

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1282,10 +1282,8 @@ void ItemList::_notification(int p_what) {
12821282
}
12831283

12841284
Vector2 text_ofs;
1285+
Size2 icon_size;
12851286
if (items[i].icon.is_valid()) {
1286-
Size2 icon_size;
1287-
//= _adjust_to_max_size(items[i].get_icon_size(),fixed_icon_size) * icon_scale;
1288-
12891287
if (fixed_icon_size.x > 0 && fixed_icon_size.y > 0) {
12901288
icon_size = fixed_icon_size * icon_scale;
12911289
} else {
@@ -1417,14 +1415,14 @@ void ItemList::_notification(int p_what) {
14171415
text_ofs += base_ofs;
14181416
text_ofs += items[i].rect_cache.position;
14191417

1420-
float text_w = items[i].rect_cache.size.width - (items[i].get_icon_size().x * icon_scale) - MAX(theme_cache.h_separation, 0);
1418+
float text_w = items[i].rect_cache.size.width - icon_size.x - MAX(theme_cache.h_separation, 0);
14211419
if (wraparound_items && items[i].rect_cache.size.width > width) {
14221420
text_w -= items[i].rect_cache.size.width - width;
14231421
}
14241422
items.write[i].text_buf->set_width(text_w);
14251423

14261424
if (rtl) {
1427-
text_ofs.x = size.width - items[i].rect_cache.size.width + (items[i].get_icon_size().x * icon_scale) - text_ofs.x + MAX(theme_cache.h_separation, 0);
1425+
text_ofs.x = size.width - items[i].rect_cache.size.width + icon_size.x - text_ofs.x + MAX(theme_cache.h_separation, 0);
14281426
if (wraparound_items) {
14291427
text_ofs.x += MAX(items[i].rect_cache.size.width - width, 0);
14301428
}
@@ -1438,12 +1436,12 @@ void ItemList::_notification(int p_what) {
14381436
}
14391437

14401438
if (fixed_column_width > 0) {
1441-
if (items[i].rect_cache.size.width - (items[i].get_icon_size().x * icon_scale) - MAX(theme_cache.h_separation, 0) > 0) {
1439+
if (items[i].rect_cache.size.width - icon_size.x - MAX(theme_cache.h_separation, 0) > 0) {
14421440
items[i].text_buf->draw(get_canvas_item(), text_ofs, txt_modulate);
14431441
}
14441442
} else {
14451443
if (wraparound_items) {
1446-
if (width - (items[i].get_icon_size().x * icon_scale) - MAX(theme_cache.h_separation, 0) - int(scroll_bar_h->get_value()) > 0) {
1444+
if (width - icon_size.x - MAX(theme_cache.h_separation, 0) - int(scroll_bar_h->get_value()) > 0) {
14471445
items[i].text_buf->draw(get_canvas_item(), text_ofs, txt_modulate);
14481446
}
14491447
} else {

0 commit comments

Comments
 (0)