Merge pull request #30110 from peppy/new-colour-better-ux

When adding a new combo colour, use the last colour as a starting point
This commit is contained in:
Bartłomiej Dach 2024-10-04 13:19:01 +02:00 committed by GitHub
commit 31aea86eab
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 13 additions and 1 deletions

View File

@ -3,6 +3,7 @@
using System; using System;
using System.Collections.Specialized; using System.Collections.Specialized;
using System.Linq;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Bindables; using osu.Framework.Bindables;
using osu.Framework.Extensions; using osu.Framework.Extensions;
@ -19,6 +20,7 @@
using osu.Game.Overlays; using osu.Game.Overlays;
using osu.Game.Resources.Localisation.Web; using osu.Game.Resources.Localisation.Web;
using osuTK; using osuTK;
using osuTK.Graphics;
namespace osu.Game.Graphics.UserInterfaceV2 namespace osu.Game.Graphics.UserInterfaceV2
{ {
@ -76,7 +78,7 @@ private void load()
Spacing = new Vector2(5), Spacing = new Vector2(5),
Child = button = new RoundedButton Child = button = new RoundedButton
{ {
Action = () => Colours.Add(Colour4.White), Action = addNewColour,
Size = new Vector2(70), Size = new Vector2(70),
Text = "+", Text = "+",
} }
@ -112,6 +114,16 @@ protected override void OnHoverLost(HoverLostEvent e)
updateState(); updateState();
} }
private void addNewColour()
{
Color4 startingColour = Colours.Count > 0
? Colours.Last()
: Colour4.White;
Colours.Add(startingColour);
flow.OfType<ColourButton>().Last().TriggerClick();
}
private void updateState() private void updateState()
{ {
background.Colour = colourProvider.Background5; background.Colour = colourProvider.Background5;