1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-15 14:42:56 +08:00

Add "themed" dropdown variant and use in settings sidebar

This commit is contained in:
Bartłomiej Dach 2021-10-12 21:58:43 +02:00
parent 1fba932e84
commit a2f3a7cba8
No known key found for this signature in database
GPG Key ID: BCECCD4FA41F6497
4 changed files with 65 additions and 2 deletions

View File

@ -0,0 +1,45 @@
// 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.Allocation;
using osu.Framework.Graphics.UserInterface;
using osu.Game.Graphics.UserInterface;
using osu.Game.Overlays;
namespace osu.Game.Graphics.UserInterfaceV2
{
/// <summary>
/// A variant of <see cref="OsuDropdown{T}"/> that uses the nearest <see cref="OverlayColourProvider"/> for theming purposes.
/// </summary>
public class ThemedDropdown<T> : OsuDropdown<T>
{
[BackgroundDependencyLoader]
private void load(OverlayColourProvider colourProvider)
{
AccentColour = colourProvider.Light4;
}
protected override DropdownHeader CreateHeader() => new ThemedDropdownHeader();
protected override DropdownMenu CreateMenu() => new ThemedDropdownMenu();
protected class ThemedDropdownMenu : OsuDropdownMenu
{
[BackgroundDependencyLoader]
private void load(OverlayColourProvider colourProvider)
{
BackgroundColour = colourProvider.Background5;
}
}
protected class ThemedDropdownHeader : OsuDropdownHeader
{
[BackgroundDependencyLoader]
private void load(OverlayColourProvider colourProvider)
{
BackgroundColour = colourProvider.Background5;
BackgroundColourHover = colourProvider.Light4;
}
}
}
}

View File

@ -0,0 +1,16 @@
// 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 System;
namespace osu.Game.Graphics.UserInterfaceV2
{
public class ThemedEnumDropdown<T> : ThemedDropdown<T>
where T : struct, Enum
{
public ThemedEnumDropdown()
{
Items = (T[])Enum.GetValues(typeof(T));
}
}
}

View File

@ -6,6 +6,7 @@ using System.Linq;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Game.Graphics.UserInterface;
using osu.Game.Graphics.UserInterfaceV2;
using osuTK;
namespace osu.Game.Overlays.Settings
@ -37,7 +38,7 @@ namespace osu.Game.Overlays.Settings
protected virtual OsuDropdown<T> CreateDropdown() => new DropdownControl();
protected class DropdownControl : OsuDropdown<T>
protected class DropdownControl : ThemedDropdown<T>
{
public DropdownControl()
{

View File

@ -4,6 +4,7 @@
using System;
using osu.Framework.Graphics;
using osu.Game.Graphics.UserInterface;
using osu.Game.Graphics.UserInterfaceV2;
namespace osu.Game.Overlays.Settings
{
@ -12,7 +13,7 @@ namespace osu.Game.Overlays.Settings
{
protected override OsuDropdown<T> CreateDropdown() => new DropdownControl();
protected new class DropdownControl : OsuEnumDropdown<T>
protected new class DropdownControl : ThemedEnumDropdown<T>
{
public DropdownControl()
{