mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 12:57:36 +08:00
Revert ThemedDropdown
-related changes
This commit is contained in:
parent
7c5bd2db7b
commit
d205483a36
@ -24,26 +24,11 @@ namespace osu.Game.Graphics.Containers
|
||||
}
|
||||
}
|
||||
|
||||
public class OsuScrollContainer<T> : ScrollContainer<T>, IHasAccentColour
|
||||
where T : Drawable
|
||||
public class OsuScrollContainer<T> : ScrollContainer<T> where T : Drawable
|
||||
{
|
||||
public const float SCROLL_BAR_HEIGHT = 10;
|
||||
public const float SCROLL_BAR_PADDING = 3;
|
||||
|
||||
private Color4 accentColour;
|
||||
|
||||
public Color4 AccentColour
|
||||
{
|
||||
get => accentColour;
|
||||
set
|
||||
{
|
||||
accentColour = value;
|
||||
|
||||
if (Scrollbar is IHasAccentColour accentedScrollbar)
|
||||
accentedScrollbar.AccentColour = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Allows controlling the scroll bar from any position in the container using the right mouse button.
|
||||
/// Uses the value of <see cref="DistanceDecayOnRightMouseScrollbar"/> to smoothly scroll to the dragged location.
|
||||
@ -124,27 +109,11 @@ namespace osu.Game.Graphics.Containers
|
||||
|
||||
protected override ScrollbarContainer CreateScrollbar(Direction direction) => new OsuScrollbar(direction);
|
||||
|
||||
protected class OsuScrollbar : ScrollbarContainer, IHasAccentColour
|
||||
protected class OsuScrollbar : ScrollbarContainer
|
||||
{
|
||||
private Color4 accentColour;
|
||||
|
||||
public Color4 AccentColour
|
||||
{
|
||||
get => accentColour;
|
||||
set
|
||||
{
|
||||
accentColour = value;
|
||||
|
||||
if (IsLoaded)
|
||||
updateMouseDownState();
|
||||
}
|
||||
}
|
||||
|
||||
private Color4 hoverColour;
|
||||
private Color4 defaultColour;
|
||||
|
||||
private bool mouseDown;
|
||||
private const int fade_duration = 100;
|
||||
private Color4 highlightColour;
|
||||
|
||||
private readonly Box box;
|
||||
|
||||
@ -177,15 +146,7 @@ namespace osu.Game.Graphics.Containers
|
||||
{
|
||||
Colour = defaultColour = colours.Gray8;
|
||||
hoverColour = colours.GrayF;
|
||||
AccentColour = colours.Green;
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
updateHoverState();
|
||||
updateMouseDownState();
|
||||
highlightColour = colours.Green;
|
||||
}
|
||||
|
||||
public override void ResizeTo(float val, int duration = 0, Easing easing = Easing.None)
|
||||
@ -199,24 +160,21 @@ namespace osu.Game.Graphics.Containers
|
||||
|
||||
protected override bool OnHover(HoverEvent e)
|
||||
{
|
||||
updateHoverState(fade_duration);
|
||||
this.FadeColour(hoverColour, 100);
|
||||
return true;
|
||||
}
|
||||
|
||||
protected override void OnHoverLost(HoverLostEvent e)
|
||||
{
|
||||
updateHoverState(fade_duration);
|
||||
this.FadeColour(defaultColour, 100);
|
||||
}
|
||||
|
||||
private void updateHoverState(double duration = 0) => this.FadeColour(IsHovered ? hoverColour : defaultColour, duration);
|
||||
|
||||
protected override bool OnMouseDown(MouseDownEvent e)
|
||||
{
|
||||
if (!base.OnMouseDown(e)) return false;
|
||||
|
||||
mouseDown = true;
|
||||
updateMouseDownState(fade_duration);
|
||||
|
||||
// note that we are changing the colour of the box here as to not interfere with the hover effect.
|
||||
box.FadeColour(highlightColour, 100);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -224,17 +182,10 @@ namespace osu.Game.Graphics.Containers
|
||||
{
|
||||
if (e.Button != MouseButton.Left) return;
|
||||
|
||||
mouseDown = false;
|
||||
updateMouseDownState(fade_duration);
|
||||
box.FadeColour(Color4.White, 100);
|
||||
|
||||
base.OnMouseUp(e);
|
||||
}
|
||||
|
||||
private void updateMouseDownState(double duration = 0)
|
||||
{
|
||||
// note that we are changing the colour of the box here as to not interfere with the hover effect.
|
||||
box.FadeColour(mouseDown ? AccentColour : Color4.White, duration);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,54 +0,0 @@
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,16 +0,0 @@
|
||||
// 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,7 +6,6 @@ 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
|
||||
@ -38,7 +37,7 @@ namespace osu.Game.Overlays.Settings
|
||||
|
||||
protected virtual OsuDropdown<T> CreateDropdown() => new DropdownControl();
|
||||
|
||||
protected class DropdownControl : ThemedDropdown<T>
|
||||
protected class DropdownControl : OsuDropdown<T>
|
||||
{
|
||||
public DropdownControl()
|
||||
{
|
||||
|
@ -4,7 +4,6 @@
|
||||
using System;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Graphics.UserInterfaceV2;
|
||||
|
||||
namespace osu.Game.Overlays.Settings
|
||||
{
|
||||
@ -13,7 +12,7 @@ namespace osu.Game.Overlays.Settings
|
||||
{
|
||||
protected override OsuDropdown<T> CreateDropdown() => new DropdownControl();
|
||||
|
||||
protected new class DropdownControl : ThemedEnumDropdown<T>
|
||||
protected new class DropdownControl : OsuEnumDropdown<T>
|
||||
{
|
||||
public DropdownControl()
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user