Add new style classes.
This commit is contained in:
parent
9eadc26f2f
commit
e731e8af49
@ -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<string, object> _keys = new Dictionary<string, object>();
|
||||
|
||||
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<Style> _styles = new List<Style>();
|
||||
|
||||
public Style BaseStyle { get; }
|
||||
|
||||
public override object this[string key]
|
||||
{
|
||||
get
|
||||
{
|
||||
object value = null;
|
||||
|
||||
for (int i = _styles.Count; i != 0 && value == null; i--)
|
||||
{
|
||||
value = _styles[i-1][key];
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
set => throw new InvalidOperationException();
|
||||
}
|
||||
|
||||
public StyleStack(Style baseStyle)
|
||||
{
|
||||
BaseStyle = baseStyle;
|
||||
Push(BaseStyle);
|
||||
}
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
_styles.Clear();
|
||||
Push(BaseStyle);
|
||||
}
|
||||
|
||||
public void Push(Style style)
|
||||
{
|
||||
_styles.Add(style);
|
||||
}
|
||||
|
||||
public void Pop()
|
||||
{
|
||||
if (_styles.Count == 1)
|
||||
return;
|
||||
|
||||
_styles.RemoveAt(_styles.Count - 1);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A line stipple pattern.
|
||||
/// </summary>
|
||||
|
Loading…
Reference in New Issue
Block a user