Make the position and the size of FileSystem controls more precise

This commit is contained in:
BrotherShort
2025-04-19 16:52:17 +08:00
parent 8f78e7510d
commit a52a7a4a48
3 changed files with 31 additions and 24 deletions

View File

@@ -329,11 +329,14 @@ Rect2 ItemList::get_item_rect(int p_idx, bool p_expand) const {
ERR_FAIL_INDEX_V(p_idx, items.size(), Rect2());
Rect2 ret = items[p_idx].rect_cache;
ret.position += theme_cache.panel_style->get_offset();
if (p_expand && p_idx % current_columns == current_columns - 1) {
ret.size.width = get_size().width - ret.position.x;
int width = get_size().width - theme_cache.panel_style->get_minimum_size().width;
if (scroll_bar_v->is_visible()) {
width -= scroll_bar_v->get_combined_minimum_size().width;
}
ret.size.width = width - ret.position.x;
}
ret.position += theme_cache.panel_style->get_offset();
return ret;
}
@@ -1524,9 +1527,7 @@ void ItemList::_notification(int p_what) {
icon_size = items[i].get_icon_size() * icon_scale;
}
Vector2 icon_ofs;
Point2 pos = items[i].rect_cache.position + icon_ofs + base_ofs;
Point2 pos = items[i].rect_cache.position + base_ofs;
if (icon_mode == ICON_MODE_TOP) {
pos.y += MAX(theme_cache.v_separation, 0) / 2;
@@ -1579,14 +1580,14 @@ void ItemList::_notification(int p_what) {
tag_icon_size = items[i].tag_icon->get_size();
}
Point2 draw_pos = items[i].rect_cache.position;
Point2 draw_pos = items[i].rect_cache.position + base_ofs;
draw_pos.x += MAX(theme_cache.h_separation, 0) / 2;
draw_pos.y += MAX(theme_cache.v_separation, 0) / 2;
if (rtl) {
draw_pos.x = size.width - draw_pos.x - tag_icon_size.x;
}
draw_texture_rect(items[i].tag_icon, Rect2(draw_pos + base_ofs, tag_icon_size));
draw_texture_rect(items[i].tag_icon, Rect2(draw_pos, tag_icon_size));
}
if (!items[i].text.is_empty()) {
@@ -1646,10 +1647,12 @@ void ItemList::_notification(int p_what) {
text_ofs.x += MAX(theme_cache.h_separation, 0) / 2;
}
real_t text_width_ofs = text_ofs.x;
text_ofs += base_ofs;
text_ofs += items[i].rect_cache.position;
float text_w = items[i].rect_cache.size.width - icon_size.x - MAX(theme_cache.h_separation, 0);
float text_w = items[i].rect_cache.size.width - text_width_ofs;
if (wraparound_items && items[i].rect_cache.size.width > width) {
text_w -= items[i].rect_cache.size.width - width;
}