diff --git a/doc/classes/Button.xml b/doc/classes/Button.xml index 9fce014125f..ec2447dbbc1 100644 --- a/doc/classes/Button.xml +++ b/doc/classes/Button.xml @@ -48,7 +48,7 @@ When this property is enabled, text that is too large to fit the button is clipped, when disabled the Button will always be wide enough to hold the text. - When enabled, the button's icon will expand/shrink to fit the button's size while keeping its aspect. + When enabled, the button's icon will expand/shrink to fit the button's size while keeping its aspect. See also [theme_item icon_max_width]. Flat buttons don't display decoration. @@ -116,6 +116,9 @@ The horizontal space between [Button]'s icon and text. Negative values will be treated as [code]0[/code] when used. + + The maximum allowed width of the [Button]'s icon. This limit is applied on top of the default size of the icon, or its expanded size if [member expand_icon] is [code]true[/code]. The height is adjusted according to the icon's ratio. + The size of the text outline. [b]Note:[/b] If using a font with [member FontFile.multichannel_signed_distance_field] enabled, its [member FontFile.msdf_pixel_range] must be set to at least [i]twice[/i] the value of [theme_item outline_size] for outline rendering to look correct. Otherwise, the outline may appear to be cut off earlier than intended. diff --git a/doc/classes/PopupMenu.xml b/doc/classes/PopupMenu.xml index 6787b5d20a7..6996061bd8d 100644 --- a/doc/classes/PopupMenu.xml +++ b/doc/classes/PopupMenu.xml @@ -202,6 +202,13 @@ Returns the icon of the item at the given [param index]. + + + + + Returns the maximum allowed width of the icon for the item at the given [param index]. + + @@ -397,6 +404,14 @@ Replaces the [Texture2D] icon of the item at the given [param index]. + + + + + + Sets the maximum allowed width of the icon for the item at the given [param index]. This limit is applied on top of the default size of the icon and on top of [theme_item icon_max_width]. The height is adjusted according to the icon's ratio. + + @@ -573,6 +588,9 @@ The horizontal space between the item's elements. + + The maximum allowed width of the item's icon. This limit is applied on top of the default size of the icon, but before the value set with [method set_item_icon_max_width]. The height is adjusted according to the icon's ratio. + Width of the single indentation level. diff --git a/doc/classes/TabBar.xml b/doc/classes/TabBar.xml index ae6d589339c..7211fc21378 100644 --- a/doc/classes/TabBar.xml +++ b/doc/classes/TabBar.xml @@ -46,14 +46,21 @@ - Returns the [Texture2D] for the right button of the tab at index [param tab_idx] or [code]null[/code] if the button has no [Texture2D]. + Returns the icon for the right button of the tab at index [param tab_idx] or [code]null[/code] if the right button has no icon. - Returns the [Texture2D] for the tab at index [param tab_idx] or [code]null[/code] if the tab has no [Texture2D]. + Returns the icon for the tab at index [param tab_idx] or [code]null[/code] if the tab has no icon. + + + + + + + Returns the maximum allowed width of the icon for the tab at index [param tab_idx]. @@ -158,6 +165,14 @@ Sets an [param icon] for the tab at index [param tab_idx]. + + + + + + Sets the maximum allowed width of the icon for the tab at index [param tab_idx]. This limit is applied on top of the default size of the icon and on top of [theme_item icon_max_width]. The height is adjusted according to the icon's ratio. + + @@ -323,6 +338,9 @@ The horizontal separation between the elements inside tabs. + + The maximum allowed width of the tab's icon. This limit is applied on top of the default size of the icon, but before the value set with [method set_tab_icon_max_width]. The height is adjusted according to the icon's ratio. + The size of the tab text outline. [b]Note:[/b] If using a font with [member FontFile.multichannel_signed_distance_field] enabled, its [member FontFile.msdf_pixel_range] must be set to at least [i]twice[/i] the value of [theme_item outline_size] for outline rendering to look correct. Otherwise, the outline may appear to be cut off earlier than intended. diff --git a/doc/classes/TabContainer.xml b/doc/classes/TabContainer.xml index c34336353f0..b0dcb932dc4 100644 --- a/doc/classes/TabContainer.xml +++ b/doc/classes/TabContainer.xml @@ -209,6 +209,9 @@ Font color of the other, unselected tabs. + + The maximum allowed width of the tab's icon. This limit is applied on top of the default size of the icon, but before the value set with [method TabBar.set_tab_icon_max_width]. The height is adjusted according to the icon's ratio. + Space between tab's name and its icon. diff --git a/doc/classes/Tree.xml b/doc/classes/Tree.xml index 95778f86c45..d09f61b8c87 100644 --- a/doc/classes/Tree.xml +++ b/doc/classes/Tree.xml @@ -518,6 +518,9 @@ The horizontal space between item cells. This is also used as the margin at the start of an item when folding is disabled. + + The maximum allowed width of the icon in item's cells. This limit is applied on top of the default size of the icon, but before the value set with [method TreeItem.set_icon_max_width]. The height is adjusted according to the icon's ratio. + The horizontal margin at the start of an item. This is used when folding is enabled for the item. diff --git a/doc/classes/TreeItem.xml b/doc/classes/TreeItem.xml index 3ce434e0699..49b4622aed0 100644 --- a/doc/classes/TreeItem.xml +++ b/doc/classes/TreeItem.xml @@ -183,7 +183,7 @@ - Returns the column's icon's maximum width. + Returns the maximum allowed width of the icon in the given [param column]. @@ -545,7 +545,7 @@ - Sets the given column's icon's maximum width. + Sets the maximum allowed width of the icon in the given [param column]. This limit is applied on top of the default size of the icon and on top of [theme_item Tree.icon_max_width]. The height is adjusted according to the icon's ratio. diff --git a/editor/create_dialog.cpp b/editor/create_dialog.cpp index ee47ee57296..aaf106a1c75 100644 --- a/editor/create_dialog.cpp +++ b/editor/create_dialog.cpp @@ -462,6 +462,11 @@ void CreateDialog::_notification(int p_what) { } break; case NOTIFICATION_THEME_CHANGED: { + const int icon_width = get_theme_constant(SNAME("class_icon_size"), SNAME("Editor")); + search_options->add_theme_constant_override("icon_max_width", icon_width); + favorites->add_theme_constant_override("icon_max_width", icon_width); + recent->set_fixed_icon_size(Size2(icon_width, icon_width)); + _update_theme(); } break; } diff --git a/editor/editor_data.cpp b/editor/editor_data.cpp index d2af7879d27..2d095d2dc77 100644 --- a/editor/editor_data.cpp +++ b/editor/editor_data.cpp @@ -1030,13 +1030,11 @@ void EditorData::script_class_load_icon_paths() { } } -Ref EditorData::_load_script_icon(const String &p_path) const { - if (p_path.length()) { - Ref img = memnew(Image); - Error err = ImageLoader::load_image(p_path, img); - if (err == OK) { - img->resize(16 * EDSCALE, 16 * EDSCALE, Image::INTERPOLATE_LANCZOS); - return ImageTexture::create_from_image(img); +Ref EditorData::_load_script_icon(const String &p_path) const { + if (!p_path.is_empty() && ResourceLoader::exists(p_path)) { + Ref icon = ResourceLoader::load(p_path); + if (icon.is_valid()) { + return icon; } } return nullptr; @@ -1051,9 +1049,9 @@ Ref EditorData::get_script_icon(const Ref