mirror of
https://github.com/ppy/osu.git
synced 2024-12-16 06:23:20 +08:00
Merge pull request #931 from peppy/fix-hacky-tabs
Fix hacky channel selector tab
This commit is contained in:
commit
df79fff996
@ -1 +1 @@
|
|||||||
Subproject commit e63cfd9ba44a40750dff0617ba6f08ffbfcc7fde
|
Subproject commit c80d5f53e740ffe63d9deca41749c5ba0573e744
|
@ -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 const float transition_length = 500;
|
||||||
|
|
||||||
private void fadeActive()
|
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<T>
|
private class OsuTabDropdown : OsuDropdown<T>
|
||||||
|
@ -29,21 +29,6 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
|
|
||||||
private readonly Box box;
|
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)
|
public PageTabItem(T value) : base(value)
|
||||||
{
|
{
|
||||||
AutoSizeAxes = Axes.X;
|
AutoSizeAxes = Axes.X;
|
||||||
@ -100,6 +85,10 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
{
|
{
|
||||||
box.ScaleTo(new Vector2(1f, 0f), transition_duration);
|
box.ScaleTo(new Vector2(1f, 0f), transition_duration);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void OnActivated() => slideActive();
|
||||||
|
|
||||||
|
protected override void OnDeactivated() => slideInactive();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,6 +26,8 @@ namespace osu.Game.Overlays.Chat
|
|||||||
|
|
||||||
public readonly Bindable<bool> ChannelSelectorActive = new Bindable<bool>();
|
public readonly Bindable<bool> ChannelSelectorActive = new Bindable<bool>();
|
||||||
|
|
||||||
|
private readonly ChannelTabItem.ChannelSelectorTabItem selectorTab;
|
||||||
|
|
||||||
public ChatTabControl()
|
public ChatTabControl()
|
||||||
{
|
{
|
||||||
TabContainer.Margin = new MarginPadding { Left = 50 };
|
TabContainer.Margin = new MarginPadding { Left = 50 };
|
||||||
@ -41,7 +43,22 @@ namespace osu.Game.Overlays.Chat
|
|||||||
Padding = new MarginPadding(10),
|
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<Channel> tab)
|
||||||
|
{
|
||||||
|
if (tab is ChannelTabItem.ChannelSelectorTabItem)
|
||||||
|
{
|
||||||
|
tab.Active.Toggle();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
selectorTab.Active.Value = false;
|
||||||
|
|
||||||
|
base.SelectTab(tab);
|
||||||
}
|
}
|
||||||
|
|
||||||
private class ChannelTabItem : TabItem<Channel>
|
private class ChannelTabItem : TabItem<Channel>
|
||||||
@ -56,18 +73,6 @@ namespace osu.Game.Overlays.Chat
|
|||||||
private readonly Box highlightBox;
|
private readonly Box highlightBox;
|
||||||
private readonly TextAwesome icon;
|
private readonly TextAwesome icon;
|
||||||
|
|
||||||
public override bool Active
|
|
||||||
{
|
|
||||||
get { return base.Active; }
|
|
||||||
set
|
|
||||||
{
|
|
||||||
if (Active == value) return;
|
|
||||||
|
|
||||||
base.Active = value;
|
|
||||||
updateState();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void updateState()
|
private void updateState()
|
||||||
{
|
{
|
||||||
if (Active)
|
if (Active)
|
||||||
@ -205,28 +210,8 @@ namespace osu.Game.Overlays.Chat
|
|||||||
|
|
||||||
public class ChannelSelectorTabItem : ChannelTabItem
|
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<bool> activeBindable;
|
|
||||||
|
|
||||||
public ChannelSelectorTabItem(Channel value, Bindable<bool> active) : base(value)
|
|
||||||
{
|
|
||||||
activeBindable = active;
|
|
||||||
activeBindable.ValueChanged += v => selectorUpdateState();
|
|
||||||
|
|
||||||
|
|
||||||
Depth = float.MaxValue;
|
Depth = float.MaxValue;
|
||||||
Width = 45;
|
Width = 45;
|
||||||
|
|
||||||
@ -242,27 +227,11 @@ namespace osu.Game.Overlays.Chat
|
|||||||
backgroundInactive = colour.Gray2;
|
backgroundInactive = colour.Gray2;
|
||||||
backgroundActive = colour.Gray3;
|
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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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]
|
[BackgroundDependencyLoader]
|
||||||
private void load(OsuColour colours)
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user