Skip to content
11 changes: 11 additions & 0 deletions Robust.Client/UserInterface/Controls/AlphaSliderChannel.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<BoxContainer xmlns="https://spacestation14.io"
Orientation="Horizontal"
SeparationOverride="3">
<Label Name="ChannelLabel"
Text="{Loc 'color-selector-sliders-alpha'}" />
<Slider Name="AlphaSlider"
HorizontalExpand="True"
VerticalAlignment="Center"
MaxValue="1.0" />
<SpinBox Name="InputBox" />
</BoxContainer>
38 changes: 38 additions & 0 deletions Robust.Client/UserInterface/Controls/AlphaSliderChannel.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
using System;
using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface.XAML;

namespace Robust.Client.UserInterface.Controls;

[GenerateTypedNameReferences]
[Access(typeof(ColorSelectorSliders))]
public sealed partial class AlphaSliderChannel : BoxContainer, ISliderChannel
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't be public

{
public event Action<Range>? OnSliderValueChanged;
public event Action<ValueChangedEventArgs>? OnSpinValueChanged;

public Func<int, bool>? IsInputValid
{
set => InputBox.IsValid = value;
}

public float Value
{
get => AlphaSlider.Value;
set => AlphaSlider.Value = value;
}

public AlphaSliderChannel()
{
RobustXamlLoader.Load(this);
AlphaSlider.OnValueChanged += v => OnSliderValueChanged?.Invoke(v);
InputBox.ValueChanged += args => OnSpinValueChanged?.Invoke(args);
InputBox.InitDefaultButtons();
}

public void OverrideValue(float value, float divisor)
{
AlphaSlider.SetValueWithoutEvent(value);
InputBox.OverrideValue((int)(value * divisor));
}
}
30 changes: 30 additions & 0 deletions Robust.Client/UserInterface/Controls/ColorSelectorSliders.xaml
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Holy copy paste

Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<Control xmlns="https://spacestation14.io">
<BoxContainer Name="RootBox" Orientation="Vertical">
<BoxContainer Name="HeaderBox"
Orientation="Horizontal"
SeparationOverride="5">
<OptionButton Name="TypeSelector" />
<Label Name="ColorDescriptionLabel" />
</BoxContainer>
<BoxContainer Name="BodyBox" Orientation="Vertical">
<ColorSliderChannel Name="TopChannel" />
<ColorSliderChannel Name="MiddleChannel" />
<ColorSliderChannel Name="BottomChannel" />
<AlphaSliderChannel Name="AlphaChannel" />
</BoxContainer>
<BoxContainer Name="HexBox"
Orientation="Horizontal"
HorizontalExpand="True">
<PanelContainer Name="ColorPreviewPanel"
Margin="2"
HorizontalExpand="True"
SizeFlagsStretchRatio="1" />
<Control HorizontalExpand="True"
SizeFlagsStretchRatio="3" />
<BoxContainer Name="HexEditBox" Orientation="Horizontal">
<Label Text="#" />
<!-- mono line edit added in c# -->
</BoxContainer>
</BoxContainer>
</BoxContainer>
</Control>
Loading
Loading