Merge pull request #92669 from Hilderin/fix-huge-tscn-icon-in-background-of-file-system-panel

Fix huge .tscn icon and icon in background of File System panel
This commit is contained in:
Rémi Verschelde 2024-06-03 10:36:02 +02:00
commit 9b4cfcba5f
No known key found for this signature in database
GPG key ID: C3336907360768E1
3 changed files with 26 additions and 2 deletions

View file

@ -962,6 +962,9 @@ void FileSystemDock::_update_file_list(bool p_keep_selection) {
files->set_max_text_lines(2);
files->set_fixed_icon_size(Size2(thumbnail_size, thumbnail_size));
const int icon_size = get_theme_constant(SNAME("class_icon_size"), EditorStringName(Editor));
files->set_fixed_tag_icon_size(Size2(icon_size, icon_size));
if (thumbnail_size < 64) {
folder_thumbnail = get_editor_theme_icon(SNAME("FolderMediumThumb"));
file_thumbnail = get_editor_theme_icon(SNAME("FileMediumThumb"));

View file

@ -638,6 +638,16 @@ Size2 ItemList::Item::get_icon_size() const {
return size_result;
}
void ItemList::set_fixed_tag_icon_size(const Size2i &p_size) {
if (fixed_tag_icon_size == p_size) {
return;
}
fixed_tag_icon_size = p_size;
queue_redraw();
shape_changed = true;
}
void ItemList::gui_input(const Ref<InputEvent> &p_event) {
ERR_FAIL_COND(p_event.is_null());
@ -1225,13 +1235,21 @@ void ItemList::_notification(int p_what) {
}
if (items[i].tag_icon.is_valid()) {
Size2 tag_icon_size;
if (fixed_tag_icon_size.x > 0 && fixed_tag_icon_size.y > 0) {
tag_icon_size = fixed_tag_icon_size;
} else {
tag_icon_size = items[i].tag_icon->get_size();
}
Point2 draw_pos = items[i].rect_cache.position;
draw_pos.x += theme_cache.h_separation / 2;
draw_pos.y += theme_cache.v_separation / 2;
if (rtl) {
draw_pos.x = size.width - draw_pos.x - items[i].tag_icon->get_width();
draw_pos.x = size.width - draw_pos.x - tag_icon_size.x;
}
draw_texture(items[i].tag_icon, draw_pos + base_ofs);
draw_texture_rect(items[i].tag_icon, Rect2(draw_pos + base_ofs, tag_icon_size));
}
if (!items[i].text.is_empty()) {

View file

@ -120,6 +120,7 @@ private:
Size2 fixed_icon_size;
Size2 max_item_size_cache;
Size2 fixed_tag_icon_size;
int defer_select_single = -1;
bool allow_rmb_select = false;
@ -261,6 +262,8 @@ public:
void set_fixed_icon_size(const Size2i &p_size);
Size2i get_fixed_icon_size() const;
void set_fixed_tag_icon_size(const Size2i &p_size);
void set_allow_rmb_select(bool p_allow);
bool get_allow_rmb_select() const;