using System.Collections.Generic; namespace MLEM.Ui.Style { public struct StyleProp { public T Value { get; private set; } private bool isCustom; public StyleProp(T value) { this.isCustom = true; this.Value = value; } public void SetFromStyle(T value) { if (!this.isCustom) { this.Value = value; } } public void Set(T value) { this.isCustom = true; this.Value = value; } public T OrDefault(T def) { return this.HasValue() ? this.Value : def; } public bool HasValue() { return !EqualityComparer.Default.Equals(this.Value, default); } public static implicit operator T(StyleProp prop) { return prop.Value; } public static implicit operator StyleProp(T prop) { return new StyleProp(prop); } } }