mirror of
https://github.com/ppy/osu.git
synced 2025-01-30 00:53:10 +08:00
Refactor OsuTabControl.AccentColour
This commit is contained in:
parent
34ffbcf2ae
commit
738980e3f7
@ -22,12 +22,20 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
{
|
{
|
||||||
public class OsuTabControl<T> : TabControl<T>
|
public class OsuTabControl<T> : TabControl<T>
|
||||||
{
|
{
|
||||||
private readonly Bindable<Color4> accentColour = new Bindable<Color4>();
|
protected readonly Bindable<Color4> AccentColourBindable = new Bindable<Color4>();
|
||||||
|
|
||||||
public Color4 AccentColour
|
public Color4 AccentColour
|
||||||
{
|
{
|
||||||
get => accentColour.Value;
|
get => AccentColourBindable.Value;
|
||||||
set => accentColour.Value = value;
|
set
|
||||||
|
{
|
||||||
|
AccentColourBindable.Value = value;
|
||||||
|
|
||||||
|
if (Dropdown is IHasAccentColour dropdown)
|
||||||
|
dropdown.AccentColour = value;
|
||||||
|
foreach (var i in TabContainer.Children.OfType<IHasAccentColour>())
|
||||||
|
i.AccentColour = value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private readonly Box strip;
|
private readonly Box strip;
|
||||||
@ -67,24 +75,10 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(OsuColour colours)
|
private void load(OsuColour colours)
|
||||||
{
|
{
|
||||||
if (accentColour.Value == default)
|
if (AccentColour == default)
|
||||||
AccentColour = colours.Blue;
|
AccentColour = colours.Blue;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void LoadComplete()
|
|
||||||
{
|
|
||||||
base.LoadComplete();
|
|
||||||
accentColour.BindValueChanged(OnAccentColourChanged, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected virtual void OnAccentColourChanged(ValueChangedEvent<Color4> colour)
|
|
||||||
{
|
|
||||||
if (Dropdown is IHasAccentColour dropdown)
|
|
||||||
dropdown.AccentColour = colour.NewValue;
|
|
||||||
foreach (var i in TabContainer.Children.OfType<IHasAccentColour>())
|
|
||||||
i.AccentColour = colour.NewValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Color4 StripColour
|
public Color4 StripColour
|
||||||
{
|
{
|
||||||
get => strip.Colour;
|
get => strip.Colour;
|
||||||
|
@ -37,10 +37,10 @@ namespace osu.Game.Overlays
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnAccentColourChanged(ValueChangedEvent<Color4> colour)
|
protected override void LoadComplete()
|
||||||
{
|
{
|
||||||
base.OnAccentColourChanged(colour);
|
base.LoadComplete();
|
||||||
bar.Colour = colour.NewValue;
|
AccentColourBindable.BindValueChanged(colour => bar.Colour = colour.NewValue, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override Dropdown<T> CreateDropdown() => null;
|
protected override Dropdown<T> CreateDropdown() => null;
|
||||||
|
Loading…
Reference in New Issue
Block a user