Theme

package
v0.0.0-...-0d6c339 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 16, 2025 License: MIT Imports: 27 Imported by: 0

Documentation

Overview

A resource used for styling/skinning graphics.gd/classdb/Control and graphics.gd/classdb/Window nodes. While individual controls can be styled using their local theme overrides (see graphics.gd/classdb/Control.Instance.AddThemeColorOverride), theme resources allow you to store and apply the same settings across all controls sharing the same type (e.g. style all [graphics.gd/classdb/Button]s 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 graphics.gd/classdb/ProjectSettings "gui/theme/custom" to set up a project-scope theme that will be available to every control in your project.

Use graphics.gd/classdb/Control.Instance.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.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Advanced

type Advanced = class

Advanced exposes a 1:1 low-level instance of the class, undocumented, for those who know what they are doing.

type Any

type Any interface {
	gd.IsClass
	AsTheme() Instance
}

type DataType

type DataType int //gd:Theme.DataType
const (
	// Theme's [Color.RGBA] item type.
	DataTypeColor DataType = 0
	// Theme's constant item type.
	DataTypeConstant DataType = 1
	// Theme's [graphics.gd/classdb/Font] item type.
	DataTypeFont DataType = 2
	// Theme's font size item type.
	DataTypeFontSize DataType = 3
	// Theme's icon [graphics.gd/classdb/Texture2D] item type.
	DataTypeIcon DataType = 4
	// Theme's [graphics.gd/classdb/StyleBox] item type.
	DataTypeStylebox DataType = 5
	// Maximum value for the DataType enum.
	DataTypeMax DataType = 6
)

type Extension

type Extension[T gdclass.Interface] struct{ gdclass.Extension[T, Instance] }

Extension can be embedded in a new struct to create an extension of this class. T should be the type that is embedding this Extension

func (*Extension[T]) AsObject

func (self *Extension[T]) AsObject() [1]gd.Object

func (*Extension[T]) AsRefCounted

func (self *Extension[T]) AsRefCounted() [1]gd.RefCounted

func (*Extension[T]) AsResource

func (self *Extension[T]) AsResource() Resource.Instance

func (*Extension[T]) AsTheme

func (self *Extension[T]) AsTheme() Instance

type ID

type ID Object.ID

ID is a typed object ID (reference) to an instance of this class, use it to store references to objects with unknown lifetimes, as an ID will not panic on use if the underlying object has been destroyed.

func (ID) Instance

func (id ID) Instance() (Instance, bool)

type Instance

type Instance [1]gdclass.Theme

Instance of the class with convieniently typed arguments and results.

var Nil Instance

Nil is a nil/null instance of the class. Equivalent to the zero value.

func New

func New() Instance

func (Instance) AddType

func (self Instance) AddType(theme_type string)

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.

func (Instance) AsObject

func (self Instance) AsObject() [1]gd.Object

func (Instance) AsRefCounted

func (self Instance) AsRefCounted() [1]gd.RefCounted

func (Instance) AsResource

func (self Instance) AsResource() Resource.Instance

func (Instance) AsTheme

func (self Instance) AsTheme() Instance

func (Instance) Clear

func (self Instance) Clear()

Removes all the theme properties defined on the theme resource.

func (Instance) ClearColor

func (self Instance) ClearColor(name string, theme_type string)

Removes the [Color.RGBA] property defined by 'name' and 'theme_type', if it exists.

Fails if it doesn't exist. Use Instance.HasColor to check for existence.

func (Instance) ClearConstant

func (self Instance) ClearConstant(name string, theme_type string)

Removes the constant property defined by 'name' and 'theme_type', if it exists.

Fails if it doesn't exist. Use Instance.HasConstant to check for existence.

func (Instance) ClearFont

func (self Instance) ClearFont(name string, theme_type string)

Removes the graphics.gd/classdb/Font property defined by 'name' and 'theme_type', if it exists.

Fails if it doesn't exist. Use Instance.HasFont to check for existence.

func (Instance) ClearFontSize

func (self Instance) ClearFontSize(name string, theme_type string)

Removes the font size property defined by 'name' and 'theme_type', if it exists.

Fails if it doesn't exist. Use Instance.HasFontSize to check for existence.

func (Instance) ClearIcon

func (self Instance) ClearIcon(name string, theme_type string)

Removes the icon property defined by 'name' and 'theme_type', if it exists.

Fails if it doesn't exist. Use Instance.HasIcon to check for existence.

func (Instance) ClearStylebox

func (self Instance) ClearStylebox(name string, theme_type string)

Removes the graphics.gd/classdb/StyleBox property defined by 'name' and 'theme_type', if it exists.

Fails if it doesn't exist. Use Instance.HasStylebox to check for existence.

func (Instance) ClearThemeItem

func (self Instance) ClearThemeItem(data_type DataType, name string, theme_type string)

Removes the theme property of 'data_type' defined by 'name' and 'theme_type', if it exists.

Fails if it doesn't exist. Use Instance.HasThemeItem 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.

func (Instance) ClearTypeVariation

func (self Instance) ClearTypeVariation(theme_type string)

Unmarks 'theme_type' as being a variation of another theme type. See Instance.SetTypeVariation.

func (Instance) DefaultBaseScale

func (self Instance) DefaultBaseScale() Float.X

func (Instance) DefaultFont

func (self Instance) DefaultFont() Font.Instance

func (Instance) DefaultFontSize

func (self Instance) DefaultFontSize() int

func (Instance) GetColor

func (self Instance) GetColor(name string, theme_type string) Color.RGBA

Returns the [Color.RGBA] property defined by 'name' and 'theme_type', if it exists.

Returns the default color value if the property doesn't exist. Use Instance.HasColor to check for existence.

func (Instance) GetColorList

func (self Instance) GetColorList(theme_type string) []string

Returns a list of names for [Color.RGBA] properties defined with 'theme_type'. Use Instance.GetColorTypeList to get a list of possible theme type names.

func (Instance) GetColorTypeList

func (self Instance) GetColorTypeList() []string

Returns a list of all unique theme type names for [Color.RGBA] properties. Use Instance.GetTypeList to get a list of all unique theme types.

func (Instance) GetConstant

func (self Instance) GetConstant(name string, theme_type string) int

Returns the constant property defined by 'name' and 'theme_type', if it exists.

Returns 0 if the property doesn't exist. Use Instance.HasConstant to check for existence.

func (Instance) GetConstantList

func (self Instance) GetConstantList(theme_type string) []string

Returns a list of names for constant properties defined with 'theme_type'. Use Instance.GetConstantTypeList to get a list of possible theme type names.

func (Instance) GetConstantTypeList

func (self Instance) GetConstantTypeList() []string

Returns a list of all unique theme type names for constant properties. Use Instance.GetTypeList to get a list of all unique theme types.

func (Instance) GetFont

func (self Instance) GetFont(name string, theme_type string) Font.Instance

Returns the graphics.gd/classdb/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 Instance.DefaultFont). Use Instance.HasFont to check for existence of the property and Instance.HasDefaultFont to check for existence of the default theme font.

Returns the engine fallback font value, if neither exist (see graphics.gd/classdb/ThemeDB.FallbackFont).

func (Instance) GetFontList

func (self Instance) GetFontList(theme_type string) []string

Returns a list of names for graphics.gd/classdb/Font properties defined with 'theme_type'. Use Instance.GetFontTypeList to get a list of possible theme type names.

func (Instance) GetFontSize

func (self Instance) GetFontSize(name string, theme_type string) int

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 Instance.DefaultFontSize). Use Instance.HasFontSize to check for existence of the property and Instance.HasDefaultFontSize to check for existence of the default theme font.

Returns the engine fallback font size value, if neither exist (see graphics.gd/classdb/ThemeDB.FallbackFontSize).

func (Instance) GetFontSizeList

func (self Instance) GetFontSizeList(theme_type string) []string

Returns a list of names for font size properties defined with 'theme_type'. Use Instance.GetFontSizeTypeList to get a list of possible theme type names.

func (Instance) GetFontSizeTypeList

func (self Instance) GetFontSizeTypeList() []string

Returns a list of all unique theme type names for font size properties. Use Instance.GetTypeList to get a list of all unique theme types.

func (Instance) GetFontTypeList

func (self Instance) GetFontTypeList() []string

Returns a list of all unique theme type names for graphics.gd/classdb/Font properties. Use Instance.GetTypeList to get a list of all unique theme types.

func (Instance) GetIcon

func (self Instance) GetIcon(name string, theme_type string) Texture2D.Instance

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 graphics.gd/classdb/ThemeDB.FallbackIcon). Use Instance.HasIcon to check for existence.

func (Instance) GetIconList

func (self Instance) GetIconList(theme_type string) []string

Returns a list of names for icon properties defined with 'theme_type'. Use Instance.GetIconTypeList to get a list of possible theme type names.

func (Instance) GetIconTypeList

func (self Instance) GetIconTypeList() []string

Returns a list of all unique theme type names for icon properties. Use Instance.GetTypeList to get a list of all unique theme types.

func (Instance) GetStylebox

func (self Instance) GetStylebox(name string, theme_type string) StyleBox.Instance

Returns the graphics.gd/classdb/StyleBox property defined by 'name' and 'theme_type', if it exists.

Returns the engine fallback stylebox value if the property doesn't exist (see graphics.gd/classdb/ThemeDB.FallbackStylebox). Use Instance.HasStylebox to check for existence.

func (Instance) GetStyleboxList

func (self Instance) GetStyleboxList(theme_type string) []string

Returns a list of names for graphics.gd/classdb/StyleBox properties defined with 'theme_type'. Use Instance.GetStyleboxTypeList to get a list of possible theme type names.

func (Instance) GetStyleboxTypeList

func (self Instance) GetStyleboxTypeList() []string

Returns a list of all unique theme type names for graphics.gd/classdb/StyleBox properties. Use Instance.GetTypeList to get a list of all unique theme types.

func (Instance) GetThemeItem

func (self Instance) GetThemeItem(data_type DataType, name string, theme_type string) any

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 graphics.gd/classdb/ThemeDB). Use Instance.HasThemeItem 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.

func (Instance) GetThemeItemList

func (self Instance) GetThemeItemList(data_type DataType, theme_type string) []string

Returns a list of names for properties of 'data_type' defined with 'theme_type'. Use Instance.GetThemeItemTypeList 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.

func (Instance) GetThemeItemTypeList

func (self Instance) GetThemeItemTypeList(data_type DataType) []string

Returns a list of all unique theme type names for 'data_type' properties. Use Instance.GetTypeList 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.

func (Instance) GetTypeList

func (self Instance) GetTypeList() []string

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.

func (Instance) GetTypeVariationBase

func (self Instance) GetTypeVariationBase(theme_type string) string

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

func (Instance) GetTypeVariationList

func (self Instance) GetTypeVariationList(base_type string) []string

Returns a list of all type variations for the given 'base_type'.

func (Instance) HasColor

func (self Instance) HasColor(name string, theme_type string) bool

Returns true if the [Color.RGBA] property defined by 'name' and 'theme_type' exists.

Returns false if it doesn't exist. Use Instance.SetColor to define it.

func (Instance) HasConstant

func (self Instance) HasConstant(name string, theme_type string) bool

Returns true if the constant property defined by 'name' and 'theme_type' exists.

Returns false if it doesn't exist. Use Instance.SetConstant to define it.

func (Instance) HasDefaultBaseScale

func (self Instance) HasDefaultBaseScale() bool

Returns true if Instance.DefaultBaseScale has a valid value.

Returns false if it doesn't. The value must be greater than 0.0 to be considered valid.

func (Instance) HasDefaultFont

func (self Instance) HasDefaultFont() bool

Returns true if Instance.DefaultFont has a valid value.

Returns false if it doesn't.

func (Instance) HasDefaultFontSize

func (self Instance) HasDefaultFontSize() bool

Returns true if Instance.DefaultFontSize has a valid value.

Returns false if it doesn't. The value must be greater than 0 to be considered valid.

func (Instance) HasFont

func (self Instance) HasFont(name string, theme_type string) bool

Returns true if the graphics.gd/classdb/Font property defined by 'name' and 'theme_type' exists, or if the default theme font is set up (see Instance.HasDefaultFont).

Returns false if neither exist. Use Instance.SetFont to define the property.

func (Instance) HasFontSize

func (self Instance) HasFontSize(name string, theme_type string) bool

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 Instance.HasDefaultFontSize).

Returns false if neither exist. Use Instance.SetFontSize to define the property.

func (Instance) HasIcon

func (self Instance) HasIcon(name string, theme_type string) bool

Returns true if the icon property defined by 'name' and 'theme_type' exists.

Returns false if it doesn't exist. Use Instance.SetIcon to define it.

func (Instance) HasStylebox

func (self Instance) HasStylebox(name string, theme_type string) bool

Returns true if the graphics.gd/classdb/StyleBox property defined by 'name' and 'theme_type' exists.

Returns false if it doesn't exist. Use Instance.SetStylebox to define it.

func (Instance) HasThemeItem

func (self Instance) HasThemeItem(data_type DataType, name string, theme_type string) bool

Returns true if the theme property of 'data_type' defined by 'name' and 'theme_type' exists.

Returns false if it doesn't exist. Use Instance.SetThemeItem to define it.

Note: This method is analogous to calling the corresponding data type specific method, but can be used for more generalized logic.

func (Instance) ID

func (self Instance) ID() ID

func (Instance) IsTypeVariation

func (self Instance) IsTypeVariation(theme_type string, base_type string) bool

Returns true if 'theme_type' is marked as a variation of 'base_type'.

func (Instance) MergeWith

func (self Instance) MergeWith(other Instance)

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.

func (Instance) RemoveType

func (self Instance) RemoveType(theme_type string)

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.

func (Instance) RenameColor

func (self Instance) RenameColor(old_name string, name string, theme_type string)

Renames the [Color.RGBA] 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 Instance.HasColor to check for existence, and Instance.ClearColor to remove the existing property.

func (Instance) RenameConstant

func (self Instance) RenameConstant(old_name string, name string, theme_type string)

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 Instance.HasConstant to check for existence, and Instance.ClearConstant to remove the existing property.

func (Instance) RenameFont

func (self Instance) RenameFont(old_name string, name string, theme_type string)

Renames the graphics.gd/classdb/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 Instance.HasFont to check for existence, and Instance.ClearFont to remove the existing property.

func (Instance) RenameFontSize

func (self Instance) RenameFontSize(old_name string, name string, theme_type string)

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 Instance.HasFontSize to check for existence, and Instance.ClearFontSize to remove the existing property.

func (Instance) RenameIcon

func (self Instance) RenameIcon(old_name string, name string, theme_type string)

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 Instance.HasIcon to check for existence, and Instance.ClearIcon to remove the existing property.

func (Instance) RenameStylebox

func (self Instance) RenameStylebox(old_name string, name string, theme_type string)

Renames the graphics.gd/classdb/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 Instance.HasStylebox to check for existence, and Instance.ClearStylebox to remove the existing property.

func (Instance) RenameThemeItem

func (self Instance) RenameThemeItem(data_type DataType, old_name string, name string, theme_type string)

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 Instance.HasThemeItem to check for existence, and Instance.ClearThemeItem 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.

func (Instance) RenameType

func (self Instance) RenameType(old_theme_type string, theme_type string)

Renames the theme type 'old_theme_type' to 'theme_type', if the old type exists and the new one doesn't exist.

Note: Renaming a theme type to an empty name or a variation to a type associated with a built-in class removes type variation connections in a way that cannot be undone by reversing the rename alone.

func (Instance) SetColor

func (self Instance) SetColor(name string, theme_type string, color Color.RGBA)

Creates or changes the value of the [Color.RGBA] property defined by 'name' and 'theme_type'. Use Instance.ClearColor to remove the property.

func (Instance) SetConstant

func (self Instance) SetConstant(name string, theme_type string, constant int)

Creates or changes the value of the constant property defined by 'name' and 'theme_type'. Use Instance.ClearConstant to remove the property.

func (Instance) SetDefaultBaseScale

func (self Instance) SetDefaultBaseScale(value Float.X)

func (Instance) SetDefaultFont

func (self Instance) SetDefaultFont(value Font.Instance)

func (Instance) SetDefaultFontSize

func (self Instance) SetDefaultFontSize(value int)

func (Instance) SetFont

func (self Instance) SetFont(name string, theme_type string, font Font.Instance)

Creates or changes the value of the graphics.gd/classdb/Font property defined by 'name' and 'theme_type'. Use Instance.ClearFont to remove the property.

func (Instance) SetFontSize

func (self Instance) SetFontSize(name string, theme_type string, font_size int)

Creates or changes the value of the font size property defined by 'name' and 'theme_type'. Use Instance.ClearFontSize to remove the property.

func (Instance) SetIcon

func (self Instance) SetIcon(name string, theme_type string, texture Texture2D.Instance)

Creates or changes the value of the icon property defined by 'name' and 'theme_type'. Use Instance.ClearIcon to remove the property.

func (*Instance) SetObject

func (self *Instance) SetObject(obj [1]gd.Object) bool

func (Instance) SetStylebox

func (self Instance) SetStylebox(name string, theme_type string, texture StyleBox.Instance)

Creates or changes the value of the graphics.gd/classdb/StyleBox property defined by 'name' and 'theme_type'. Use Instance.ClearStylebox to remove the property.

func (Instance) SetThemeItem

func (self Instance) SetThemeItem(data_type DataType, name string, theme_type string, value any)

Creates or changes the value of the theme property of 'data_type' defined by 'name' and 'theme_type'. Use Instance.ClearThemeItem 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.

func (Instance) SetTypeVariation

func (self Instance) SetTypeVariation(theme_type string, base_type string)

Marks 'theme_type' as a variation of 'base_type'.

This adds 'theme_type' as a suggested option for graphics.gd/classdb/Control.Instance.ThemeTypeVariation on a graphics.gd/classdb/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 graphics.gd/classdb/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 graphics.gd/classdb/ProjectSettings "gui/theme/custom".

func (Instance) Virtual

func (self Instance) Virtual(name string) reflect.Value

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL