diff --git a/osu-framework b/osu-framework index e63cfd9ba4..c80d5f53e7 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit e63cfd9ba44a40750dff0617ba6f08ffbfcc7fde +Subproject commit c80d5f53e740ffe63d9deca41749c5ba0573e744 diff --git a/osu.Game/Graphics/UserInterface/OsuTabControl.cs b/osu.Game/Graphics/UserInterface/OsuTabControl.cs index 4bbae4efd1..6f955b1696 100644 --- a/osu.Game/Graphics/UserInterface/OsuTabControl.cs +++ b/osu.Game/Graphics/UserInterface/OsuTabControl.cs @@ -74,21 +74,6 @@ namespace osu.Game.Graphics.UserInterface } } - public override bool Active - { - get { return base.Active; } - set - { - if (Active == value) return; - - if (value) - fadeActive(); - else - fadeInactive(); - base.Active = value; - } - } - private const float transition_length = 500; private void fadeActive() @@ -150,6 +135,10 @@ namespace osu.Game.Graphics.UserInterface } }; } + + protected override void OnActivated() => fadeActive(); + + protected override void OnDeactivated() => fadeInactive(); } private class OsuTabDropdown : OsuDropdown diff --git a/osu.Game/Graphics/UserInterface/PageTabControl.cs b/osu.Game/Graphics/UserInterface/PageTabControl.cs index 8bf455b099..993ac4a238 100644 --- a/osu.Game/Graphics/UserInterface/PageTabControl.cs +++ b/osu.Game/Graphics/UserInterface/PageTabControl.cs @@ -29,21 +29,6 @@ namespace osu.Game.Graphics.UserInterface private readonly Box box; - public override bool Active - { - get { return base.Active; } - set - { - if (Active == value) return; - - if (value) - slideActive(); - else - slideInactive(); - base.Active = value; - } - } - public PageTabItem(T value) : base(value) { AutoSizeAxes = Axes.X; @@ -100,6 +85,10 @@ namespace osu.Game.Graphics.UserInterface { box.ScaleTo(new Vector2(1f, 0f), transition_duration); } + + protected override void OnActivated() => slideActive(); + + protected override void OnDeactivated() => slideInactive(); } } } diff --git a/osu.Game/Overlays/Chat/ChatTabControl.cs b/osu.Game/Overlays/Chat/ChatTabControl.cs index 7436c9fd85..1bc1daa599 100644 --- a/osu.Game/Overlays/Chat/ChatTabControl.cs +++ b/osu.Game/Overlays/Chat/ChatTabControl.cs @@ -26,6 +26,8 @@ namespace osu.Game.Overlays.Chat public readonly Bindable ChannelSelectorActive = new Bindable(); + private readonly ChannelTabItem.ChannelSelectorTabItem selectorTab; + public ChatTabControl() { TabContainer.Margin = new MarginPadding { Left = 50 }; @@ -41,7 +43,22 @@ namespace osu.Game.Overlays.Chat Padding = new MarginPadding(10), }); - AddTabItem(new ChannelTabItem.ChannelSelectorTabItem(new Channel { Name = "+" }, ChannelSelectorActive)); + AddTabItem(selectorTab = new ChannelTabItem.ChannelSelectorTabItem(new Channel { Name = "+" })); + + ChannelSelectorActive.BindTo(selectorTab.Active); + } + + protected override void SelectTab(TabItem tab) + { + if (tab is ChannelTabItem.ChannelSelectorTabItem) + { + tab.Active.Toggle(); + return; + } + + selectorTab.Active.Value = false; + + base.SelectTab(tab); } private class ChannelTabItem : TabItem @@ -56,18 +73,6 @@ namespace osu.Game.Overlays.Chat private readonly Box highlightBox; private readonly TextAwesome icon; - public override bool Active - { - get { return base.Active; } - set - { - if (Active == value) return; - - base.Active = value; - updateState(); - } - } - private void updateState() { if (Active) @@ -205,28 +210,8 @@ namespace osu.Game.Overlays.Chat public class ChannelSelectorTabItem : ChannelTabItem { - public override bool Active + public ChannelSelectorTabItem(Channel value) : base(value) { - get { return false; } - // ReSharper disable once ValueParameterNotUsed - set - { - // we basically never want this tab to become active. - // this allows us to become a "toggle" tab. - // is a bit hacky, to say the least. - activeBindable.Value = !activeBindable.Value; - base.Active = false; - } - } - - private readonly Bindable activeBindable; - - public ChannelSelectorTabItem(Channel value, Bindable active) : base(value) - { - activeBindable = active; - activeBindable.ValueChanged += v => selectorUpdateState(); - - Depth = float.MaxValue; Width = 45; @@ -242,27 +227,11 @@ namespace osu.Game.Overlays.Chat backgroundInactive = colour.Gray2; backgroundActive = colour.Gray3; } - - protected override void LoadComplete() - { - base.LoadComplete(); - - selectorUpdateState(); - } - - protected override void OnHoverLost(InputState state) - { - selectorUpdateState(); - } - - private void selectorUpdateState() - { - if (activeBindable.Value) - fadeActive(); - else - fadeInactive(); - } } + + protected override void OnActivated() => updateState(); + + protected override void OnDeactivated() => updateState(); } } } diff --git a/osu.Game/Screens/Ranking/ResultModeButton.cs b/osu.Game/Screens/Ranking/ResultModeButton.cs index 7e7a32b3f0..cc1dbbe444 100644 --- a/osu.Game/Screens/Ranking/ResultModeButton.cs +++ b/osu.Game/Screens/Ranking/ResultModeButton.cs @@ -36,19 +36,6 @@ namespace osu.Game.Screens.Ranking } } - public override bool Active - { - get - { - return base.Active; - } - set - { - base.Active = value; - colouredPart.FadeColour(Active ? activeColour : inactiveColour, 200, EasingTypes.OutQuint); - } - } - [BackgroundDependencyLoader] private void load(OsuColour colours) { @@ -104,5 +91,9 @@ namespace osu.Game.Screens.Ranking } }; } + + protected override void OnActivated() => colouredPart.FadeColour(activeColour, 200, EasingTypes.OutQuint); + + protected override void OnDeactivated() => colouredPart.FadeColour(inactiveColour, 200, EasingTypes.OutQuint); } }