Struct StyleProp<T>
A struct used by Element to store style properties.
This is a helper struct that allows default style settings from UiStyle to be overridden by custom user settings easily.
Note that T
implicitly converts to StyleProp{T}
and vice versa.
public readonly struct StyleProp<T>
Type Parameters
T
The type of style setting that this property stores
- Inherited Members
Constructors
StyleProp(T)
Creates a new style property with the given custom style and a priority of MaxValue. To create a style property with a lower priority, use OrStyle(T, byte) on an existing priority, or use None.
public StyleProp(T value)
Parameters
value
TThe custom style to apply
Fields
Value
The currently applied style
public readonly T Value
Field Value
- T
Properties
None
The empty style property, with no Value and a priority of 0.
public static StyleProp<T> None { get; }
Property Value
- StyleProp<T>
Methods
HasValue()
Returns whether this style property has a value assigned to it using OrStyle(StyleProp<T>) or StyleProp(T).
public bool HasValue()
Returns
- bool
Whether this style property has a value
OrDefault(T)
Returns the current style value or, if HasValue() is false, the given default value.
public T OrDefault(T def)
Parameters
def
TThe default to return if this style property has no value
Returns
- T
The current value, or the default
OrStyle(StyleProp<T>)
Chooses and returns the style property with the higher priority, out of this value and other
.
This allows this property to be overridden by custom style settings using StyleProp(T) or a higher priority.
public StyleProp<T> OrStyle(StyleProp<T> other)
Parameters
other
StyleProp<T>The style property to compare with
Returns
- StyleProp<T>
The style property with the higher priority
OrStyle(T, byte)
Creates a copy of this style property and sets its value and marks it as being set by a UiStyle if it doesn't have a custom value yet.
This allows this property to be overridden by custom style settings using StyleProp(T) or a higher priority
.
public StyleProp<T> OrStyle(T value, byte priority = 0)
Parameters
value
TThe style to apply
priority
byteThe priority that the style value has. Higher priority style values will override lower priority style values.
Returns
- StyleProp<T>
The style with the higher priority
ToString()
Returns the fully qualified type name of this instance.
public override string ToString()
Returns
- string
The fully qualified type name.
Operators
implicit operator T(StyleProp<T>)
Implicitly converts a style property to its value.
public static implicit operator T(StyleProp<T> prop)
Parameters
prop
StyleProp<T>The property to convert
Returns
- T
The style that the style property holds
implicit operator StyleProp<T>(T)
Implicitly converts a style to a style property.
public static implicit operator StyleProp<T>(T prop)
Parameters
prop
TThe property to convert
Returns
- StyleProp<T>
A style property with the given style value