mirror of https://github.com/ppy/osu
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>
|
||||
{
|
||||
private readonly Bindable<Color4> accentColour = new Bindable<Color4>();
|
||||
protected readonly Bindable<Color4> AccentColourBindable = new Bindable<Color4>();
|
||||
|
||||
public Color4 AccentColour
|
||||
{
|
||||
get => accentColour.Value;
|
||||
set => accentColour.Value = value;
|
||||
get => AccentColourBindable.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;
|
||||
|
@ -67,24 +75,10 @@ public OsuTabControl()
|
|||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours)
|
||||
{
|
||||
if (accentColour.Value == default)
|
||||
if (AccentColour == default)
|
||||
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
|
||||
{
|
||||
get => strip.Colour;
|
||||
|
|
|
@ -37,10 +37,10 @@ protected OverlayTabControl()
|
|||
});
|
||||
}
|
||||
|
||||
protected override void OnAccentColourChanged(ValueChangedEvent<Color4> colour)
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.OnAccentColourChanged(colour);
|
||||
bar.Colour = colour.NewValue;
|
||||
base.LoadComplete();
|
||||
AccentColourBindable.BindValueChanged(colour => bar.Colour = colour.NewValue, true);
|
||||
}
|
||||
|
||||
protected override Dropdown<T> CreateDropdown() => null;
|
||||
|
|
Loading…
Reference in New Issue