Adds a UI element to act as placeholder.

This commit is contained in:
Pieter-Jan Briers
2019-05-14 01:19:25 +02:00
parent 88c29abe5e
commit 96fbde3413
4 changed files with 51 additions and 0 deletions

View File

@@ -20,6 +20,7 @@ namespace Content.Client.UserInterface
{
var resCache = IoCManager.Resolve<IResourceCache>();
var notoSans12 = resCache.GetFont("/Nano/NotoSans/NotoSans-Regular.ttf", 12);
var notoSans16 = resCache.GetFont("/Nano/NotoSans/NotoSans-Regular.ttf", 16);
var notoSansBold16 = resCache.GetFont("/Nano/NotoSans/NotoSans-Bold.ttf", 16);
var textureCloseButton = resCache.GetTexture("/Nano/cross.svg.png");
var windowHeaderTex = resCache.GetTexture("/Nano/window_header.png");
@@ -140,6 +141,12 @@ namespace Content.Client.UserInterface
tooltipBox.SetPatchMargin(StyleBox.Margin.All, 2);
tooltipBox.SetContentMarginOverride(StyleBox.Margin.Horizontal, 5);
// Placeholder
var placeholderTexture = resCache.GetTexture("/Nano/placeholder.png");
var placeholder = new StyleBoxTexture { Texture = placeholderTexture };
placeholder.SetPatchMargin(StyleBox.Margin.All, 24);
placeholder.SetExpandMargin(StyleBox.Margin.All, -5);
Stylesheet = new Stylesheet(new[]
{
// Default font.
@@ -376,6 +383,18 @@ namespace Content.Client.UserInterface
ContentMarginLeftOverride = 4
})
}),
// Placeholder
new StyleRule(new SelectorElement(typeof(Placeholder), null, null, null), new []
{
new StyleProperty(PanelContainer.StylePropertyPanel, placeholder),
}),
new StyleRule(new SelectorElement(typeof(Label), new []{Placeholder.StyleClassPlaceholderText}, null, null), new []
{
new StyleProperty(Label.StylePropertyFont, notoSans16),
new StyleProperty(Label.StylePropertyFontColor, new Color(103, 103, 103, 128)),
}),
});
}
}