mirror of
https://github.com/ppy/osu.git
synced 2025-02-15 15:23:14 +08:00
Improve feel of settings toolbox group
This commit is contained in:
parent
ebc1088457
commit
0f4a2a6059
@ -5,12 +5,14 @@
|
||||
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Graphics.UserInterfaceV2;
|
||||
using osu.Game.Overlays;
|
||||
using osu.Game.Overlays.Settings;
|
||||
using osuTK;
|
||||
using osuTK.Input;
|
||||
|
||||
namespace osu.Game.Tests.Visual.UserInterface
|
||||
@ -20,11 +22,17 @@ namespace osu.Game.Tests.Visual.UserInterface
|
||||
{
|
||||
private SettingsToolboxGroup group;
|
||||
|
||||
[Cached]
|
||||
private OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Blue);
|
||||
|
||||
[SetUp]
|
||||
public void SetUp() => Schedule(() =>
|
||||
{
|
||||
Child = group = new SettingsToolboxGroup("example")
|
||||
{
|
||||
Scale = new Vector2(3),
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new RoundedButton
|
||||
|
@ -1,8 +1,7 @@
|
||||
// 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.
|
||||
|
||||
#nullable disable
|
||||
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Caching;
|
||||
using osu.Framework.Extensions.EnumExtensions;
|
||||
@ -23,25 +22,40 @@ namespace osu.Game.Overlays
|
||||
{
|
||||
public class SettingsToolboxGroup : Container, IExpandable
|
||||
{
|
||||
private readonly string title;
|
||||
public const int CONTAINER_WIDTH = 270;
|
||||
|
||||
private const float transition_duration = 250;
|
||||
private const int border_thickness = 2;
|
||||
private const int header_height = 30;
|
||||
private const int corner_radius = 5;
|
||||
|
||||
private const float fade_duration = 800;
|
||||
private const float inactive_alpha = 0.5f;
|
||||
|
||||
private readonly Cached headerTextVisibilityCache = new Cached();
|
||||
|
||||
private readonly FillFlowContainer content;
|
||||
protected override Container<Drawable> Content => content;
|
||||
|
||||
private readonly FillFlowContainer content = new FillFlowContainer
|
||||
{
|
||||
Name = @"Content",
|
||||
Origin = Anchor.TopCentre,
|
||||
Anchor = Anchor.TopCentre,
|
||||
Direction = FillDirection.Vertical,
|
||||
RelativeSizeAxes = Axes.X,
|
||||
AutoSizeDuration = transition_duration,
|
||||
AutoSizeEasing = Easing.OutQuint,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
Padding = new MarginPadding { Horizontal = 10, Top = 5, Bottom = 10 },
|
||||
Spacing = new Vector2(0, 15),
|
||||
};
|
||||
|
||||
public BindableBool Expanded { get; } = new BindableBool(true);
|
||||
|
||||
private readonly OsuSpriteText headerText;
|
||||
private OsuSpriteText headerText = null!;
|
||||
|
||||
private readonly Container headerContent;
|
||||
private Container headerContent = null!;
|
||||
|
||||
private Box background = null!;
|
||||
|
||||
private IconButton expandButton = null!;
|
||||
|
||||
/// <summary>
|
||||
/// Create a new instance.
|
||||
@ -49,20 +63,24 @@ namespace osu.Game.Overlays
|
||||
/// <param name="title">The title to be displayed in the header of this group.</param>
|
||||
public SettingsToolboxGroup(string title)
|
||||
{
|
||||
this.title = title;
|
||||
|
||||
AutoSizeAxes = Axes.Y;
|
||||
Width = CONTAINER_WIDTH;
|
||||
Masking = true;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OverlayColourProvider colourProvider)
|
||||
{
|
||||
CornerRadius = corner_radius;
|
||||
BorderColour = Color4.Black;
|
||||
BorderThickness = border_thickness;
|
||||
|
||||
InternalChildren = new Drawable[]
|
||||
{
|
||||
new Box
|
||||
background = new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = Color4.Black,
|
||||
Alpha = 0.5f,
|
||||
Colour = colourProvider.Background5,
|
||||
},
|
||||
new FillFlowContainer
|
||||
{
|
||||
@ -88,7 +106,7 @@ namespace osu.Game.Overlays
|
||||
Font = OsuFont.GetFont(weight: FontWeight.Bold, size: 17),
|
||||
Padding = new MarginPadding { Left = 10, Right = 30 },
|
||||
},
|
||||
new IconButton
|
||||
expandButton = new IconButton
|
||||
{
|
||||
Origin = Anchor.Centre,
|
||||
Anchor = Anchor.CentreRight,
|
||||
@ -99,19 +117,7 @@ namespace osu.Game.Overlays
|
||||
},
|
||||
}
|
||||
},
|
||||
content = new FillFlowContainer
|
||||
{
|
||||
Name = @"Content",
|
||||
Origin = Anchor.TopCentre,
|
||||
Anchor = Anchor.TopCentre,
|
||||
Direction = FillDirection.Vertical,
|
||||
RelativeSizeAxes = Axes.X,
|
||||
AutoSizeDuration = transition_duration,
|
||||
AutoSizeEasing = Easing.OutQuint,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
Padding = new MarginPadding(15),
|
||||
Spacing = new Vector2(0, 15),
|
||||
}
|
||||
content
|
||||
}
|
||||
},
|
||||
};
|
||||
@ -175,9 +181,10 @@ namespace osu.Game.Overlays
|
||||
|
||||
private void updateFadeState()
|
||||
{
|
||||
this.FadeTo(IsHovered ? 1 : inactive_alpha, fade_duration, Easing.OutQuint);
|
||||
}
|
||||
const float fade_duration = 500;
|
||||
|
||||
protected override Container<Drawable> Content => content;
|
||||
background.FadeTo(IsHovered ? 1 : 0, fade_duration, Easing.OutQuint);
|
||||
expandButton.FadeTo(IsHovered ? 1 : 0, fade_duration, Easing.OutQuint);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -71,6 +71,9 @@ namespace osu.Game.Screens.Play
|
||||
private AudioFilter lowPassFilter = null!;
|
||||
private AudioFilter highPassFilter = null!;
|
||||
|
||||
[Cached]
|
||||
private OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Purple);
|
||||
|
||||
protected bool BackgroundBrightnessReduction
|
||||
{
|
||||
set
|
||||
|
Loading…
Reference in New Issue
Block a user