diff --git a/editor/script_create_dialog.cpp b/editor/script_create_dialog.cpp index 1da8fa49b43c..3583c1699a98 100644 --- a/editor/script_create_dialog.cpp +++ b/editor/script_create_dialog.cpp @@ -113,10 +113,22 @@ void ScriptCreateDialog::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { + const int icon_size = get_theme_constant(SNAME("class_icon_size"), EditorStringName(Editor)); + + EditorData &ed = EditorNode::get_editor_data(); + for (int i = 0; i < ScriptServer::get_language_count(); i++) { - Ref language_icon = get_editor_theme_icon(ScriptServer::get_language(i)->get_type()); + // Check if the extension has an icon first + String script_type = ScriptServer::get_language(i)->get_type(); + Ref language_icon = ed.extension_class_get_icon(script_type); if (language_icon.is_valid()) { language_menu->set_item_icon(i, language_icon); + language_menu->set_item_icon_max_width(i, icon_size); + } else { + language_icon = get_editor_theme_icon(script_type); + if (language_icon.is_valid()) { + language_menu->set_item_icon(i, language_icon); + } } } @@ -881,6 +893,7 @@ ScriptCreateDialog::ScriptCreateDialog() { language_menu = memnew(OptionButton); language_menu->set_custom_minimum_size(Size2(350, 0) * EDSCALE); + language_menu->set_expand_icon(true); language_menu->set_h_size_flags(Control::SIZE_EXPAND_FILL); gc->add_child(memnew(Label(TTR("Language:")))); gc->add_child(language_menu); diff --git a/scene/gui/option_button.cpp b/scene/gui/option_button.cpp index 6613f25b4c13..b567e021d8d4 100644 --- a/scene/gui/option_button.cpp +++ b/scene/gui/option_button.cpp @@ -269,6 +269,12 @@ void OptionButton::set_item_icon(int p_idx, const Ref &p_icon) { _queue_update_size_cache(); } +void OptionButton::set_item_icon_max_width(int p_idx, int p_width) { + popup->set_item_icon_max_width(p_idx, p_width); + + _queue_update_size_cache(); +} + void OptionButton::set_item_id(int p_idx, int p_id) { popup->set_item_id(p_idx, p_id); } @@ -550,6 +556,7 @@ void OptionButton::_bind_methods() { ClassDB::bind_method(D_METHOD("add_icon_item", "texture", "label", "id"), &OptionButton::add_icon_item, DEFVAL(-1)); ClassDB::bind_method(D_METHOD("set_item_text", "idx", "text"), &OptionButton::set_item_text); ClassDB::bind_method(D_METHOD("set_item_icon", "idx", "texture"), &OptionButton::set_item_icon); + ClassDB::bind_method(D_METHOD("set_item_icon_max_width", "idx", "texture"), &OptionButton::set_item_icon_max_width); ClassDB::bind_method(D_METHOD("set_item_disabled", "idx", "disabled"), &OptionButton::set_item_disabled); ClassDB::bind_method(D_METHOD("set_item_id", "idx", "id"), &OptionButton::set_item_id); ClassDB::bind_method(D_METHOD("set_item_metadata", "idx", "metadata"), &OptionButton::set_item_metadata); diff --git a/scene/gui/option_button.h b/scene/gui/option_button.h index 9c15b295a959..6b96fe80b354 100644 --- a/scene/gui/option_button.h +++ b/scene/gui/option_button.h @@ -95,6 +95,7 @@ class OptionButton : public Button { void set_item_text(int p_idx, const String &p_text); void set_item_icon(int p_idx, const Ref &p_icon); + void set_item_icon_max_width(int p_idx, int p_width); void set_item_id(int p_idx, int p_id); void set_item_metadata(int p_idx, const Variant &p_metadata); void set_item_disabled(int p_idx, bool p_disabled);