Up to date
This page is up to date for Godot 4.3
.
If you still find outdated information, please open an issue.
ThemeDB¶
Inherits: Object
A singleton that provides access to static information about Theme resources used by the engine and by your project.
Description¶
This singleton provides access to static information about Theme resources used by the engine and by your projects. You can fetch the default engine theme, as well as your project configured theme.
ThemeDB also contains fallback values for theme properties.
Properties¶
|
||
|
||
Methods¶
add_user_icon(icon_name: String, icon_source: String) |
|
void |
|
get_user_icon(icon_name: String) |
|
has_user_icon(icon_name: String) |
|
is_default_theme_frozen() const |
|
remove_user_icon(icon_name: String) |
|
void |
Signals¶
border_padding_changed() 🔗
Emits when the default theme padding or border width are changed from ProjectSettings.
Used internally to update the internal margin of the nodes that has a focus StyleBox.
Use ThemeDB.get_default_theme().get_constant("border_padding", "Constants")
to get the changed value.
border_width_changed() 🔗
Emits when the default theme border width is changed from ProjectSettings.
Use ThemeDB.get_default_theme().get_constant("border_width", "Constants")
to get the changed value.
colors_changed() 🔗
Emits when any of the theme colors are changed from the ProjectSettings.
Use ThemeDB.get_default_theme().get_color("base_color", "Colors")
to get the changed value.
Valid options are base_color, accent_color, accent_color2, bg_color, bg_color2, normal_color, pressed_color, hover_color, disabled_color, mono_color, font_color, and font_outline_color.
corner_radius_changed() 🔗
Emits when the default theme corner radius is changed from ProjectSettings.
Use ThemeDB.get_default_theme().get_constant("corner_radius", "Constants")
to get the changed value.
Note: To get the corner radius used for focus style, use ThemeDB.get_default_theme().get_constant("focus_corners", "Constants")
.
fallback_changed() 🔗
Emitted when one of the fallback values had been changed. Use it to refresh the look of controls that may rely on the fallback theme items.
font_changed() 🔗
Emits when the project font is changed from ProjectSettings.
Use ThemeDB.get_default_theme().get_default_font()
to get the new font, if the new font is null, the fallback font is used instead.
font_color_changed() 🔗
Emits when the default theme font color is changed from ProjectSettings.
Use ThemeDB.get_default_theme().get_color("font_color", "Colors")
to get the changed value.
font_outline_color_changed() 🔗
Emits when the default theme font outline color is changed from ProjectSettings.
Use ThemeDB.get_default_theme().get_color("font_outline_color", "Colors")
to get the changed value.
font_outline_size_changed() 🔗
Emits when the default theme font outline size is changed from ProjectSettings.
Use ThemeDB.get_default_theme().get_constant("font_outline_size", "Constants")
to get the changed value.
font_size_changed() 🔗
Emits when the default theme font size is changed from ProjectSettings.
Use ThemeDB.get_default_theme().get_default_font_size()
to get the changed value.
icons_changed() 🔗
Emits when the theme icons scale or colors changes.
margin_changed() 🔗
Emits when the default theme margin is changed from ProjectSettings.
Note: The margin is used for internal separation and not the content margins which uses padding, check padding_changed.
Use ThemeDB.get_default_theme().get_constant("margin", "Constants")
to get the changed value.
padding_changed() 🔗
Emits when the default theme padding is changed from ProjectSettings.
Use ThemeDB.get_default_theme().get_constant("padding", "Constants")
to get the changed value.
scale_changed() 🔗
Emits when the default theme scale is changed from ProjectSettings.
Use ThemeDB.get_default_theme().get_default_base_scale()
to get the changed value.
theme_changed() 🔗
Emits when any property that has a path starting with "gui/theme/" is changed from ProjectSettings.
Property Descriptions¶
float fallback_base_scale = 1.0
🔗
The fallback base scale factor of every Control node and Theme resource. Used when no other value is available to the control.
See also Theme.default_base_scale.
The fallback font of every Control node and Theme resource. Used when no other value is available to the control.
See also Theme.default_font.
The fallback font size of every Control node and Theme resource. Used when no other value is available to the control.
See also Theme.default_font_size.
The fallback icon of every Control node and Theme resource. Used when no other value is available to the control.
The fallback stylebox of every Control node and Theme resource. Used when no other value is available to the control.
Method Descriptions¶
Error add_user_icon(icon_name: String, icon_source: String) 🔗
Add an Icon to the default theme, which will make it change colors and scale when the default theme is changed from ProjectSettings.
icon_source
should be a valid SVG String.
In SVG source "red" and "#0f0" are replaced with font and accent colors when they are changed from ProjectSettings.
Note: Editor plugins need to remove their user icon(s) when unloaded.
func _enter_tree():
var source = FileAccess.get_file_as_string("res://icon.svg")
ThemeDB.add_user_icon("my_icon", source)
func _exit_tree():
ThemeDB.remove_user_icon("my_icon")
void freeze_default_theme() 🔗
Prevents the default theme from emitting changed. This prevents Nodes using the theme from being updated until unfreeze_default_theme is called.
Returns a reference to the default engine Theme. This theme resource is responsible for the out-of-the-box look of Control nodes and can be customized from ProjectSettings.
ImageTexture get_icon(icon_name: String) 🔗
Returns an internal icon from the fallback theme, internal theme icons are the default icons that comes with Blazium.
PackedStringArray get_icon_list() 🔗
Returns a list for all the icon names that are used internally for the default theme.
Returns a reference to the custom project Theme. This theme resources allows to override the default engine theme for every control node in the project.
To set the project theme, see ProjectSettings.gui/theme/custom.
ImageTexture get_user_icon(icon_name: String) 🔗
Returns a user icon from the default theme.
PackedStringArray get_user_icon_list() 🔗
Returns a list for all the user icon names.
bool has_icon(icon_name: String) 🔗
Returns whether the default theme has an internal icon with icon_name
.
bool has_user_icon(icon_name: String) 🔗
Returns whether the default theme has a user icon with icon_name
.
bool is_default_theme_frozen() const 🔗
Returns whether the default theme is frozen.
Error remove_user_icon(icon_name: String) 🔗
Removes a user icon that was previously added to the default theme.
void unfreeze_default_theme() 🔗
Emits Resource.changed if the default theme was already frozen. Also check freeze_default_theme.