mirror of
https://github.com/ppy/osu.git
synced 2026-05-31 06:29:54 +08:00
Add "themed" dropdown variant and use in settings sidebar
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user