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:
parent
1fba932e84
commit
a2f3a7cba8
45
osu.Game/Graphics/UserInterfaceV2/ThemedDropdown.cs
Normal file
45
osu.Game/Graphics/UserInterfaceV2/ThemedDropdown.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
16
osu.Game/Graphics/UserInterfaceV2/ThemedEnumDropdown.cs
Normal file
16
osu.Game/Graphics/UserInterfaceV2/ThemedEnumDropdown.cs
Normal 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));
|
||||
}
|
||||
}
|
||||
}
|
@ -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()
|
||||
{
|
||||
|
@ -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()
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user