Theme
A resource used for styling/skinning Control
s and Window
s.
class Theme
A resource used for styling/skinning Control
and Window
nodes. While individual controls can be styled using their local theme overrides (see addThemeColorOverride(name:color:)
), theme resources allow you to store and apply the same settings across all controls sharing the same type (e.g. style all 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 ProjectSettings/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.
Superclasses
class Resource
Base class for serializable objects.
Citizens in SwiftGodot
Conformances
protocol CustomStringConvertible
A type with a customized textual representation.
protocol Equatable
A type that can be compared for value equality.
protocol Hashable
A type that can be hashed into a
Hasher
to produce an integer hash value.protocol Identifiable<ID>
A class of types whose instances hold the value of an entity with stable identity.
protocol VariantRepresentable
Types that conform to VariantRepresentable can be stored directly in
Variant
with no conversion. These include all of the Variant types from Godot (for exampleGString
,Rect
,Plane
), Godot objects (those that subclass SwiftGodot.Object) as well as the built-in Swift types UInt8, Int64 and Double.protocol VariantStorable
Types that conform to VariantStorable can be stored in a Variant and can be extracted back out of a Variant.
Types
Type members
Instance members
var defaultBaseScale: Double
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 (seefallbackBaseScale
).var defaultFont: 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
fallbackFont
).var defaultFontSize: Int32
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
fallbackFontSize
).func addType(themeType: StringName
) Adds an empty theme type for every valid data type.
func clear(
) Removes all the theme properties defined on the theme resource.
func clearColor(name: StringName, themeType: StringName
) Removes the
Color
property defined byname
andthemeType
, if it exists.func clearConstant(name: StringName, themeType: StringName
) Removes the constant property defined by
name
andthemeType
, if it exists.func clearFont(name: StringName, themeType: StringName
) Removes the
Font
property defined byname
andthemeType
, if it exists.func clearFontSize(name: StringName, themeType: StringName
) Removes the font size property defined by
name
andthemeType
, if it exists.func clearIcon(name: StringName, themeType: StringName
) Removes the icon property defined by
name
andthemeType
, if it exists.func clearStylebox(name: StringName, themeType: StringName
) Removes the
StyleBox
property defined byname
andthemeType
, if it exists.func clearThemeItem(dataType: Theme.DataType, name: StringName, themeType: StringName
) Removes the theme property of
dataType
defined byname
andthemeType
, if it exists.func clearTypeVariation(themeType: StringName
) Unmarks
themeType
as being a variation of another theme type. SeesetTypeVariation(themeType:baseType:)
.func getColor(name: StringName, themeType: StringName
) -> Color Returns the
Color
property defined byname
andthemeType
, if it exists.func getColorList(themeType: String
) -> PackedStringArray Returns a list of names for
Color
properties defined withthemeType
. UsegetColorTypeList
to get a list of possible theme type names.func getColorTypeList(
) -> PackedStringArray Returns a list of all unique theme type names for
Color
properties. UsegetTypeList
to get a list of all unique theme types.func getConstant(name: StringName, themeType: StringName
) -> Int32 Returns the constant property defined by
name
andthemeType
, if it exists.func getConstantList(themeType: String
) -> PackedStringArray Returns a list of names for constant properties defined with
themeType
. UsegetConstantTypeList
to get a list of possible theme type names.func getConstantTypeList(
) -> PackedStringArray Returns a list of all unique theme type names for constant properties. Use
getTypeList
to get a list of all unique theme types.func getFont(name: StringName, themeType: StringName
) -> Font? Returns the
Font
property defined byname
andthemeType
, if it exists.func getFontList(themeType: String
) -> PackedStringArray Returns a list of names for
Font
properties defined withthemeType
. UsegetFontTypeList
to get a list of possible theme type names.func getFontSize(name: StringName, themeType: StringName
) -> Int32 Returns the font size property defined by
name
andthemeType
, if it exists.func getFontSizeList(themeType: String
) -> PackedStringArray Returns a list of names for font size properties defined with
themeType
. UsegetFontSizeTypeList
to get a list of possible theme type names.func getFontSizeTypeList(
) -> PackedStringArray Returns a list of all unique theme type names for font size properties. Use
getTypeList
to get a list of all unique theme types.func getFontTypeList(
) -> PackedStringArray Returns a list of all unique theme type names for
Font
properties. UsegetTypeList
to get a list of all unique theme types.func getIcon(name: StringName, themeType: StringName
) -> Texture2D? Returns the icon property defined by
name
andthemeType
, if it exists.func getIconList(themeType: String
) -> PackedStringArray Returns a list of names for icon properties defined with
themeType
. UsegetIconTypeList
to get a list of possible theme type names.func getIconTypeList(
) -> PackedStringArray Returns a list of all unique theme type names for icon properties. Use
getTypeList
to get a list of all unique theme types.func getStylebox(name: StringName, themeType: StringName
) -> StyleBox? Returns the
StyleBox
property defined byname
andthemeType
, if it exists.func getStyleboxList(themeType: String
) -> PackedStringArray Returns a list of names for
StyleBox
properties defined withthemeType
. UsegetStyleboxTypeList
to get a list of possible theme type names.func getStyleboxTypeList(
) -> PackedStringArray Returns a list of all unique theme type names for
StyleBox
properties. UsegetTypeList
to get a list of all unique theme types.func getThemeItem(dataType: Theme.DataType, name: StringName, themeType: StringName
) -> Variant Returns the theme property of
dataType
defined byname
andthemeType
, if it exists.func getThemeItemList(dataType: Theme.DataType, themeType: String
) -> PackedStringArray Returns a list of names for properties of
dataType
defined withthemeType
. UsegetThemeItemTypeList(dataType:)
to get a list of possible theme type names.func getThemeItemTypeList(dataType: Theme.DataType
) -> PackedStringArray Returns a list of all unique theme type names for
dataType
properties. UsegetTypeList
to get a list of all unique theme types.func getTypeList(
) -> PackedStringArray 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 getTypeVariationBase(themeType: StringName
) -> StringName Returns the name of the base theme type if
themeType
is a valid variation type. Returns an empty string otherwise.func getTypeVariationList(baseType: StringName
) -> PackedStringArray Returns a list of all type variations for the given
baseType
.func hasColor(name: StringName, themeType: StringName
) -> Bool Returns
true
if theColor
property defined byname
andthemeType
exists.func hasConstant(name: StringName, themeType: StringName
) -> Bool Returns
true
if the constant property defined byname
andthemeType
exists.func hasDefaultBaseScale(
) -> Bool Returns
true
ifdefaultBaseScale
has a valid value.func hasDefaultFont(
) -> Bool Returns
true
ifdefaultFont
has a valid value.func hasDefaultFontSize(
) -> Bool Returns
true
ifdefaultFontSize
has a valid value.func hasFont(name: StringName, themeType: StringName
) -> Bool Returns
true
if theFont
property defined byname
andthemeType
exists, or if the default theme font is set up (seehasDefaultFont
).func hasFontSize(name: StringName, themeType: StringName
) -> Bool Returns
true
if the font size property defined byname
andthemeType
exists, or if the default theme font size is set up (seehasDefaultFontSize
).func hasIcon(name: StringName, themeType: StringName
) -> Bool Returns
true
if the icon property defined byname
andthemeType
exists.func hasStylebox(name: StringName, themeType: StringName
) -> Bool Returns
true
if theStyleBox
property defined byname
andthemeType
exists.func hasThemeItem(dataType: Theme.DataType, name: StringName, themeType: StringName
) -> Bool Returns
true
if the theme property ofdataType
defined byname
andthemeType
exists.func isTypeVariation(themeType: StringName, baseType: StringName
) -> Bool Returns
true
ifthemeType
is marked as a variation ofbaseType
.func mergeWith(other: Theme?
) Adds missing and overrides existing definitions with values from the
other
theme resource.func removeType(themeType: 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.
func renameColor(oldName: StringName, name: StringName, themeType: StringName
) Renames the
Color
property defined byoldName
andthemeType
toname
, if it exists.func renameConstant(oldName: StringName, name: StringName, themeType: StringName
) Renames the constant property defined by
oldName
andthemeType
toname
, if it exists.func renameFont(oldName: StringName, name: StringName, themeType: StringName
) Renames the
Font
property defined byoldName
andthemeType
toname
, if it exists.func renameFontSize(oldName: StringName, name: StringName, themeType: StringName
) Renames the font size property defined by
oldName
andthemeType
toname
, if it exists.func renameIcon(oldName: StringName, name: StringName, themeType: StringName
) Renames the icon property defined by
oldName
andthemeType
toname
, if it exists.func renameStylebox(oldName: StringName, name: StringName, themeType: StringName
) Renames the
StyleBox
property defined byoldName
andthemeType
toname
, if it exists.func renameThemeItem(dataType: Theme.DataType, oldName: StringName, name: StringName, themeType: StringName
) Renames the theme property of
dataType
defined byoldName
andthemeType
toname
, if it exists.func setColor(name: StringName, themeType: StringName, color: Color
) Creates or changes the value of the
Color
property defined byname
andthemeType
. UseclearColor(name:themeType:)
to remove the property.func setConstant(name: StringName, themeType: StringName, constant: Int32
) Creates or changes the value of the constant property defined by
name
andthemeType
. UseclearConstant(name:themeType:)
to remove the property.func setFont(name: StringName, themeType: StringName, font: Font?
) Creates or changes the value of the
Font
property defined byname
andthemeType
. UseclearFont(name:themeType:)
to remove the property.func setFontSize(name: StringName, themeType: StringName, fontSize: Int32
) Creates or changes the value of the font size property defined by
name
andthemeType
. UseclearFontSize(name:themeType:)
to remove the property.func setIcon(name: StringName, themeType: StringName, texture: Texture2D?
) Creates or changes the value of the icon property defined by
name
andthemeType
. UseclearIcon(name:themeType:)
to remove the property.func setStylebox(name: StringName, themeType: StringName, texture: StyleBox?
) Creates or changes the value of the
StyleBox
property defined byname
andthemeType
. UseclearStylebox(name:themeType:)
to remove the property.func setThemeItem(dataType: Theme.DataType, name: StringName, themeType: StringName, value: Variant
) Creates or changes the value of the theme property of
dataType
defined byname
andthemeType
. UseclearThemeItem(dataType:name:themeType:)
to remove the property.func setTypeVariation(themeType: StringName, baseType: StringName
) Marks
themeType
as a variation ofbaseType
.