Up to date
This page is up to date for Godot 4.0
.
If you still find outdated information, please open an issue.
Theme¶
Inherits: Resource < RefCounted < Object
A resource used for styling/skinning Controls and Windows.
Description¶
A resource used for styling/skinning Control and Window nodes. While individual controls can be styled using their local theme overrides (see Control.add_theme_color_override), theme resources allow you to store and apply the same settings across all controls sharing the same type (e.g. style all Buttons the same). One theme resource can be used for the entire project, but you can also set a separate theme resource to a branch of control nodes. A theme resource assigned to a control applies to the control itself, as well as all of its direct and indirect children (as long as a chain of controls is uninterrupted).
Use ProjectSettings.gui/theme/custom to set up a project-scope theme that will be available to every control in your project.
Use Control.theme of any control node to set up a theme that will be available to that control and all of its direct and indirect children.
Tutorials¶
Properties¶
|
||
|
Methods¶
Enumerations¶
enum DataType:
DataType DATA_TYPE_COLOR = 0
Theme's Color item type.
DataType DATA_TYPE_CONSTANT = 1
Theme's constant item type.
DataType DATA_TYPE_FONT = 2
Theme's Font item type.
DataType DATA_TYPE_FONT_SIZE = 3
Theme's font size item type.
DataType DATA_TYPE_ICON = 4
Theme's icon Texture2D item type.
DataType DATA_TYPE_STYLEBOX = 5
Theme's StyleBox item type.
DataType DATA_TYPE_MAX = 6
Maximum value for the DataType enum.
Property Descriptions¶
float default_base_scale = 0.0
The default base scale factor of this theme resource. Used by some controls to scale their visual properties based on the global scale factor. If this value is set to 0.0
, the global scale factor is used (see ThemeDB.fallback_base_scale).
Use has_default_base_scale to check if this value is valid.
Font default_font
The default font of this theme resource. Used as the default value when trying to fetch a font resource that doesn't exist in this theme or is in invalid state. If the default font is also missing or invalid, the engine fallback value is used (see ThemeDB.fallback_font).
Use has_default_font to check if this value is valid.
int default_font_size = -1
The default font size of this theme resource. Used as the default value when trying to fetch a font size value that doesn't exist in this theme or is in invalid state. If the default font size is also missing or invalid, the engine fallback value is used (see ThemeDB.fallback_font_size).
Values below 0
are invalid and can be used to unset the property. Use has_default_font_size to check if this value is valid.
Method Descriptions¶
void add_type ( StringName theme_type )
Adds an empty theme type for every valid data type.
Note: Empty types are not saved with the theme. This method only exists to perform in-memory changes to the resource. Use available set_*
methods to add theme items.
void clear ( )
Removes all the theme properties defined on the theme resource.
void clear_color ( StringName name, StringName theme_type )
Removes the Color property defined by name
and theme_type
, if it exists.
Fails if it doesn't exist. Use has_color to check for existence.
void clear_constant ( StringName name, StringName theme_type )
Removes the constant property defined by name
and theme_type
, if it exists.
Fails if it doesn't exist. Use has_constant to check for existence.
void clear_font ( StringName name, StringName theme_type )
Removes the Font property defined by name
and theme_type
, if it exists.
Fails if it doesn't exist. Use has_font to check for existence.
void clear_font_size ( StringName name, StringName theme_type )
Removes the font size property defined by name
and theme_type
, if it exists.
Fails if it doesn't exist. Use has_font_size to check for existence.
void clear_icon ( StringName name, StringName theme_type )
Removes the icon property defined by name
and theme_type
, if it exists.
Fails if it doesn't exist. Use has_icon to check for existence.
void clear_stylebox ( StringName name, StringName theme_type )
Removes the StyleBox property defined by name
and theme_type
, if it exists.
Fails if it doesn't exist. Use has_stylebox to check for existence.
void clear_theme_item ( DataType data_type, StringName name, StringName theme_type )
Removes the theme property of data_type
defined by name
and theme_type
, if it exists.
Fails if it doesn't exist. Use has_theme_item to check for existence.
Note: This method is analogous to calling the corresponding data type specific method, but can be used for more generalized logic.
void clear_type_variation ( StringName theme_type )
Unmarks theme_type
as being a variation of another theme type. See set_type_variation.
Color get_color ( StringName name, StringName theme_type ) const
Returns the Color property defined by name
and theme_type
, if it exists.
Returns the default color value if the property doesn't exist. Use has_color to check for existence.
PackedStringArray get_color_list ( String theme_type ) const
Returns a list of names for Color properties defined with theme_type
. Use get_color_type_list to get a list of possible theme type names.
PackedStringArray get_color_type_list ( ) const