1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-12 17:43:05 +08:00

Remove ``RoundedNub.cs` and make `Nub.cs`` non abstract again

This commit is contained in:
mk56-spn 2023-02-03 12:19:09 +01:00
parent 8c11e8e6f4
commit e1af5e110a
6 changed files with 41 additions and 59 deletions

View File

@ -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

View File

@ -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<bool>, IHasAccentColour
public partial class Nub : Container, IHasCurrentValue<bool>, 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;
/// <summary>
/// Implements the shape for the nub, allowing for any type of container to be used.
/// </summary>
/// <returns></returns>
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);
}
}
}

View File

@ -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);

View File

@ -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}");

View File

@ -1,32 +0,0 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. 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,
};
}
}

View File

@ -17,7 +17,7 @@ namespace osu.Game.Graphics.UserInterface
public partial class RoundedSliderBar<T> : OsuSliderBar<T>
where T : struct, IEquatable<T>, IComparable<T>, 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,