Class Theme
- Inheritance
-
Theme
Remarks
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 gui/theme/custom to set up a project-scope theme that will be available to every control in your project.
Use 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.
See Also
Properties
default_base_scale
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 fallback_base_scale).
Use has_default_base_scale to check if this value is valid.
var default_base_scale : float = 0.0
Property Value
Remarks
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 fallback_font).
Use has_default_font to check if this value is valid.
var default_font : Font
Property Value
Remarks
default_font_size
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 fallback_font_size).
Values below 1
are invalid and can be used to unset the property. Use has_default_font_size to check if this value is valid.
var default_font_size : int = -1
Property Value
Remarks
Methods
add_type(StringName)
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 add_type(StringName theme_type)
Parameters
theme_type
StringName
clear
Removes all the theme properties defined on the theme resource.
void clear
clear_color(StringName, StringName)
Removes the Color property defined by name
and theme_type
, if it exists.
Fails if it doesn't exist. Use Theme.has_color to check for existence.
void clear_color(StringName name, StringName theme_type)
Parameters
name
StringNametheme_type
StringName
clear_constant(StringName, StringName)
Removes the constant property defined by name
and theme_type
, if it exists.
Fails if it doesn't exist. Use Theme.has_constant to check for existence.
void clear_constant(StringName name, StringName theme_type)
Parameters
name
StringNametheme_type
StringName
clear_font(StringName, StringName)
Removes the Font property defined by name
and theme_type
, if it exists.
Fails if it doesn't exist. Use Theme.has_font to check for existence.
void clear_font(StringName name, StringName theme_type)
Parameters
name
StringNametheme_type
StringName
clear_font_size(StringName, StringName)
Removes the font size property defined by name
and theme_type
, if it exists.
Fails if it doesn't exist. Use Theme.has_font_size to check for existence.
void clear_font_size(StringName name, StringName theme_type)
Parameters
name
StringNametheme_type
StringName
clear_icon(StringName, StringName)
Removes the icon property defined by name
and theme_type
, if it exists.
Fails if it doesn't exist. Use Theme.has_icon to check for existence.
void clear_icon(StringName name, StringName theme_type)
Parameters
name
StringNametheme_type
StringName
clear_stylebox(StringName, StringName)
Removes the StyleBox property defined by name
and theme_type
, if it exists.
Fails if it doesn't exist. Use Theme.has_stylebox to check for existence.
void clear_stylebox(StringName name, StringName theme_type)
Parameters
name
StringNametheme_type
StringName
clear_theme_item(int, StringName, StringName)
Removes the theme property of data_type
defined by name
and theme_type
, if it exists.
Fails if it doesn't exist. Use Theme.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_theme_item(int data_type, StringName name, StringName theme_type)
Parameters
data_type
intname
StringNametheme_type
StringName
clear_type_variation(StringName)
Unmarks theme_type
as being a variation of another theme type. See Theme.set_type_variation.
void clear_type_variation(StringName theme_type)
Parameters
theme_type
StringName
get_color(StringName, StringName)
Qualifiers: 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 Theme.has_color to check for existence.
Color get_color(StringName name, StringName theme_type)
Parameters
name
StringNametheme_type
StringName
get_color_list(String)
Qualifiers: 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_list(String theme_type)
Parameters
theme_type
String
get_color_type_list
Qualifiers: const
Returns a list of all unique theme type names for Color properties. Use get_type_list to get a list of all unique theme types.
PackedStringArray get_color_type_list
get_constant(StringName, StringName)
Qualifiers: const
Returns the constant property defined by name
and theme_type
, if it exists.
Returns 0
if the property doesn't exist. Use Theme.has_constant to check for existence.
int get_constant(StringName name, StringName theme_type)
Parameters
name
StringNametheme_type
StringName
get_constant_list(String)
Qualifiers: const
Returns a list of names for constant properties defined with theme_type
. Use get_constant_type_list to get a list of possible theme type names.
PackedStringArray get_constant_list(String theme_type)
Parameters
theme_type
String
get_constant_type_list
Qualifiers: const
Returns a list of all unique theme type names for constant properties. Use get_type_list to get a list of all unique theme types.
PackedStringArray get_constant_type_list
get_font(StringName, StringName)
Qualifiers: const
Returns the Font property defined by name
and theme_type
, if it exists.
Returns the default theme font if the property doesn't exist and the default theme font is set up (see default_font). Use Theme.has_font to check for existence of the property and has_default_font to check for existence of the default theme font.
Returns the engine fallback font value, if neither exist (see fallback_font).
Font get_font(StringName name, StringName theme_type)
Parameters
name
StringNametheme_type
StringName
get_font_list(String)
Qualifiers: const
Returns a list of names for Font properties defined with theme_type
. Use get_font_type_list to get a list of possible theme type names.
PackedStringArray get_font_list(String theme_type)
Parameters
theme_type
String
get_font_size(StringName, StringName)
Qualifiers: const
Returns the font size property defined by name
and theme_type
, if it exists.
Returns the default theme font size if the property doesn't exist and the default theme font size is set up (see default_font_size). Use Theme.has_font_size to check for existence of the property and has_default_font_size to check for existence of the default theme font.
Returns the engine fallback font size value, if neither exist (see fallback_font_size).
int get_font_size(StringName name, StringName theme_type)
Parameters
name
StringNametheme_type
StringName
get_font_size_list(String)
Qualifiers: const
Returns a list of names for font size properties defined with theme_type
. Use get_font_size_type_list to get a list of possible theme type names.
PackedStringArray get_font_size_list(String theme_type)
Parameters
theme_type
String
get_font_size_type_list
Qualifiers: const
Returns a list of all unique theme type names for font size properties. Use get_type_list to get a list of all unique theme types.
PackedStringArray get_font_size_type_list
get_font_type_list
Qualifiers: const
Returns a list of all unique theme type names for Font properties. Use get_type_list to get a list of all unique theme types.
PackedStringArray get_font_type_list
get_icon(StringName, StringName)
Qualifiers: const
Returns the icon property defined by name
and theme_type
, if it exists.
Returns the engine fallback icon value if the property doesn't exist (see fallback_icon). Use Theme.has_icon to check for existence.
Texture2D get_icon(StringName name, StringName theme_type)
Parameters
name
StringNametheme_type
StringName
get_icon_list(String)
Qualifiers: const
Returns a list of names for icon properties defined with theme_type
. Use get_icon_type_list to get a list of possible theme type names.
PackedStringArray get_icon_list(String theme_type)
Parameters
theme_type
String
get_icon_type_list
Qualifiers: const
Returns a list of all unique theme type names for icon properties. Use get_type_list to get a list of all unique theme types.
PackedStringArray get_icon_type_list
get_stylebox(StringName, StringName)
Qualifiers: const
Returns the StyleBox property defined by name
and theme_type
, if it exists.
Returns the engine fallback stylebox value if the property doesn't exist (see fallback_stylebox). Use Theme.has_stylebox to check for existence.
StyleBox get_stylebox(StringName name, StringName theme_type)
Parameters
name
StringNametheme_type
StringName
get_stylebox_list(String)
Qualifiers: const
Returns a list of names for StyleBox properties defined with theme_type
. Use get_stylebox_type_list to get a list of possible theme type names.
PackedStringArray get_stylebox_list(String theme_type)
Parameters
theme_type
String
get_stylebox_type_list
Qualifiers: const
Returns a list of all unique theme type names for StyleBox properties. Use get_type_list to get a list of all unique theme types.
PackedStringArray get_stylebox_type_list
get_theme_item(int, StringName, StringName)
Qualifiers: const
Returns the theme property of data_type
defined by name
and theme_type
, if it exists.
Returns the engine fallback value if the property doesn't exist (see ThemeDB). Use Theme.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.
Variant get_theme_item(int data_type, StringName name, StringName theme_type)
Parameters
data_type
intname
StringNametheme_type
StringName
get_theme_item_list(int, String)
Qualifiers: const
Returns a list of names for properties of data_type
defined with theme_type
. Use Theme.get_theme_item_type_list to get a list of possible theme type names.
Note: This method is analogous to calling the corresponding data type specific method, but can be used for more generalized logic.
PackedStringArray get_theme_item_list(int data_type, String theme_type)
Parameters
get_theme_item_type_list(int)
Qualifiers: const
Returns a list of all unique theme type names for data_type
properties. Use get_type_list to get a list of all unique theme types.
Note: This method is analogous to calling the corresponding data type specific method, but can be used for more generalized logic.
PackedStringArray get_theme_item_type_list(int data_type)
Parameters
data_type
int
get_type_list
Qualifiers: const
Returns a list of all unique theme type names. Use the appropriate get_*_type_list
method to get a list of unique theme types for a single data type.
PackedStringArray get_type_list
get_type_variation_base(StringName)
Qualifiers: const
Returns the name of the base theme type if theme_type
is a valid variation type. Returns an empty string otherwise.
StringName get_type_variation_base(StringName theme_type)
Parameters
theme_type
StringName
get_type_variation_list(StringName)
Qualifiers: const
Returns a list of all type variations for the given base_type
.
PackedStringArray get_type_variation_list(StringName base_type)
Parameters
base_type
StringName
has_color(StringName, StringName)
Qualifiers: const
Returns true
if the Color property defined by name
and theme_type
exists.
Returns false
if it doesn't exist. Use Theme.set_color to define it.
bool has_color(StringName name, StringName theme_type)
Parameters
name
StringNametheme_type
StringName
has_constant(StringName, StringName)
Qualifiers: const
Returns true
if the constant property defined by name
and theme_type
exists.
Returns false
if it doesn't exist. Use Theme.set_constant to define it.
bool has_constant(StringName name, StringName theme_type)
Parameters
name
StringNametheme_type
StringName
has_default_base_scale
Qualifiers: const
Returns true
if default_base_scale has a valid value.
Returns false
if it doesn't. The value must be greater than 0.0
to be considered valid.
bool has_default_base_scale
has_default_font
bool has_default_font
has_default_font_size
Qualifiers: const
Returns true
if default_font_size has a valid value.
Returns false
if it doesn't. The value must be greater than 0
to be considered valid.
bool has_default_font_size
has_font(StringName, StringName)
Qualifiers: const
Returns true
if the Font property defined by name
and theme_type
exists, or if the default theme font is set up (see has_default_font).
Returns false
if neither exist. Use Theme.set_font to define the property.
bool has_font(StringName name, StringName theme_type)
Parameters
name
StringNametheme_type
StringName
has_font_size(StringName, StringName)
Qualifiers: const
Returns true
if the font size property defined by name
and theme_type
exists, or if the default theme font size is set up (see has_default_font_size).
Returns false
if neither exist. Use Theme.set_font_size to define the property.
bool has_font_size(StringName name, StringName theme_type)
Parameters
name
StringNametheme_type
StringName
has_icon(StringName, StringName)
Qualifiers: const
Returns true
if the icon property defined by name
and theme_type
exists.
Returns false
if it doesn't exist. Use Theme.set_icon to define it.
bool has_icon(StringName name, StringName theme_type)
Parameters
name
StringNametheme_type
StringName
has_stylebox(StringName, StringName)
Qualifiers: const
Returns true
if the StyleBox property defined by name
and theme_type
exists.
Returns false
if it doesn't exist. Use Theme.set_stylebox to define it.
bool has_stylebox(StringName name, StringName theme_type)
Parameters
name
StringNametheme_type
StringName
has_theme_item(int, StringName, StringName)
Qualifiers: const
Returns true
if the theme property of data_type
defined by name
and theme_type
exists.
Returns false
if it doesn't exist. Use Theme.set_theme_item to define it.
Note: This method is analogous to calling the corresponding data type specific method, but can be used for more generalized logic.
bool has_theme_item(int data_type, StringName name, StringName theme_type)
Parameters
data_type
intname
StringNametheme_type
StringName
is_type_variation(StringName, StringName)
Qualifiers: const
Returns true
if theme_type
is marked as a variation of base_type
.
bool is_type_variation(StringName theme_type, StringName base_type)
Parameters
theme_type
StringNamebase_type
StringName
merge_with(Theme)
Adds missing and overrides existing definitions with values from the other
theme resource.
Note: This modifies the current theme. If you want to merge two themes together without modifying either one, create a new empty theme and merge the other two into it one after another.
void merge_with(Theme other)
Parameters
other
Theme
remove_type(StringName)
Removes the theme type, gracefully discarding defined theme items. If the type is a variation, this information is also erased. If the type is a base for type variations, those variations lose their base.
void remove_type(StringName theme_type)
Parameters
theme_type
StringName
rename_color(StringName, StringName, StringName)
Renames the Color property defined by old_name
and theme_type
to name
, if it exists.
Fails if it doesn't exist, or if a similar property with the new name already exists. Use Theme.has_color to check for existence, and Theme.clear_color to remove the existing property.
void rename_color(StringName old_name, StringName name, StringName theme_type)
Parameters
old_name
StringNamename
StringNametheme_type
StringName
rename_constant(StringName, StringName, StringName)
Renames the constant property defined by old_name
and theme_type
to name
, if it exists.
Fails if it doesn't exist, or if a similar property with the new name already exists. Use Theme.has_constant to check for existence, and Theme.clear_constant to remove the existing property.
void rename_constant(StringName old_name, StringName name, StringName theme_type)
Parameters
old_name
StringNamename
StringNametheme_type
StringName
rename_font(StringName, StringName, StringName)
Renames the Font property defined by old_name
and theme_type
to name
, if it exists.
Fails if it doesn't exist, or if a similar property with the new name already exists. Use Theme.has_font to check for existence, and Theme.clear_font to remove the existing property.
void rename_font(StringName old_name, StringName name, StringName theme_type)
Parameters
old_name
StringNamename
StringNametheme_type
StringName
rename_font_size(StringName, StringName, StringName)
Renames the font size property defined by old_name
and theme_type
to name
, if it exists.
Fails if it doesn't exist, or if a similar property with the new name already exists. Use Theme.has_font_size to check for existence, and Theme.clear_font_size to remove the existing property.
void rename_font_size(StringName old_name, StringName name, StringName theme_type)
Parameters
old_name
StringNamename
StringNametheme_type
StringName
rename_icon(StringName, StringName, StringName)
Renames the icon property defined by old_name
and theme_type
to name
, if it exists.
Fails if it doesn't exist, or if a similar property with the new name already exists. Use Theme.has_icon to check for existence, and Theme.clear_icon to remove the existing property.
void rename_icon(StringName old_name, StringName name, StringName theme_type)
Parameters
old_name
StringNamename
StringNametheme_type
StringName
rename_stylebox(StringName, StringName, StringName)
Renames the StyleBox property defined by old_name
and theme_type
to name
, if it exists.
Fails if it doesn't exist, or if a similar property with the new name already exists. Use Theme.has_stylebox to check for existence, and Theme.clear_stylebox to remove the existing property.
void rename_stylebox(StringName old_name, StringName name, StringName theme_type)
Parameters
old_name
StringNamename
StringNametheme_type
StringName
rename_theme_item(int, StringName, StringName, StringName)
Renames the theme property of data_type
defined by old_name
and theme_type
to name
, if it exists.
Fails if it doesn't exist, or if a similar property with the new name already exists. Use Theme.has_theme_item to check for existence, and Theme.clear_theme_item to remove the existing property.
Note: This method is analogous to calling the corresponding data type specific method, but can be used for more generalized logic.
void rename_theme_item(int data_type, StringName old_name, StringName name, StringName theme_type)
Parameters
data_type
intold_name
StringNamename
StringNametheme_type
StringName
set_color(StringName, StringName, Color)
Creates or changes the value of the Color property defined by name
and theme_type
. Use Theme.clear_color to remove the property.
void set_color(StringName name, StringName theme_type, Color color)
Parameters
name
StringNametheme_type
StringNamecolor
Color
set_constant(StringName, StringName, int)
Creates or changes the value of the constant property defined by name
and theme_type
. Use Theme.clear_constant to remove the property.
void set_constant(StringName name, StringName theme_type, int constant)
Parameters
name
StringNametheme_type
StringNameconstant
int
set_font(StringName, StringName, Font)
Creates or changes the value of the Font property defined by name
and theme_type
. Use Theme.clear_font to remove the property.
void set_font(StringName name, StringName theme_type, Font font)
Parameters
name
StringNametheme_type
StringNamefont
Font
set_font_size(StringName, StringName, int)
Creates or changes the value of the font size property defined by name
and theme_type
. Use Theme.clear_font_size to remove the property.
void set_font_size(StringName name, StringName theme_type, int font_size)
Parameters
name
StringNametheme_type
StringNamefont_size
int
set_icon(StringName, StringName, Texture2D)
Creates or changes the value of the icon property defined by name
and theme_type
. Use Theme.clear_icon to remove the property.
void set_icon(StringName name, StringName theme_type, Texture2D texture)
Parameters
name
StringNametheme_type
StringNametexture
Texture2D
set_stylebox(StringName, StringName, StyleBox)
Creates or changes the value of the StyleBox property defined by name
and theme_type
. Use Theme.clear_stylebox to remove the property.
void set_stylebox(StringName name, StringName theme_type, StyleBox texture)
Parameters
name
StringNametheme_type
StringNametexture
StyleBox
set_theme_item(int, StringName, StringName, Variant)
Creates or changes the value of the theme property of data_type
defined by name
and theme_type
. Use Theme.clear_theme_item to remove the property.
Fails if the value
type is not accepted by data_type
.
Note: This method is analogous to calling the corresponding data type specific method, but can be used for more generalized logic.
void set_theme_item(int data_type, StringName name, StringName theme_type, Variant value)
Parameters
data_type
intname
StringNametheme_type
StringNamevalue
Variant
set_type_variation(StringName, StringName)
Marks theme_type
as a variation of base_type
.
This adds theme_type
as a suggested option for theme_type_variation on a Control that is of the base_type
class.
Variations can also be nested, i.e. base_type
can be another variation. If a chain of variations ends with a base_type
matching the class of the Control, the whole chain is going to be suggested as options.
Note: Suggestions only show up if this theme resource is set as the project default theme. See gui/theme/custom.
void set_type_variation(StringName theme_type, StringName base_type)
Parameters
theme_type
StringNamebase_type
StringName