1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-19 03:23:05 +08:00

use AddTabItem instead + Bindable for ChannelSelectorTabItem

This commit is contained in:
Jorolf 2017-05-19 11:59:23 +02:00
parent 0e3fb55d5e
commit 94484974f9
2 changed files with 22 additions and 18 deletions

View File

@ -14,15 +14,20 @@ using osu.Game.Graphics.UserInterface;
using osu.Game.Online.Chat;
using OpenTK;
using OpenTK.Graphics;
using osu.Framework.Configuration;
namespace osu.Game.Overlays.Chat
{
public class ChatTabControl : OsuTabControl<Channel>
{
protected override TabItem<Channel> CreateTabItem(Channel value) => value.Id == ChatOverlay.CHANNEL_SELECTOR_ID ? new ChannelTabItem.ChannelSelectorTabItem(value) : new ChannelTabItem(value);
protected override TabItem<Channel> CreateTabItem(Channel value) => new ChannelTabItem(value);
private const float shear_width = 10;
private Bindable<bool> channelSelectorActive = new Bindable<bool>();
public Bindable<bool> ChannelSelectorActive => channelSelectorActive;
public ChatTabControl()
{
TabContainer.Margin = new MarginPadding { Left = 50 };
@ -38,10 +43,7 @@ namespace osu.Game.Overlays.Chat
Padding = new MarginPadding(10),
});
AddItem(new Channel
{
Id = ChatOverlay.CHANNEL_SELECTOR_ID,
});
AddTabItem(new ChannelTabItem.ChannelSelectorTabItem(new Channel(), channelSelectorActive));
}
private class ChannelTabItem : TabItem<Channel>
@ -200,8 +202,21 @@ namespace osu.Game.Overlays.Chat
public class ChannelSelectorTabItem : ChannelTabItem
{
public ChannelSelectorTabItem(Channel value) : base(value)
public override bool Active
{
get { return base.Active; }
set
{
activeBindable.Value = value;
base.Active = value;
}
}
private Bindable<bool> activeBindable;
public ChannelSelectorTabItem(Channel value, Bindable<bool> active) : base(value)
{
activeBindable = active;
Depth = float.MaxValue;
Width = 60;

View File

@ -44,8 +44,6 @@ namespace osu.Game.Overlays
public const float TAB_AREA_HEIGHT = 50;
public const int CHANNEL_SELECTOR_ID = -1;
private GetMessagesRequest fetchReq;
private readonly ChatTabControl channelTabs;
@ -264,16 +262,7 @@ namespace osu.Game.Overlays
{
if (currentChannel == value) return;
if (value.Id == CHANNEL_SELECTOR_ID)
{
//channel selector popout
currentChannel = value;
return;
}
else if (currentChannel?.Id == CHANNEL_SELECTOR_ID)
{
//channel selector popin
}
if (channelTabs.ChannelSelectorActive) return;
if (currentChannel != null)
currentChannelContainer.Clear(false);