diff --git a/osu.Game/Graphics/UserInterface/OsuTabControl.cs b/osu.Game/Graphics/UserInterface/OsuTabControl.cs index 51df8e7830..d03fb474b8 100644 --- a/osu.Game/Graphics/UserInterface/OsuTabControl.cs +++ b/osu.Game/Graphics/UserInterface/OsuTabControl.cs @@ -2,6 +2,8 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System; +using OpenTK.Graphics; +using osu.Framework.Allocation; using osu.Framework.Graphics.UserInterface.Tab; namespace osu.Game.Graphics.UserInterface @@ -20,5 +22,25 @@ namespace osu.Game.Graphics.UserInterface foreach (var val in (T[])Enum.GetValues(typeof(T))) AddTab(val); } + + [BackgroundDependencyLoader] + private void load(OsuColour colours) + { + if (accentColour == null) + AccentColour = colours.Blue; + } + + private Color4? accentColour; + public Color4 AccentColour + { + get { return accentColour.GetValueOrDefault(); } + set + { + accentColour = value; + (DropDown as OsuTabDropDownMenu).AccentColour = value; + foreach (OsuTabItem item in TabContainer.Children) + item.AccentColour = value; + } + } } } diff --git a/osu.Game/Graphics/UserInterface/OsuTabDropDownMenu.cs b/osu.Game/Graphics/UserInterface/OsuTabDropDownMenu.cs index 57f298513a..51e7009e45 100644 --- a/osu.Game/Graphics/UserInterface/OsuTabDropDownMenu.cs +++ b/osu.Game/Graphics/UserInterface/OsuTabDropDownMenu.cs @@ -9,8 +9,6 @@ using osu.Framework.Graphics.Primitives; using osu.Framework.Graphics.Transforms; using osu.Framework.Graphics.UserInterface; using osu.Framework.Graphics.UserInterface.Tab; -using osu.Game.Graphics; -using osu.Game.Screens.Select.Filter; namespace osu.Game.Graphics.UserInterface { @@ -19,9 +17,26 @@ namespace osu.Game.Graphics.UserInterface public override float HeaderWidth => 14; public override float HeaderHeight => 24; - protected override DropDownHeader CreateHeader() => new OsuTabDropDownHeader(); + private Color4? accentColour; + public Color4 AccentColour + { + get { return accentColour.GetValueOrDefault(); } + set + { + accentColour = value; + Header.Colour = value; + foreach (OsuTabDropDownMenuItem item in ItemList) + item.AccentColour = value; + } + } - protected override DropDownMenuItem CreateDropDownItem(string key, T value) => new OsuTabDropDownMenuItem(key, value); + protected override DropDownHeader CreateHeader() => new OsuTabDropDownHeader + { + Colour = AccentColour + }; + + protected override DropDownMenuItem CreateDropDownItem(string key, T value) => + new OsuTabDropDownMenuItem(key, value) { AccentColour = AccentColour }; public OsuTabDropDownMenu() { @@ -50,7 +65,8 @@ namespace osu.Game.Graphics.UserInterface [BackgroundDependencyLoader] private void load(OsuColour colours) { - Header.Colour = typeof(T) == typeof(SortMode) ? colours.GreenLight : colours.Blue; + if (accentColour == null) + AccentColour = colours.Blue; } } } diff --git a/osu.Game/Graphics/UserInterface/OsuTabDropDownMenuItem.cs b/osu.Game/Graphics/UserInterface/OsuTabDropDownMenuItem.cs index 130e026ab4..1df57e3ac6 100644 --- a/osu.Game/Graphics/UserInterface/OsuTabDropDownMenuItem.cs +++ b/osu.Game/Graphics/UserInterface/OsuTabDropDownMenuItem.cs @@ -6,10 +6,8 @@ using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Primitives; using osu.Framework.Graphics.UserInterface; -using osu.Game.Graphics; using OpenTK.Graphics; using osu.Game.Graphics.Sprites; -using osu.Game.Screens.Select.Filter; namespace osu.Game.Graphics.UserInterface { @@ -30,23 +28,27 @@ namespace osu.Game.Graphics.UserInterface }); } + private Color4? accentColour; + public Color4 AccentColour + { + get { return accentColour.Value; } + set + { + accentColour = value; + BackgroundColourHover = BackgroundColourSelected = value; + FormatBackground(); + FormatForeground(); + } + } + [BackgroundDependencyLoader] private void load(OsuColour colours) { BackgroundColour = Color4.Black.Opacity(0f); ForegroundColourHover = Color4.Black; ForegroundColourSelected = Color4.Black; - - if (typeof(T) == typeof(SortMode)) - { - BackgroundColourHover = colours.GreenLight; - BackgroundColourSelected = colours.GreenLight; - } - else - { - BackgroundColourHover = colours.Blue; - BackgroundColourSelected = colours.Blue; - } + if (accentColour == null) + AccentColour = colours.Blue; } } } diff --git a/osu.Game/Graphics/UserInterface/OsuTabItem.cs b/osu.Game/Graphics/UserInterface/OsuTabItem.cs index 8b62829df3..ca4b70d5d8 100644 --- a/osu.Game/Graphics/UserInterface/OsuTabItem.cs +++ b/osu.Game/Graphics/UserInterface/OsuTabItem.cs @@ -10,9 +10,7 @@ using osu.Framework.Graphics.Primitives; using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.UserInterface.Tab; using osu.Framework.Input; -using osu.Game.Graphics; using osu.Game.Graphics.Sprites; -using osu.Game.Screens.Select.Filter; namespace osu.Game.Graphics.UserInterface { @@ -20,7 +18,18 @@ namespace osu.Game.Graphics.UserInterface { private SpriteText text; private Box box; - private Color4 fadeColour; + + private Color4? accentColour; + public Color4 AccentColour + { + get { return accentColour.GetValueOrDefault(); } + set + { + accentColour = value; + if (!Active) + text.Colour = value; + } + } public new T Value { @@ -54,16 +63,18 @@ namespace osu.Game.Graphics.UserInterface private void fadeInactive() { box.FadeOut(300); - text.FadeColour(fadeColour, 300); + text.FadeColour(AccentColour, 300); } - protected override bool OnHover(InputState state) { + protected override bool OnHover(InputState state) + { if (!Active) fadeActive(); return true; } - protected override void OnHoverLost(InputState state) { + protected override void OnHoverLost(InputState state) + { if (!Active) fadeInactive(); } @@ -94,18 +105,8 @@ namespace osu.Game.Graphics.UserInterface [BackgroundDependencyLoader] private void load(OsuColour colours) { - if (typeof(T) == typeof(SortMode)) - { - fadeColour = colours.GreenLight; - if (!Active) - text.Colour = colours.GreenLight; - } - else - { - fadeColour = colours.Blue; - if (!Active) - text.Colour = colours.Blue; - } + if (accentColour == null) + AccentColour = colours.Blue; } } } diff --git a/osu.Game/Screens/Select/FilterControl.cs b/osu.Game/Screens/Select/FilterControl.cs index 7bf237d378..a162579b96 100644 --- a/osu.Game/Screens/Select/FilterControl.cs +++ b/osu.Game/Screens/Select/FilterControl.cs @@ -23,6 +23,8 @@ namespace osu.Game.Screens.Select public Action FilterChanged; public string Search => searchTextBox.Text; + + private OsuTabControl sortTabs; private SortMode sort = SortMode.Title; public SortMode Sort @@ -60,7 +62,6 @@ namespace osu.Game.Screens.Select public FilterControl(float height) { - TabControl sortTabs; TabControl groupTabs; Children = new Drawable[] @@ -134,7 +135,7 @@ namespace osu.Game.Screens.Select sortTabs = new OsuTabControl(87) { Width = 191, - AutoSort = true + AutoSort = true, } } } @@ -164,7 +165,7 @@ namespace osu.Game.Screens.Select [BackgroundDependencyLoader] private void load(OsuColour colours) { - spriteText.Colour = colours.GreenLight; + sortTabs.AccentColour = spriteText.Colour = colours.GreenLight; } } } \ No newline at end of file