mirror of
https://github.com/ppy/osu.git
synced 2025-02-20 05:36:05 +08:00
Refactor color handling
colour*
This commit is contained in:
parent
db5a1e241a
commit
01cca1a4d2
@ -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<T>).AccentColour = value;
|
||||
foreach (OsuTabItem<T> item in TabContainer.Children)
|
||||
item.AccentColour = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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<T> item in ItemList)
|
||||
item.AccentColour = value;
|
||||
}
|
||||
}
|
||||
|
||||
protected override DropDownMenuItem<T> CreateDropDownItem(string key, T value) => new OsuTabDropDownMenuItem<T>(key, value);
|
||||
protected override DropDownHeader CreateHeader() => new OsuTabDropDownHeader
|
||||
{
|
||||
Colour = AccentColour
|
||||
};
|
||||
|
||||
protected override DropDownMenuItem<T> CreateDropDownItem(string key, T value) =>
|
||||
new OsuTabDropDownMenuItem<T>(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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -23,6 +23,8 @@ namespace osu.Game.Screens.Select
|
||||
public Action FilterChanged;
|
||||
|
||||
public string Search => searchTextBox.Text;
|
||||
|
||||
private OsuTabControl<SortMode> sortTabs;
|
||||
|
||||
private SortMode sort = SortMode.Title;
|
||||
public SortMode Sort
|
||||
@ -60,7 +62,6 @@ namespace osu.Game.Screens.Select
|
||||
|
||||
public FilterControl(float height)
|
||||
{
|
||||
TabControl<SortMode> sortTabs;
|
||||
TabControl<GroupMode> groupTabs;
|
||||
|
||||
Children = new Drawable[]
|
||||
@ -134,7 +135,7 @@ namespace osu.Game.Screens.Select
|
||||
sortTabs = new OsuTabControl<SortMode>(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;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user