mirror of
https://github.com/ppy/osu.git
synced 2025-01-28 04:42:58 +08:00
Move Enabled/Disabled state logic to the OverlayRulesetTabItem
This commit is contained in:
parent
ad7f7343d7
commit
4abd9cb89a
@ -18,8 +18,6 @@ namespace osu.Game.Overlays.BeatmapSet
|
|||||||
{
|
{
|
||||||
public readonly Bindable<BeatmapSetInfo> BeatmapSet = new Bindable<BeatmapSetInfo>();
|
public readonly Bindable<BeatmapSetInfo> BeatmapSet = new Bindable<BeatmapSetInfo>();
|
||||||
|
|
||||||
public override bool PropagatePositionalInputSubTree => Enabled.Value && !Active.Value && base.PropagatePositionalInputSubTree;
|
|
||||||
|
|
||||||
[Resolved]
|
[Resolved]
|
||||||
private OverlayColourProvider colourProvider { get; set; }
|
private OverlayColourProvider colourProvider { get; set; }
|
||||||
|
|
||||||
@ -73,17 +71,6 @@ namespace osu.Game.Overlays.BeatmapSet
|
|||||||
|
|
||||||
Enabled.Value = beatmapsCount > 0;
|
Enabled.Value = beatmapsCount > 0;
|
||||||
}, true);
|
}, true);
|
||||||
|
|
||||||
Enabled.BindValueChanged(enabled =>
|
|
||||||
{
|
|
||||||
if (enabled.NewValue)
|
|
||||||
{
|
|
||||||
UpdateState();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
AccentColour = colourProvider.Foreground1;
|
|
||||||
}, true);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,8 @@ namespace osu.Game.Overlays
|
|||||||
{
|
{
|
||||||
public class OverlayRulesetTabItem : TabItem<RulesetInfo>
|
public class OverlayRulesetTabItem : TabItem<RulesetInfo>
|
||||||
{
|
{
|
||||||
|
public override bool PropagatePositionalInputSubTree => Enabled.Value && !Active.Value && base.PropagatePositionalInputSubTree;
|
||||||
|
|
||||||
private Color4 accentColour;
|
private Color4 accentColour;
|
||||||
|
|
||||||
protected virtual Color4 AccentColour
|
protected virtual Color4 AccentColour
|
||||||
@ -61,37 +63,35 @@ namespace osu.Game.Overlays
|
|||||||
Enabled.Value = true;
|
Enabled.Value = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
protected override void LoadComplete()
|
||||||
private void load()
|
|
||||||
{
|
{
|
||||||
UpdateState();
|
base.LoadComplete();
|
||||||
|
Enabled.BindValueChanged(_ => updateState(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override bool OnHover(HoverEvent e)
|
protected override bool OnHover(HoverEvent e)
|
||||||
{
|
{
|
||||||
base.OnHover(e);
|
base.OnHover(e);
|
||||||
UpdateState();
|
updateState();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnHoverLost(HoverLostEvent e)
|
protected override void OnHoverLost(HoverLostEvent e)
|
||||||
{
|
{
|
||||||
base.OnHoverLost(e);
|
base.OnHoverLost(e);
|
||||||
UpdateState();
|
updateState();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnActivated() => UpdateState();
|
protected override void OnActivated() => updateState();
|
||||||
|
|
||||||
protected override void OnDeactivated() => UpdateState();
|
protected override void OnDeactivated() => updateState();
|
||||||
|
|
||||||
protected void UpdateState()
|
private void updateState()
|
||||||
{
|
{
|
||||||
text.Font = text.Font.With(weight: Active.Value ? FontWeight.Bold : FontWeight.Medium);
|
text.Font = text.Font.With(weight: Active.Value ? FontWeight.Bold : FontWeight.Medium);
|
||||||
|
AccentColour = IsHovered || Active.Value ? Color4.White : getStateColour();
|
||||||
if (!Enabled.Value)
|
|
||||||
return;
|
|
||||||
|
|
||||||
AccentColour = IsHovered || Active.Value ? Color4.White : colourProvider.Highlight1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Color4 getStateColour() => Enabled.Value ? colourProvider.Highlight1 : colourProvider.Foreground1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user