Theme

Inherits: Resource < RefCounted < Object

Theme for controls.

Description

A theme for skinning controls. Controls can be skinned individually, but for complex applications, it's more practical to just create a global theme that defines everything. This theme can be applied to any Control; the Control and its children will automatically use it.

Theme resources can alternatively be loaded by writing them in a .theme file, see the documentation for more information.

Tutorials

Methods

void

clear ( )

void

clear_color ( StringName name, StringName theme_type )

void

clear_constant ( StringName name, StringName theme_type )

void

clear_font ( StringName name, StringName theme_type )

void

clear_font_size ( StringName name, StringName theme_type )

void

clear_icon ( StringName name, StringName theme_type )

void

clear_stylebox ( StringName name, StringName theme_type )

void

clear_theme_item ( DataType data_type, StringName name, StringName theme_type )

void

clear_type_variation ( StringName theme_type )

Color

get_color ( StringName name, StringName theme_type ) const

PackedStringArray

get_color_list ( String theme_type ) const

PackedStringArray

get_color_type_list ( ) const

int

get_constant ( StringName name, StringName theme_type ) const

PackedStringArray

get_constant_list ( String theme_type ) const

PackedStringArray

get_constant_type_list ( ) const

Font

get_font ( StringName name, StringName theme_type ) const

PackedStringArray

get_font_list ( String theme_type ) const

int

get_font_size ( StringName name, StringName theme_type ) const

PackedStringArray

get_font_size_list ( String theme_type ) const

PackedStringArray

get_font_size_type_list ( ) const

PackedStringArray

get_font_type_list ( ) const

Texture2D

get_icon ( StringName name, StringName theme_type ) const

PackedStringArray

get_icon_list ( String theme_type ) const

PackedStringArray

get_icon_type_list ( ) const

StyleBox

get_stylebox ( StringName name, StringName theme_type ) const

PackedStringArray

get_stylebox_list ( String theme_type ) const

PackedStringArray

get_stylebox_type_list ( ) const

Variant

get_theme_item ( DataType data_type, StringName name, StringName theme_type ) const

PackedStringArray

get_theme_item_list ( DataType data_type, String theme_type ) const

PackedStringArray

get_theme_item_type_list ( DataType data_type ) const

PackedStringArray

get_type_list ( ) const

StringName

get_type_variation_base ( StringName theme_type ) const

PackedStringArray

get_type_variation_list ( StringName base_type ) const

bool

has_color ( StringName name, StringName theme_type ) const

bool

has_constant ( StringName name, StringName theme_type ) const

bool

has_default_base_scale ( ) const

bool

has_default_font ( ) const

bool

has_default_font_size ( ) const

bool

has_font ( StringName name, StringName theme_type ) const

bool

has_font_size ( StringName name, StringName theme_type ) const

bool

has_icon ( StringName name, StringName theme_type ) const

bool

has_stylebox ( StringName name, StringName theme_type ) const

bool

has_theme_item ( DataType data_type, StringName name, StringName theme_type ) const

bool

is_type_variation ( StringName theme_type, StringName base_type ) const

void

merge_with ( Theme other )

void

rename_color ( StringName old_name, StringName name, StringName theme_type )

void

rename_constant ( StringName old_name, StringName name, StringName theme_type )

void

rename_font ( StringName old_name, StringName name, StringName theme_type )

void

rename_font_size ( StringName old_name, StringName name, StringName theme_type )

void

rename_icon ( StringName old_name, StringName name, StringName theme_type )

void

rename_stylebox ( StringName old_name, StringName name, StringName theme_type )

void

rename_theme_item ( DataType data_type, StringName old_name, StringName name, StringName theme_type )

void

set_color ( StringName name, StringName theme_type, Color color )

void

set_constant ( StringName name, StringName theme_type, int constant )

void

set_font ( StringName name, StringName theme_type, Font font )

void

set_font_size ( StringName name, StringName theme_type, int font_size )

void

set_icon ( StringName name, StringName theme_type, Texture2D texture )

void

set_stylebox ( StringName name, StringName theme_type, StyleBox texture )

void

set_theme_item ( DataType data_type, StringName name, StringName theme_type, Variant value )

void

set_type_variation ( StringName theme_type, StringName base_type )

Enumerations

enum DataType:

  • DATA_TYPE_COLOR = 0 --- Theme's Color item type.

  • DATA_TYPE_CONSTANT = 1 --- Theme's constant item type.

  • DATA_TYPE_FONT = 2 --- Theme's Font item type.

  • DATA_TYPE_FONT_SIZE = 3 --- Theme's font size item type.

  • DATA_TYPE_ICON = 4 --- Theme's icon Texture2D item type.

  • DATA_TYPE_STYLEBOX = 5 --- Theme's StyleBox item type.

  • DATA_TYPE_MAX = 6 --- Maximum value for the DataType enum.

Property Descriptions

  • float default_base_scale

Default

0.0

Setter

set_default_base_scale(value)

Getter

get_default_base_scale()

The default base scale factor of this Theme resource. Used by some controls to scale their visual properties based on a global scale factor. If this value is set to 0.0, the global scale factor is used.

Use has_default_base_scale to check if this value is valid.


Setter

set_default_font(value)

Getter

get_default_font()

The default font of this Theme resource. Used as a fallback value for font items defined in this theme, but having invalid values. If this value is also invalid, the global default value is used.

Use has_default_font to check if this value is valid.


  • int default_font_size

Default

-1

Setter

set_default_font_size(value)

Getter

get_default_font_size()

The default font size of this Theme resource. Used as a fallback value for font size items defined in this theme, but having invalid values. If this value is set to -1, the global default value is used.

Use has_default_font_size to check if this value is valid.

Method Descriptions

  • void clear ( )

Clears all values on the theme.


Clears the Color at name if the theme has theme_type.


Clears the constant at name if the theme has theme_type.


Clears the Font at name if the theme has theme_type.


Clears the font size name if the theme has theme_type.


Clears the icon at name if the theme has theme_type.


Clears StyleBox at name if the theme has theme_type.


Clears the theme item of data_type at name if the theme has theme_type.


  • void clear_type_variation ( StringName theme_type )

Unmarks theme_type as being a variation of any other type.


Returns the Color at name if the theme has theme_type.


Returns all the Colors as a PackedStringArray filled with each Color's name, for use in get_color, if the theme has theme_type.


Returns all the Color types as a PackedStringArray filled with unique type names, for use in get_color and/or get_color_list.


Returns the constant at name if the theme has theme_type.


Returns all the constants as a PackedStringArray filled with each constant's name, for use in get_constant, if the theme has theme_type.


Returns all the constant types as a PackedStringArray filled with unique type names, for use in get_constant and/or get_constant_list.


Returns the Font at name if the theme has theme_type.


Returns all the Fonts as a PackedStringArray filled with each Font's name, for use in get_font, if the theme has theme_type.


Returns the font size at name if the theme has theme_type.


Returns all the font sizes as a PackedStringArray filled with each font size name, for use in get_font_size, if the theme has theme_type.


Returns all the font size types as a PackedStringArray filled with unique type names, for use in get_font_size and/or get_font_size_list.


Returns all the Font types as a PackedStringArray filled with unique type names, for use in get_font and/or get_font_list.


Returns the icon Texture2D at name if the theme has theme_type.


Returns all the icons as a PackedStringArray filled with each Texture2D's name, for use in get_icon, if the theme has theme_type.


Returns all the icon types as a PackedStringArray filled with unique type names, for use in get_icon and/or get_icon_list.


Returns the StyleBox at name if the theme has theme_type.

Valid names may be found using get_stylebox_list. Valid theme_types may be found using get_stylebox_type_list.


Returns all the StyleBoxs as a PackedStringArray filled with each StyleBox's name, for use in get_stylebox, if the theme has theme_type.

Valid theme_types may be found using get_stylebox_type_list.


Returns all the StyleBox types as a PackedStringArray filled with unique type names, for use in get_stylebox and/or get_stylebox_list.


Returns the theme item of data_type at name if the theme has theme_type.

Valid names may be found using get_theme_item_list or a data type specific method. Valid theme_types may be found using get_theme_item_type_list or a data type specific method.


Returns all the theme items of data_type as a PackedStringArray filled with each theme items's name, for use in get_theme_item or a data type specific method, if the theme has theme_type.

Valid theme_types may be found using get_theme_item_type_list or a data type specific method.


Returns all the theme items of data_type types as a PackedStringArray filled with unique type names, for use in get_theme_item, get_theme_item_list or data type specific methods.


Returns all the theme types as a PackedStringArray filled with unique type names, for use in other get_* functions of this theme.


Returns the base theme type if theme_type is a valid variation type. Returns an empty string otherwise.


Returns a list of all variation for the given base_type.


Returns true if Color with name is in theme_type.

Returns false if the theme does not have theme_type.


Returns true if constant with name is in theme_type.

Returns false if the theme does not have theme_type.


  • bool has_default_base_scale ( ) const

Returns true if this theme has a valid default_base_scale value.


  • bool has_default_font ( ) const

Returns true if this theme has a valid default_font value.


  • bool has_default_font_size ( ) const

Returns true if this theme has a valid default_font_size value.


Returns true if Font with name is in theme_type.

Returns false if the theme does not have theme_type.


Returns true if font size with name is in theme_type.

Returns false if the theme does not have theme_type.


Returns true if icon Texture2D with name is in theme_type.

Returns false if the theme does not have theme_type.


Returns true if StyleBox with name is in theme_type.

Returns false if the theme does not have theme_type.


Returns true if a theme item of data_type with name is in theme_type.

Returns false if the theme does not have theme_type.


Returns true if theme_type is marked as a variation of base_type in this theme.


  • void merge_with ( Theme other )

Adds missing and overrides existing definitions with values from the other Theme.

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.


Renames the Color at old_name to name if the theme has theme_type. If name is already taken, this method fails.


Renames the constant at old_name to name if the theme has theme_type. If name is already taken, this method fails.


Renames the Font at old_name to name if the theme has theme_type. If name is already taken, this method fails.


Renames the font size old_name to name if the theme has theme_type. If name is already taken, this method fails.


Renames the icon at old_name to name if the theme has theme_type. If name is already taken, this method fails.


Renames StyleBox at old_name to name if the theme has theme_type. If name is already taken, this method fails.


Renames the theme item of data_type at old_name to name if the theme has theme_type. If name is already taken, this method fails.


Sets the theme's Color to color at name in theme_type.

Creates theme_type if the theme does not have it.


Sets the theme's constant to constant at name in theme_type.

Creates theme_type if the theme does not have it.


Sets the theme's Font to font at name in theme_type.

Creates theme_type if the theme does not have it.


Sets the theme's font size to font_size at name in theme_type.

Creates theme_type if the theme does not have it.


Sets the theme's icon Texture2D to texture at name in theme_type.

Creates theme_type if the theme does not have it.


Sets theme's StyleBox to stylebox at name in theme_type.

Creates theme_type if the theme does not have it.


Sets the theme item of data_type to value at name in theme_type.

Does nothing if the value type does not match data_type.

Creates theme_type if the theme does not have it.


Marks theme_type as being a variation of base_type.

This adds theme_type as a suggested option for Control.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 a class of a Control, the whole chain is going to be suggested as options.

Note: Suggestions only show up if this Theme is set as the project default theme. See ProjectSettings.gui/theme/custom.