1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-06 10:22:54 +08:00

Allow specifying a custom width for nubs in OsuCheckboxes

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 @@ namespace osu.Game.Graphics.UserInterface
{ {
public const float HEIGHT = 15; 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 const float border_width = 3;
private readonly Box fill; private readonly Box fill;
private readonly Container main; 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[] InternalChildren = new[]
{ {

View File

@ -47,7 +47,7 @@ namespace osu.Game.Graphics.UserInterface
private Sample sampleChecked; private Sample sampleChecked;
private Sample sampleUnchecked; private Sample sampleUnchecked;
public OsuCheckbox(bool nubOnRight = true) public OsuCheckbox(bool nubOnRight = true, float nubSize = Nub.DEFAULT_EXPANDED_SIZE)
{ {
AutoSizeAxes = Axes.Y; AutoSizeAxes = Axes.Y;
RelativeSizeAxes = Axes.X; RelativeSizeAxes = Axes.X;
@ -61,7 +61,7 @@ namespace osu.Game.Graphics.UserInterface
AutoSizeAxes = Axes.Y, AutoSizeAxes = Axes.Y,
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
}, },
Nub = new Nub(), Nub = new Nub(nubSize),
new HoverSounds() new HoverSounds()
}; };
@ -70,14 +70,14 @@ namespace osu.Game.Graphics.UserInterface
Nub.Anchor = Anchor.CentreRight; Nub.Anchor = Anchor.CentreRight;
Nub.Origin = Anchor.CentreRight; Nub.Origin = Anchor.CentreRight;
Nub.Margin = new MarginPadding { Right = nub_padding }; 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 else
{ {
Nub.Anchor = Anchor.CentreLeft; Nub.Anchor = Anchor.CentreLeft;
Nub.Origin = Anchor.CentreLeft; Nub.Origin = Anchor.CentreLeft;
Nub.Margin = new MarginPadding { Left = nub_padding }; 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); Nub.Current.BindTo(Current);

View File

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