Adds side-open button styles.
This commit is contained in:
@@ -80,12 +80,12 @@ namespace Content.Client.GameObjects.Components.Chemistry
|
||||
new Label {Text = _localizationManager.GetString("Amount")},
|
||||
//Padding
|
||||
new Control {CustomMinimumSize = (20, 0)},
|
||||
(DispenseButton1 = new Button {Text = "1", Group = dispenseAmountGroup}),
|
||||
(DispenseButton5 = new Button {Text = "5", Group = dispenseAmountGroup}),
|
||||
(DispenseButton10 = new Button {Text = "10", Group = dispenseAmountGroup}),
|
||||
(DispenseButton25 = new Button {Text = "25", Group = dispenseAmountGroup}),
|
||||
(DispenseButton50 = new Button {Text = "50", Group = dispenseAmountGroup}),
|
||||
(DispenseButton100 = new Button {Text = "100", Group = dispenseAmountGroup}),
|
||||
(DispenseButton1 = new Button {Text = "1", Group = dispenseAmountGroup, StyleClasses = { StyleBase.ButtonOpenRight }}),
|
||||
(DispenseButton5 = new Button {Text = "5", Group = dispenseAmountGroup, StyleClasses = { StyleBase.ButtonOpenBoth }}),
|
||||
(DispenseButton10 = new Button {Text = "10", Group = dispenseAmountGroup, StyleClasses = { StyleBase.ButtonOpenBoth }}),
|
||||
(DispenseButton25 = new Button {Text = "25", Group = dispenseAmountGroup, StyleClasses = { StyleBase.ButtonOpenBoth }}),
|
||||
(DispenseButton50 = new Button {Text = "50", Group = dispenseAmountGroup, StyleClasses = { StyleBase.ButtonOpenBoth }}),
|
||||
(DispenseButton100 = new Button {Text = "100", Group = dispenseAmountGroup, StyleClasses = { StyleBase.ButtonOpenLeft }}),
|
||||
}
|
||||
},
|
||||
//Padding
|
||||
@@ -102,8 +102,8 @@ namespace Content.Client.GameObjects.Components.Chemistry
|
||||
Children =
|
||||
{
|
||||
new Label {Text = _localizationManager.GetString("Container: ")},
|
||||
(ClearButton = new Button {Text = _localizationManager.GetString("Clear")}),
|
||||
(EjectButton = new Button {Text = _localizationManager.GetString("Eject")})
|
||||
(ClearButton = new Button {Text = _localizationManager.GetString("Clear"), StyleClasses = {StyleBase.ButtonOpenRight}}),
|
||||
(EjectButton = new Button {Text = _localizationManager.GetString("Eject"), StyleClasses = {StyleBase.ButtonOpenLeft}})
|
||||
}
|
||||
},
|
||||
//Wrap the container info in a PanelContainer so we can color it's background differently.
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
using Content.Client.Utility;
|
||||
using Robust.Client.Graphics;
|
||||
using Robust.Client.Graphics.Drawing;
|
||||
using Robust.Client.Interfaces.ResourceManagement;
|
||||
using Robust.Client.UserInterface;
|
||||
using Robust.Shared.Maths;
|
||||
|
||||
namespace Content.Client.UserInterface.Stylesheets
|
||||
{
|
||||
@@ -11,11 +13,18 @@ namespace Content.Client.UserInterface.Stylesheets
|
||||
public const string StyleClassLabelHeading = "LabelHeading";
|
||||
public const string StyleClassLabelSubText = "LabelSubText";
|
||||
|
||||
public const string ButtonOpenRight = "OpenRight";
|
||||
public const string ButtonOpenLeft = "OpenLeft";
|
||||
public const string ButtonOpenBoth = "OpenBoth";
|
||||
|
||||
public abstract Stylesheet Stylesheet { get; }
|
||||
|
||||
protected StyleRule[] BaseRules { get; }
|
||||
|
||||
protected StyleBoxTexture BaseButton { get; }
|
||||
protected StyleBoxTexture BaseButtonOpenRight { get; }
|
||||
protected StyleBoxTexture BaseButtonOpenLeft { get; }
|
||||
protected StyleBoxTexture BaseButtonOpenBoth { get; }
|
||||
|
||||
protected StyleBase(IResourceCache resCache)
|
||||
{
|
||||
@@ -32,6 +41,31 @@ namespace Content.Client.UserInterface.Stylesheets
|
||||
BaseButton.SetContentMarginOverride(StyleBox.Margin.Vertical, 2);
|
||||
BaseButton.SetContentMarginOverride(StyleBox.Margin.Horizontal, 14);
|
||||
|
||||
BaseButtonOpenRight = new StyleBoxTexture(BaseButton)
|
||||
{
|
||||
Texture = new AtlasTexture(buttonTex, UIBox2.FromDimensions((0, 0), (14, 24))),
|
||||
};
|
||||
BaseButtonOpenRight.SetPatchMargin(StyleBox.Margin.Right, 0);
|
||||
BaseButtonOpenRight.SetContentMarginOverride(StyleBox.Margin.Right, 8);
|
||||
BaseButtonOpenRight.SetPadding(StyleBox.Margin.Right, 2);
|
||||
|
||||
BaseButtonOpenLeft = new StyleBoxTexture(BaseButton)
|
||||
{
|
||||
Texture = new AtlasTexture(buttonTex, UIBox2.FromDimensions((10, 0), (14, 24))),
|
||||
};
|
||||
BaseButtonOpenLeft.SetPatchMargin(StyleBox.Margin.Left, 0);
|
||||
BaseButtonOpenLeft.SetContentMarginOverride(StyleBox.Margin.Left, 8);
|
||||
BaseButtonOpenLeft.SetPadding(StyleBox.Margin.Left, 1);
|
||||
|
||||
BaseButtonOpenBoth = new StyleBoxTexture(BaseButton)
|
||||
{
|
||||
Texture = new AtlasTexture(buttonTex, UIBox2.FromDimensions((10, 0), (3, 24))),
|
||||
};
|
||||
BaseButtonOpenBoth.SetPatchMargin(StyleBox.Margin.Horizontal, 0);
|
||||
BaseButtonOpenBoth.SetContentMarginOverride(StyleBox.Margin.Horizontal, 8);
|
||||
BaseButtonOpenBoth.SetPadding(StyleBox.Margin.Right, 2);
|
||||
BaseButtonOpenBoth.SetPadding(StyleBox.Margin.Left, 1);
|
||||
|
||||
BaseRules = new[]
|
||||
{
|
||||
// Default font.
|
||||
|
||||
@@ -7,6 +7,7 @@ using Robust.Client.UserInterface;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
using Robust.Client.UserInterface.CustomControls;
|
||||
using Robust.Shared.Maths;
|
||||
using static Robust.Client.UserInterface.StylesheetHelpers;
|
||||
|
||||
namespace Content.Client.UserInterface.Stylesheets
|
||||
{
|
||||
@@ -69,26 +70,29 @@ namespace Content.Client.UserInterface.Stylesheets
|
||||
|
||||
var textureInvertedTriangle = resCache.GetTexture("/Textures/Interface/Nano/inverted_triangle.svg.png");
|
||||
|
||||
static (StyleBox, StyleBox, StyleBox, StyleBox) ButtonPermutations(StyleBoxTexture @base)
|
||||
{
|
||||
var normal = new StyleBoxTexture(@base) {Modulate = ButtonColorDefault};
|
||||
var hover = new StyleBoxTexture(@base) {Modulate = ButtonColorHovered};
|
||||
var pressed = new StyleBoxTexture(@base) {Modulate = ButtonColorPressed};
|
||||
var disabled = new StyleBoxTexture(@base) {Modulate = ButtonColorDisabled};
|
||||
|
||||
return (normal, hover, pressed, disabled);
|
||||
}
|
||||
|
||||
// Button styles.
|
||||
var buttonNormal = new StyleBoxTexture(BaseButton)
|
||||
{
|
||||
Modulate = ButtonColorDefault
|
||||
};
|
||||
var (buttonNormal, buttonHover, buttonPressed, buttonDisabled)
|
||||
= ButtonPermutations(BaseButton);
|
||||
|
||||
var buttonHover = new StyleBoxTexture(buttonNormal)
|
||||
{
|
||||
Modulate = ButtonColorHovered
|
||||
};
|
||||
var (buttonRNormal, buttonRHover, buttonRPressed, buttonRDisabled)
|
||||
= ButtonPermutations(BaseButtonOpenRight);
|
||||
|
||||
var buttonPressed = new StyleBoxTexture(buttonNormal)
|
||||
{
|
||||
Modulate = ButtonColorPressed
|
||||
};
|
||||
var (buttonLNormal, buttonLHover, buttonLPressed, buttonLDisabled)
|
||||
= ButtonPermutations(BaseButtonOpenLeft);
|
||||
|
||||
var (buttonBNormal, buttonBHover, buttonBPressed, buttonBDisabled)
|
||||
= ButtonPermutations(BaseButtonOpenBoth);
|
||||
|
||||
var buttonDisabled = new StyleBoxTexture(buttonNormal)
|
||||
{
|
||||
Modulate = ButtonColorDisabled
|
||||
};
|
||||
|
||||
var lineEditTex = resCache.GetTexture("/Textures/Interface/Nano/lineedit.png");
|
||||
var lineEdit = new StyleBoxTexture
|
||||
@@ -316,6 +320,58 @@ namespace Content.Client.UserInterface.Stylesheets
|
||||
new StyleProperty(Label.StylePropertyAlignMode, Label.AlignMode.Center),
|
||||
}),
|
||||
|
||||
// Right open buttons.
|
||||
Element<ContainerButton>().Class(ContainerButton.StyleClassButton).Class(ButtonOpenRight)
|
||||
.Pseudo(ContainerButton.StylePseudoClassNormal)
|
||||
.Prop(ContainerButton.StylePropertyStyleBox, buttonRNormal),
|
||||
|
||||
Element<ContainerButton>().Class(ContainerButton.StyleClassButton).Class(ButtonOpenRight)
|
||||
.Pseudo(ContainerButton.StylePseudoClassHover)
|
||||
.Prop(ContainerButton.StylePropertyStyleBox, buttonRHover),
|
||||
|
||||
Element<ContainerButton>().Class(ContainerButton.StyleClassButton).Class(ButtonOpenRight)
|
||||
.Pseudo(ContainerButton.StylePseudoClassPressed)
|
||||
.Prop(ContainerButton.StylePropertyStyleBox, buttonRPressed),
|
||||
|
||||
Element<ContainerButton>().Class(ContainerButton.StyleClassButton).Class(ButtonOpenRight)
|
||||
.Pseudo(ContainerButton.StylePseudoClassDisabled)
|
||||
.Prop(ContainerButton.StylePropertyStyleBox, buttonRDisabled),
|
||||
|
||||
// Left open buttons.
|
||||
Element<ContainerButton>().Class(ContainerButton.StyleClassButton).Class(ButtonOpenLeft)
|
||||
.Pseudo(ContainerButton.StylePseudoClassNormal)
|
||||
.Prop(ContainerButton.StylePropertyStyleBox, buttonLNormal),
|
||||
|
||||
Element<ContainerButton>().Class(ContainerButton.StyleClassButton).Class(ButtonOpenLeft)
|
||||
.Pseudo(ContainerButton.StylePseudoClassHover)
|
||||
.Prop(ContainerButton.StylePropertyStyleBox, buttonLHover),
|
||||
|
||||
Element<ContainerButton>().Class(ContainerButton.StyleClassButton).Class(ButtonOpenLeft)
|
||||
.Pseudo(ContainerButton.StylePseudoClassPressed)
|
||||
.Prop(ContainerButton.StylePropertyStyleBox, buttonLPressed),
|
||||
|
||||
Element<ContainerButton>().Class(ContainerButton.StyleClassButton).Class(ButtonOpenLeft)
|
||||
.Pseudo(ContainerButton.StylePseudoClassDisabled)
|
||||
.Prop(ContainerButton.StylePropertyStyleBox, buttonLDisabled),
|
||||
|
||||
// "Both" open buttons
|
||||
Element<ContainerButton>().Class(ContainerButton.StyleClassButton).Class(ButtonOpenBoth)
|
||||
.Pseudo(ContainerButton.StylePseudoClassNormal)
|
||||
.Prop(ContainerButton.StylePropertyStyleBox, buttonBNormal),
|
||||
|
||||
Element<ContainerButton>().Class(ContainerButton.StyleClassButton).Class(ButtonOpenBoth)
|
||||
.Pseudo(ContainerButton.StylePseudoClassHover)
|
||||
.Prop(ContainerButton.StylePropertyStyleBox, buttonBHover),
|
||||
|
||||
Element<ContainerButton>().Class(ContainerButton.StyleClassButton).Class(ButtonOpenBoth)
|
||||
.Pseudo(ContainerButton.StylePseudoClassPressed)
|
||||
.Prop(ContainerButton.StylePropertyStyleBox, buttonBPressed),
|
||||
|
||||
Element<ContainerButton>().Class(ContainerButton.StyleClassButton).Class(ButtonOpenBoth)
|
||||
.Pseudo(ContainerButton.StylePseudoClassDisabled)
|
||||
.Prop(ContainerButton.StylePropertyStyleBox, buttonBDisabled),
|
||||
|
||||
|
||||
new StyleRule(new SelectorChild(
|
||||
new SelectorElement(typeof(Button), null, null, new[] {ContainerButton.StylePseudoClassDisabled}),
|
||||
new SelectorElement(typeof(Label), null, null, null)),
|
||||
|
||||
@@ -25,27 +25,28 @@ namespace Content.Client.UserInterface.Stylesheets
|
||||
var notoSans10 = resCache.GetFont("/Textures/Interface/Nano/NotoSans/NotoSans-Regular.ttf", 10);
|
||||
var notoSansBold16 = resCache.GetFont("/Textures/Interface/Nano/NotoSans/NotoSans-Bold.ttf", 16);
|
||||
|
||||
static (StyleBox, StyleBox, StyleBox, StyleBox) ButtonPermutations(StyleBoxTexture @base)
|
||||
{
|
||||
var normal = new StyleBoxTexture(@base) {Modulate = ButtonColorDefault};
|
||||
var hover = new StyleBoxTexture(@base) {Modulate = ButtonColorHovered};
|
||||
var pressed = new StyleBoxTexture(@base) {Modulate = ButtonColorPressed};
|
||||
var disabled = new StyleBoxTexture(@base) {Modulate = ButtonColorDisabled};
|
||||
|
||||
return (normal, hover, pressed, disabled);
|
||||
}
|
||||
|
||||
// Button styles.
|
||||
var buttonNormal = new StyleBoxTexture(BaseButton)
|
||||
{
|
||||
Modulate = ButtonColorDefault
|
||||
};
|
||||
var (buttonNormal, buttonHover, buttonPressed, buttonDisabled)
|
||||
= ButtonPermutations(BaseButton);
|
||||
|
||||
var buttonHover = new StyleBoxTexture(buttonNormal)
|
||||
{
|
||||
Modulate = ButtonColorHovered
|
||||
};
|
||||
var (buttonRNormal, buttonRHover, buttonRPressed, buttonRDisabled)
|
||||
= ButtonPermutations(BaseButtonOpenRight);
|
||||
|
||||
var buttonPressed = new StyleBoxTexture(buttonNormal)
|
||||
{
|
||||
Modulate = ButtonColorPressed
|
||||
};
|
||||
|
||||
var buttonDisabled = new StyleBoxTexture(buttonNormal)
|
||||
{
|
||||
Modulate = ButtonColorDisabled
|
||||
};
|
||||
var (buttonLNormal, buttonLHover, buttonLPressed, buttonLDisabled)
|
||||
= ButtonPermutations(BaseButtonOpenLeft);
|
||||
|
||||
var (buttonBNormal, buttonBHover, buttonBPressed, buttonBDisabled)
|
||||
= ButtonPermutations(BaseButtonOpenBoth);
|
||||
|
||||
Stylesheet = new Stylesheet(BaseRules.Concat(new StyleRule[]
|
||||
{
|
||||
@@ -63,6 +64,7 @@ namespace Content.Client.UserInterface.Stylesheets
|
||||
BackgroundColor = SpaceRed, ContentMarginBottomOverride = 2, ContentMarginLeftOverride = 2
|
||||
}),
|
||||
|
||||
// Normal buttons.
|
||||
Element<ContainerButton>().Class(ContainerButton.StyleClassButton)
|
||||
.Pseudo(ContainerButton.StylePseudoClassNormal)
|
||||
.Prop(ContainerButton.StylePropertyStyleBox, buttonNormal),
|
||||
@@ -79,6 +81,58 @@ namespace Content.Client.UserInterface.Stylesheets
|
||||
.Pseudo(ContainerButton.StylePseudoClassDisabled)
|
||||
.Prop(ContainerButton.StylePropertyStyleBox, buttonDisabled),
|
||||
|
||||
// Right open buttons.
|
||||
Element<ContainerButton>().Class(ContainerButton.StyleClassButton).Class(ButtonOpenRight)
|
||||
.Pseudo(ContainerButton.StylePseudoClassNormal)
|
||||
.Prop(ContainerButton.StylePropertyStyleBox, buttonRNormal),
|
||||
|
||||
Element<ContainerButton>().Class(ContainerButton.StyleClassButton).Class(ButtonOpenRight)
|
||||
.Pseudo(ContainerButton.StylePseudoClassHover)
|
||||
.Prop(ContainerButton.StylePropertyStyleBox, buttonRHover),
|
||||
|
||||
Element<ContainerButton>().Class(ContainerButton.StyleClassButton).Class(ButtonOpenRight)
|
||||
.Pseudo(ContainerButton.StylePseudoClassPressed)
|
||||
.Prop(ContainerButton.StylePropertyStyleBox, buttonRPressed),
|
||||
|
||||
Element<ContainerButton>().Class(ContainerButton.StyleClassButton).Class(ButtonOpenRight)
|
||||
.Pseudo(ContainerButton.StylePseudoClassDisabled)
|
||||
.Prop(ContainerButton.StylePropertyStyleBox, buttonRDisabled),
|
||||
|
||||
// Left open buttons.
|
||||
Element<ContainerButton>().Class(ContainerButton.StyleClassButton).Class(ButtonOpenLeft)
|
||||
.Pseudo(ContainerButton.StylePseudoClassNormal)
|
||||
.Prop(ContainerButton.StylePropertyStyleBox, buttonLNormal),
|
||||
|
||||
Element<ContainerButton>().Class(ContainerButton.StyleClassButton).Class(ButtonOpenLeft)
|
||||
.Pseudo(ContainerButton.StylePseudoClassHover)
|
||||
.Prop(ContainerButton.StylePropertyStyleBox, buttonLHover),
|
||||
|
||||
Element<ContainerButton>().Class(ContainerButton.StyleClassButton).Class(ButtonOpenLeft)
|
||||
.Pseudo(ContainerButton.StylePseudoClassPressed)
|
||||
.Prop(ContainerButton.StylePropertyStyleBox, buttonLPressed),
|
||||
|
||||
Element<ContainerButton>().Class(ContainerButton.StyleClassButton).Class(ButtonOpenLeft)
|
||||
.Pseudo(ContainerButton.StylePseudoClassDisabled)
|
||||
.Prop(ContainerButton.StylePropertyStyleBox, buttonLDisabled),
|
||||
|
||||
// "Both" open buttons
|
||||
Element<ContainerButton>().Class(ContainerButton.StyleClassButton).Class(ButtonOpenBoth)
|
||||
.Pseudo(ContainerButton.StylePseudoClassNormal)
|
||||
.Prop(ContainerButton.StylePropertyStyleBox, buttonBNormal),
|
||||
|
||||
Element<ContainerButton>().Class(ContainerButton.StyleClassButton).Class(ButtonOpenBoth)
|
||||
.Pseudo(ContainerButton.StylePseudoClassHover)
|
||||
.Prop(ContainerButton.StylePropertyStyleBox, buttonBHover),
|
||||
|
||||
Element<ContainerButton>().Class(ContainerButton.StyleClassButton).Class(ButtonOpenBoth)
|
||||
.Pseudo(ContainerButton.StylePseudoClassPressed)
|
||||
.Prop(ContainerButton.StylePropertyStyleBox, buttonBPressed),
|
||||
|
||||
Element<ContainerButton>().Class(ContainerButton.StyleClassButton).Class(ButtonOpenBoth)
|
||||
.Pseudo(ContainerButton.StylePseudoClassDisabled)
|
||||
.Prop(ContainerButton.StylePropertyStyleBox, buttonBDisabled),
|
||||
|
||||
|
||||
Element<Label>().Class(ContainerButton.StyleClassButton)
|
||||
.Prop(Label.StylePropertyAlignMode, Label.AlignMode.Center),
|
||||
|
||||
|
||||
Reference in New Issue
Block a user