mirror of
https://github.com/ppy/osu.git
synced 2024-11-06 09:07:25 +08:00
7c5bd2db7b
This is to accommodate `SettingsDropdown` usages without an available `OverlayColourProvider`, such as mod settings controls and tournament client usages.
55 lines
1.8 KiB
C#
55 lines
1.8 KiB
C#
// 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 enable
|
|
|
|
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, if one is available.
|
|
/// </summary>
|
|
public class ThemedDropdown<T> : OsuDropdown<T>
|
|
{
|
|
[BackgroundDependencyLoader(true)]
|
|
private void load(OverlayColourProvider? colourProvider)
|
|
{
|
|
if (colourProvider == null) return;
|
|
|
|
AccentColour = colourProvider.Light4;
|
|
}
|
|
|
|
protected override DropdownHeader CreateHeader() => new ThemedDropdownHeader();
|
|
|
|
protected override DropdownMenu CreateMenu() => new ThemedDropdownMenu();
|
|
|
|
protected class ThemedDropdownMenu : OsuDropdownMenu
|
|
{
|
|
[BackgroundDependencyLoader(true)]
|
|
private void load(OverlayColourProvider? colourProvider)
|
|
{
|
|
if (colourProvider == null) return;
|
|
|
|
BackgroundColour = colourProvider.Background5;
|
|
((IHasAccentColour)ContentContainer).AccentColour = colourProvider.Highlight1;
|
|
}
|
|
}
|
|
|
|
protected class ThemedDropdownHeader : OsuDropdownHeader
|
|
{
|
|
[BackgroundDependencyLoader(true)]
|
|
private void load(OverlayColourProvider? colourProvider)
|
|
{
|
|
if (colourProvider == null) return;
|
|
|
|
BackgroundColour = colourProvider.Background5;
|
|
BackgroundColourHover = colourProvider.Light4;
|
|
}
|
|
}
|
|
}
|
|
}
|