Allow specifying a custom width for nubs in `OsuCheckbox`es

This commit is contained in:
Dean Herbert 2023-07-14 14:24:53 +09:00
parent 5b2e704264
commit 1dc293ed61
3 changed files with 8 additions and 8 deletions

View File

@ -20,16 +20,16 @@ public partial class Nub : Container, IHasCurrentValue<bool>, IHasAccentColour
{
public const float HEIGHT = 15;
public const float EXPANDED_SIZE = 50;
public const float DEFAULT_EXPANDED_SIZE = 50;
private const float border_width = 3;
private readonly Box fill;
private readonly Container main;
public Nub()
public Nub(float expandedSize = DEFAULT_EXPANDED_SIZE)
{
Size = new Vector2(EXPANDED_SIZE, HEIGHT);
Size = new Vector2(expandedSize, HEIGHT);
InternalChildren = new[]
{

View File

@ -47,7 +47,7 @@ public MarginPadding LabelPadding
private Sample sampleChecked;
private Sample sampleUnchecked;
public OsuCheckbox(bool nubOnRight = true)
public OsuCheckbox(bool nubOnRight = true, float nubSize = Nub.DEFAULT_EXPANDED_SIZE)
{
AutoSizeAxes = Axes.Y;
RelativeSizeAxes = Axes.X;
@ -61,7 +61,7 @@ public OsuCheckbox(bool nubOnRight = true)
AutoSizeAxes = Axes.Y,
RelativeSizeAxes = Axes.X,
},
Nub = new Nub(),
Nub = new Nub(nubSize),
new HoverSounds()
};
@ -70,14 +70,14 @@ public OsuCheckbox(bool nubOnRight = true)
Nub.Anchor = Anchor.CentreRight;
Nub.Origin = Anchor.CentreRight;
Nub.Margin = new MarginPadding { Right = nub_padding };
LabelTextFlowContainer.Padding = new MarginPadding { Right = Nub.EXPANDED_SIZE + nub_padding * 2 };
LabelTextFlowContainer.Padding = new MarginPadding { Right = Nub.DEFAULT_EXPANDED_SIZE + nub_padding * 2 };
}
else
{
Nub.Anchor = Anchor.CentreLeft;
Nub.Origin = Anchor.CentreLeft;
Nub.Margin = new MarginPadding { Left = nub_padding };
LabelTextFlowContainer.Padding = new MarginPadding { Left = Nub.EXPANDED_SIZE + nub_padding * 2 };
LabelTextFlowContainer.Padding = new MarginPadding { Left = Nub.DEFAULT_EXPANDED_SIZE + nub_padding * 2 };
}
Nub.Current.BindTo(Current);

View File

@ -51,7 +51,7 @@ public Color4 BackgroundColour
public RoundedSliderBar()
{
Height = Nub.HEIGHT;
RangePadding = Nub.EXPANDED_SIZE / 2;
RangePadding = Nub.DEFAULT_EXPANDED_SIZE / 2;
Children = new Drawable[]
{
new Container