From 3fefbb078a4382e833018cc09107f3c455579b6b Mon Sep 17 00:00:00 2001 From: aXu-AP <1621768+aXu-AP@users.noreply.github.com> Date: Wed, 11 Sep 2024 18:57:45 +0300 Subject: [PATCH] Add class icons to script list Draws icons representing the script's or doc page's class on the right side of the script editor. Supports custom icons and icons inherited from parent class. --- editor/plugins/script_editor_plugin.cpp | 57 +++++++++++++++++++++++++ editor/plugins/script_editor_plugin.h | 1 + 2 files changed, 58 insertions(+) diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp index 499696497680..acb660b48c75 100644 --- a/editor/plugins/script_editor_plugin.cpp +++ b/editor/plugins/script_editor_plugin.cpp @@ -3340,6 +3340,62 @@ void ScriptEditor::_script_list_clicked(int p_item, Vector2 p_local_mouse_pos, M } } +void ScriptEditor::_draw_script_list() { + // Draw class icons on right side. + Size2 max_icon_size = EditorNode::get_singleton()->get_class_icon("Node")->get_size(); + + VScrollBar *scroll = script_list->get_v_scroll_bar(); + real_t offset = -scroll->get_value(); + + real_t margin_right = script_list->get_theme_stylebox("panel")->get_margin(SIDE_RIGHT); + margin_right += script_list->get_theme_constant("h_separation") / 2; + if (scroll->is_visible()) { + margin_right += scroll->get_size().x; + } + + for (int i = 0; i < script_list->get_item_count(); i++) { + Control *c = tab_container->get_tab_control(i); + if (!c) { + continue; + } + + Ref icon; + if (Object::cast_to(c)) { + ScriptEditorBase *se = Object::cast_to(c); + Ref