diff --git a/osu.Game.Tests/Visual/UserInterface/TestSceneRangeSlider.cs b/osu.Game.Tests/Visual/UserInterface/TestSceneRangeSlider.cs index 1b91459615..b780764e7f 100644 --- a/osu.Game.Tests/Visual/UserInterface/TestSceneRangeSlider.cs +++ b/osu.Game.Tests/Visual/UserInterface/TestSceneRangeSlider.cs @@ -45,7 +45,7 @@ namespace osu.Game.Tests.Visual.UserInterface LowerBound = customStart, UpperBound = customEnd, TooltipSuffix = "suffix", - NubWidth = RoundedNub.HEIGHT * 2, + NubWidth = Nub.HEIGHT * 2, DefaultStringLowerBound = "Start", DefaultStringUpperBound = "End", MinRange = 10 diff --git a/osu.Game/Graphics/UserInterface/Nub.cs b/osu.Game/Graphics/UserInterface/Nub.cs index 6f875e8594..28a2eb40c3 100644 --- a/osu.Game/Graphics/UserInterface/Nub.cs +++ b/osu.Game/Graphics/UserInterface/Nub.cs @@ -2,6 +2,8 @@ // See the LICENCE file in the repository root for full licence text. using System; +using osuTK; +using osuTK.Graphics; using osu.Framework.Allocation; using osu.Framework.Bindables; using osu.Framework.Extensions.Color4Extensions; @@ -11,33 +13,45 @@ using osu.Framework.Graphics.Effects; using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.UserInterface; using osu.Game.Overlays; -using osuTK.Graphics; namespace osu.Game.Graphics.UserInterface { - public abstract partial class Nub : Container, IHasCurrentValue, IHasAccentColour + public partial class Nub : Container, IHasCurrentValue, IHasAccentColour { - protected const float BORDER_WIDTH = 3; + public const float HEIGHT = 15; + + public const float EXPANDED_SIZE = 50; + + private const float border_width = 3; private readonly Box fill; private readonly Container main; - /// - /// Implements the shape for the nub, allowing for any type of container to be used. - /// - /// - protected abstract Container CreateNubContainer(); - - protected Nub() + public Nub() { - InternalChild = main = CreateNubContainer(); + Size = new Vector2(EXPANDED_SIZE, HEIGHT); - main.Add(fill = new Box + InternalChildren = new[] { - RelativeSizeAxes = Axes.Both, - Alpha = 0, - AlwaysPresent = true, - }); + main = new CircularContainer + { + BorderColour = Color4.White, + BorderThickness = border_width, + Masking = true, + RelativeSizeAxes = Axes.Both, + Anchor = Anchor.TopCentre, + Origin = Anchor.TopCentre, + Children = new Drawable[] + { + fill = new Box + { + RelativeSizeAxes = Axes.Both, + Alpha = 0, + AlwaysPresent = true, + }, + } + }, + }; } [BackgroundDependencyLoader(true)] @@ -159,7 +173,7 @@ namespace osu.Game.Graphics.UserInterface else { main.ResizeWidthTo(0.75f, duration, Easing.OutQuint); - main.TransformTo(nameof(BorderThickness), BORDER_WIDTH, duration, Easing.OutQuint); + main.TransformTo(nameof(BorderThickness), border_width, duration, Easing.OutQuint); } } } diff --git a/osu.Game/Graphics/UserInterface/OsuCheckbox.cs b/osu.Game/Graphics/UserInterface/OsuCheckbox.cs index 2fae4e2cb5..160105af1a 100644 --- a/osu.Game/Graphics/UserInterface/OsuCheckbox.cs +++ b/osu.Game/Graphics/UserInterface/OsuCheckbox.cs @@ -41,7 +41,7 @@ namespace osu.Game.Graphics.UserInterface } } - protected readonly RoundedNub Nub; + protected readonly Nub Nub; protected readonly OsuTextFlowContainer LabelTextFlowContainer; private Sample sampleChecked; @@ -61,7 +61,7 @@ namespace osu.Game.Graphics.UserInterface AutoSizeAxes = Axes.Y, RelativeSizeAxes = Axes.X, }, - Nub = new RoundedNub(), + Nub = new Nub(), new HoverSounds() }; @@ -70,14 +70,14 @@ namespace osu.Game.Graphics.UserInterface Nub.Anchor = Anchor.CentreRight; Nub.Origin = Anchor.CentreRight; Nub.Margin = new MarginPadding { Right = nub_padding }; - LabelTextFlowContainer.Padding = new MarginPadding { Right = RoundedNub.EXPANDED_SIZE + nub_padding * 2 }; + LabelTextFlowContainer.Padding = new MarginPadding { Right = Nub.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 = RoundedNub.EXPANDED_SIZE + nub_padding * 2 }; + LabelTextFlowContainer.Padding = new MarginPadding { Left = Nub.EXPANDED_SIZE + nub_padding * 2 }; } Nub.Current.BindTo(Current); diff --git a/osu.Game/Graphics/UserInterface/RangeSlider.cs b/osu.Game/Graphics/UserInterface/RangeSlider.cs index 575327b50b..f83dff6295 100644 --- a/osu.Game/Graphics/UserInterface/RangeSlider.cs +++ b/osu.Game/Graphics/UserInterface/RangeSlider.cs @@ -163,7 +163,7 @@ namespace osu.Game.Graphics.UserInterface public string? DefaultString; public LocalisableString? DefaultTooltip; public string? TooltipSuffix; - public float NubWidth { get; set; } = RoundedNub.HEIGHT; + public float NubWidth { get; set; } = Nub.HEIGHT; public override LocalisableString TooltipText => (Current.IsDefault ? DefaultTooltip : Current.Value.ToString($@"0.## {TooltipSuffix}")) ?? Current.Value.ToString($@"0.## {TooltipSuffix}"); diff --git a/osu.Game/Graphics/UserInterface/RoundedNub.cs b/osu.Game/Graphics/UserInterface/RoundedNub.cs deleted file mode 100644 index 3bdfadfe22..0000000000 --- a/osu.Game/Graphics/UserInterface/RoundedNub.cs +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. -// See the LICENCE file in the repository root for full licence text. - -using osu.Framework.Graphics; -using osu.Framework.Graphics.Containers; -using osuTK; - -namespace osu.Game.Graphics.UserInterface -{ - public partial class RoundedNub : Nub - { - public const float HEIGHT = 15; - - public const float EXPANDED_SIZE = 50; - - public RoundedNub() - { - Size = new Vector2(EXPANDED_SIZE, HEIGHT); - } - - protected override Container CreateNubContainer() => - new CircularContainer - { - BorderColour = Colour4.White, - BorderThickness = BORDER_WIDTH, - Masking = true, - RelativeSizeAxes = Axes.Both, - Anchor = Anchor.TopCentre, - Origin = Anchor.TopCentre, - }; - } -} diff --git a/osu.Game/Graphics/UserInterface/RoundedSliderBar.cs b/osu.Game/Graphics/UserInterface/RoundedSliderBar.cs index 765e1d5105..a666b83c05 100644 --- a/osu.Game/Graphics/UserInterface/RoundedSliderBar.cs +++ b/osu.Game/Graphics/UserInterface/RoundedSliderBar.cs @@ -17,7 +17,7 @@ namespace osu.Game.Graphics.UserInterface public partial class RoundedSliderBar : OsuSliderBar where T : struct, IEquatable, IComparable, IConvertible { - protected readonly RoundedNub Nub; + protected readonly Nub Nub; protected readonly Box LeftBox; protected readonly Box RightBox; private readonly Container nubContainer; @@ -50,8 +50,8 @@ namespace osu.Game.Graphics.UserInterface public RoundedSliderBar() { - Height = RoundedNub.HEIGHT; - RangePadding = RoundedNub.EXPANDED_SIZE / 2; + Height = Nub.HEIGHT; + RangePadding = Nub.EXPANDED_SIZE / 2; Children = new Drawable[] { new Container @@ -93,7 +93,7 @@ namespace osu.Game.Graphics.UserInterface nubContainer = new Container { RelativeSizeAxes = Axes.Both, - Child = Nub = new RoundedNub + Child = Nub = new Nub { Origin = Anchor.TopCentre, RelativePositionAxes = Axes.X,