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
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions scene/gui/item_list.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -1417,14 +1415,14 @@ void ItemList::_notification(int p_what) {
text_ofs += base_ofs;
text_ofs += items[i].rect_cache.position;

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

if (rtl) {
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);
text_ofs.x = size.width - items[i].rect_cache.size.width + icon_size.x - text_ofs.x + MAX(theme_cache.h_separation, 0);
if (wraparound_items) {
text_ofs.x += MAX(items[i].rect_cache.size.width - width, 0);
}
Expand All @@ -1438,12 +1436,12 @@ void ItemList::_notification(int p_what) {
}

if (fixed_column_width > 0) {
if (items[i].rect_cache.size.width - (items[i].get_icon_size().x * icon_scale) - MAX(theme_cache.h_separation, 0) > 0) {
if (items[i].rect_cache.size.width - icon_size.x - MAX(theme_cache.h_separation, 0) > 0) {
items[i].text_buf->draw(get_canvas_item(), text_ofs, txt_modulate);
}
} else {
if (wraparound_items) {
if (width - (items[i].get_icon_size().x * icon_scale) - MAX(theme_cache.h_separation, 0) - int(scroll_bar_h->get_value()) > 0) {
if (width - icon_size.x - MAX(theme_cache.h_separation, 0) - int(scroll_bar_h->get_value()) > 0) {
items[i].text_buf->draw(get_canvas_item(), text_ofs, txt_modulate);
}
} else {
Expand Down