using System.Collections.Generic;
using Glass;
namespace Clave.Glass.UnitTests
{
///
/// Looks with sizes worked out by hand: every glyph is 3 by 4, text has no margins, and buttons draw nothing, so a
/// button is as big as its label.
///
public static class TestLooks
{
public const int GlyphWidth = 3;
public const int GlyphHeight = 4;
public const int Spacing = 2;
public static readonly SpriteFontDefinition Font = MonospaceFont(GlyphWidth, GlyphHeight);
public static readonly TextMaterialStyle Text = new TextMaterialStyle
{
Font = Font,
HorizontalMargin = 0,
VerticalMargin = 0,
};
///
/// Text with glyphs of another size, for a part that should stand out from the rest.
///
public static TextMaterialStyle TextOf(int glyphWidth, int glyphHeight)
{
return Text with { Font = MonospaceFont(glyphWidth, glyphHeight) };
}
public static readonly ButtonMaterial Binding = new SolidColorMaterial();
public static readonly ButtonMaterial Capturing = new SolidColorMaterial();
public static readonly ButtonMaterial SidedKey = new SolidColorMaterial();
public static readonly ButtonMaterial Empty = new SolidColorMaterial();
public static readonly ButtonMaterial Clashing = new SolidColorMaterial();
public static readonly KeyBindingsMaterial Material = new KeyBindingsMaterial
{
ActionTextStyle = Text,
KeyTextStyle = Text,
ClashTextStyle = Text,
ButtonTextStyle = Text,
Binding = Binding,
CapturingBinding = Capturing,
SidedKey = SidedKey,
RemoveTextStyle = Text,
RemoveButton = new SolidColorMaterial(),
EmptyBinding = Empty,
ClashingBinding = Clashing,
CommandButton = new SolidColorMaterial(),
Spacing = Spacing,
};
private static SpriteFontDefinition MonospaceFont(int glyphWidth, int glyphHeight)
{
var glyph = new SpriteFontDefinition.GlyphDefinition
{
Size = new Point(glyphWidth, glyphHeight),
Width = glyphWidth,
};
var glyphs = new Dictionary();
for (char c = ' '; c <= '~'; c++)
{
glyphs[c] = glyph;
}
return new SpriteFontDefinition(new SpriteFontDefinition.Data
{
Name = "TestMonospace",
LineHeight = (ushort)glyphHeight,
Baseline = (ushort)(glyphHeight - 1),
Pages = new List { "test" },
GlyphDefinitions = glyphs,
InvalidGlyph = glyph,
});
}
public static int WidthOf(string text)
{
return text.Length * GlyphWidth;
}
}
}