From d205483a36fcb6f4b77f524163d6f19263ec3b27 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= <dach.bartlomiej@gmail.com>
Date: Wed, 13 Oct 2021 21:57:34 +0200
Subject: [PATCH] Revert `ThemedDropdown`-related changes

---
 .../Graphics/Containers/OsuScrollContainer.cs | 67 +++----------------
 .../UserInterfaceV2/ThemedDropdown.cs         | 54 ---------------
 .../UserInterfaceV2/ThemedEnumDropdown.cs     | 16 -----
 .../Overlays/Settings/SettingsDropdown.cs     |  3 +-
 .../Overlays/Settings/SettingsEnumDropdown.cs |  3 +-
 5 files changed, 11 insertions(+), 132 deletions(-)
 delete mode 100644 osu.Game/Graphics/UserInterfaceV2/ThemedDropdown.cs
 delete mode 100644 osu.Game/Graphics/UserInterfaceV2/ThemedEnumDropdown.cs

diff --git a/osu.Game/Graphics/Containers/OsuScrollContainer.cs b/osu.Game/Graphics/Containers/OsuScrollContainer.cs
index f78f9deac1..aaad72f65c 100644
--- a/osu.Game/Graphics/Containers/OsuScrollContainer.cs
+++ b/osu.Game/Graphics/Containers/OsuScrollContainer.cs
@@ -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);
-            }
         }
     }
 }
diff --git a/osu.Game/Graphics/UserInterfaceV2/ThemedDropdown.cs b/osu.Game/Graphics/UserInterfaceV2/ThemedDropdown.cs
deleted file mode 100644
index ec96c23034..0000000000
--- a/osu.Game/Graphics/UserInterfaceV2/ThemedDropdown.cs
+++ /dev/null
@@ -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;
-            }
-        }
-    }
-}
diff --git a/osu.Game/Graphics/UserInterfaceV2/ThemedEnumDropdown.cs b/osu.Game/Graphics/UserInterfaceV2/ThemedEnumDropdown.cs
deleted file mode 100644
index 5210c03bb9..0000000000
--- a/osu.Game/Graphics/UserInterfaceV2/ThemedEnumDropdown.cs
+++ /dev/null
@@ -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));
-        }
-    }
-}
diff --git a/osu.Game/Overlays/Settings/SettingsDropdown.cs b/osu.Game/Overlays/Settings/SettingsDropdown.cs
index c48a4f5ccc..a281d03ee7 100644
--- a/osu.Game/Overlays/Settings/SettingsDropdown.cs
+++ b/osu.Game/Overlays/Settings/SettingsDropdown.cs
@@ -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()
             {
diff --git a/osu.Game/Overlays/Settings/SettingsEnumDropdown.cs b/osu.Game/Overlays/Settings/SettingsEnumDropdown.cs
index b901e8d719..199ba14b48 100644
--- a/osu.Game/Overlays/Settings/SettingsEnumDropdown.cs
+++ b/osu.Game/Overlays/Settings/SettingsEnumDropdown.cs
@@ -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()
             {