Table of Contents

Struct StyleProp<T>

Namespace
MLEM.Ui.Style
Assembly
MLEM.Ui.dll

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> : IEquatable<StyleProp<T>>

Type Parameters

T

The type of style setting that this property stores

Implements
Inherited Members
Extension Methods

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 T

The 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

Equals(StyleProp<T>)

Indicates whether the current object is equal to another object of the same type.

[Obsolete("StyleProp equality is ambiguous as it is not clear whether priority is taken into account. Compare Values instead.")]
public bool Equals(StyleProp<T> other)

Parameters

other StyleProp<T>

An object to compare with this object.

Returns

bool

true if the current object is equal to the other parameter; otherwise, false.

Equals(object)

Indicates whether this instance and a specified object are equal.

[Obsolete("StyleProp equality is ambiguous as it is not clear whether priority is taken into account. Compare Values instead.")]
public override bool Equals(object obj)

Parameters

obj object

The object to compare with the current instance.

Returns

bool

true if obj and this instance are the same type and represent the same value; otherwise, false.

GetHashCode()

Returns the hash code for this instance.

[Obsolete("StyleProp equality is ambiguous as it is not clear whether priority is taken into account. Compare Values instead.")]
public override int GetHashCode()

Returns

int

A 32-bit signed integer that is the hash code for this instance.

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 T

The 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 T

The style to apply

priority byte

The 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

operator ==(StyleProp<T>, StyleProp<T>)

Compares the two style properties and returns whether they are equal using Equals(StyleProp<T>).

[Obsolete("StyleProp equality is ambiguous as it is not clear whether priority is taken into account. Compare Values instead.")]
public static bool operator ==(StyleProp<T> left, StyleProp<T> right)

Parameters

left StyleProp<T>

The left style property.

right StyleProp<T>

The right style property.

Returns

bool

Whether the two style properties are equal.

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 T

The property to convert

Returns

StyleProp<T>

A style property with the given style value

operator !=(StyleProp<T>, StyleProp<T>)

Compares the two style properties and returns whether they are not equal using Equals(StyleProp<T>).

[Obsolete("StyleProp equality is ambiguous as it is not clear whether priority is taken into account. Compare Values instead.")]
public static bool operator !=(StyleProp<T> left, StyleProp<T> right)

Parameters

left StyleProp<T>

The left style property.

right StyleProp<T>

The right style property.

Returns

bool

Whether the two style properties are not equal.