@@ -3340,6 +3340,62 @@ void ScriptEditor::_script_list_clicked(int p_item, Vector2 p_local_mouse_pos, M
3340
3340
}
3341
3341
}
3342
3342
3343
+ void ScriptEditor::_draw_script_list () {
3344
+ // Draw class icons on right side.
3345
+ Size2 max_icon_size = EditorNode::get_singleton ()->get_class_icon (" Node" )->get_size ();
3346
+
3347
+ VScrollBar *scroll = script_list->get_v_scroll_bar ();
3348
+ real_t offset = -scroll->get_value ();
3349
+
3350
+ real_t margin_right = script_list->get_theme_stylebox (" panel" )->get_margin (SIDE_RIGHT);
3351
+ margin_right += script_list->get_theme_constant (" h_separation" ) / 2 ;
3352
+ if (scroll->is_visible ()) {
3353
+ margin_right += scroll->get_size ().x ;
3354
+ }
3355
+
3356
+ for (int i = 0 ; i < script_list->get_item_count (); i++) {
3357
+ Control *c = tab_container->get_tab_control (i);
3358
+ if (!c) {
3359
+ continue ;
3360
+ }
3361
+
3362
+ Ref<Texture2D> icon;
3363
+ if (Object::cast_to<ScriptEditorBase>(c)) {
3364
+ ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(c);
3365
+ Ref<Script> scr = se->get_edited_resource ();
3366
+
3367
+ icon = EditorNode::get_editor_data ().get_script_icon (scr);
3368
+ if (icon.is_null ()) {
3369
+ icon = EditorNode::get_singleton ()->get_class_icon (scr->get_instance_base_type ());
3370
+ }
3371
+ }
3372
+ if (Object::cast_to<EditorHelp>(c)) {
3373
+ EditorHelp *help = Object::cast_to<EditorHelp>(c);
3374
+ icon = EditorNode::get_singleton ()->get_class_icon (help->get_class ());
3375
+ }
3376
+
3377
+ if (icon.is_valid ()) {
3378
+ Size2 icon_size = icon->get_size ();
3379
+ if (icon_size.x > max_icon_size.x ) {
3380
+ icon_size.y = icon_size.y * (max_icon_size.x / icon_size.x );
3381
+ icon_size.x = max_icon_size.x ;
3382
+ }
3383
+ if (icon_size.y > max_icon_size.y ) {
3384
+ icon_size.x = icon_size.x * (max_icon_size.y / icon_size.y );
3385
+ icon_size.y = max_icon_size.y ;
3386
+ }
3387
+ Rect2 item_rect = script_list->get_item_rect (i);
3388
+ real_t margin_top = (item_rect.size .y - icon_size.y ) / 2 ;
3389
+ real_t pos_from_right = max_icon_size.x - (max_icon_size.x - icon_size.x ) / 2 ;
3390
+ Rect2 icon_rect = Rect2 (
3391
+ item_rect.get_end ().x - pos_from_right - margin_right,
3392
+ item_rect.position .y + margin_top + offset,
3393
+ icon_size.x , icon_size.y );
3394
+ script_list->draw_texture_rect (icon, icon_rect);
3395
+ }
3396
+ }
3397
+ }
3398
+
3343
3399
void ScriptEditor::_make_script_list_context_menu () {
3344
3400
context_menu->clear ();
3345
3401
@@ -4111,6 +4167,7 @@ ScriptEditor::ScriptEditor(WindowWrapper *p_wrapper) {
4111
4167
script_split->set_split_offset (70 * EDSCALE);
4112
4168
_sort_list_on_update = true ;
4113
4169
script_list->connect (" item_clicked" , callable_mp (this , &ScriptEditor::_script_list_clicked), CONNECT_DEFERRED);
4170
+ script_list->connect (" draw" , callable_mp (this , &ScriptEditor::_draw_script_list));
4114
4171
script_list->set_allow_rmb_select (true );
4115
4172
SET_DRAG_FORWARDING_GCD (script_list, ScriptEditor);
4116
4173
0 commit comments