From e731e8af49909b046ead93d165d6e49cb863f04d Mon Sep 17 00:00:00 2001 From: "H. Utku Maden" Date: Mon, 15 May 2023 12:07:12 +0300 Subject: [PATCH] Add new style classes. --- Quik/QuikStyle.cs | 198 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 198 insertions(+) diff --git a/Quik/QuikStyle.cs b/Quik/QuikStyle.cs index 8acb8c6..9c5ba7e 100644 --- a/Quik/QuikStyle.cs +++ b/Quik/QuikStyle.cs @@ -1,5 +1,203 @@ +using System; +using System.Collections.Generic; +using Quik.Typography; + namespace Quik { + public enum TextAlignment + { + Left, + Center, + Right, + Justify + } + + public enum TextDecoration + { + None, + Underline, + Overline, + Strikethrough + } + + public enum TextTransform + { + None, + Title, + Upper, + Lower, + } + + public enum ListMarkerType + { + None, + Disc, + Circle, + FilledSquare, + Square, + Dash, + ArabicNumeral, + RomanNumeralUpper, + RomanNumeralLower, + AlphabetUpper, + AlphabetLower, + Image + } + + public enum ListMarkerPosition + { + Inside, + Outside, + } + + public abstract class StyleBase + { + public abstract object this[string key] { get; set; } + + public QuikColor? Color + { + get => (QuikColor?)this["color"]; + set => this["color"] = value; + } + + public float? LineHeight + { + get => (float?)this["line-height"]; + set => this["line-height"] = value; + } + + public float? LetterSpacing + { + get => (float?)this["letter-spacing"]; + set => this["letter-spacing"] = value; + } + + public TextAlignment? TextAlignment + { + get => (TextAlignment?)this["text-alignment"]; + set => this["text-alignment"] = value; + } + + public TextDecoration? TextDecoration + { + get => (TextDecoration?)this["text-decoration"]; + set => this["text-decoration"] = value; + } + + public float? TextIndent + { + get => (float?)this["text-indent"]; + set => this["text-indent"] = value; + } + + public TextTransform? TextTransform + { + get => (TextTransform?)this["text-transform"]; + set => this["text-transform"] = value; + } + + public ListMarkerType? ListMarker + { + get => (ListMarkerType?)this["list-marker"]; + set => this["list-marker"] = value; + } + + public ListMarkerPosition? ListMarkerPosition + { + get => (ListMarkerPosition?)this["list-marker-position"]; + set => this["list-marker-position"] = value; + } + + public IQuikTexture ListMarkerImage + { + get => (IQuikTexture)this["list-marker-image"]; + set => this["list-marker-image"] = value; + } + + public float? BorderWidth + { + get => (float?)this["border-width"]; + set => this["border-width"] = value; + } + + public QuikColor? BorderColor + { + get => (QuikColor?)this["border-color"]; + set => this["border-color"] = value; + } + + public QuikFont Font + { + get => (QuikFont)this["font"]; + set => this["font"] = value; + } + } + + public class Style : StyleBase + { + private readonly Dictionary _keys = new Dictionary(); + + public override object this[string styleKey] + { + get => _keys.TryGetValue(styleKey, out object value) ? value : null; + set + { + if (value == null) + _keys.Remove(styleKey); + else + _keys[styleKey] = value; + } + } + } + + public class StyleStack : StyleBase + { + public readonly List