1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-22 00:47:24 +08:00
osu-lazer/osu.Game/Overlays/OverlayStreamControl.cs

57 lines
1.7 KiB
C#
Raw Normal View History

2019-05-22 18:51:16 +08:00
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using osu.Framework.Graphics;
using osu.Framework.Input.Events;
using System.Collections.Generic;
using System.Linq;
using osu.Framework.Graphics.UserInterface;
using JetBrains.Annotations;
2019-05-22 18:51:16 +08:00
namespace osu.Game.Overlays
2019-05-22 18:51:16 +08:00
{
2020-03-05 04:08:58 +08:00
public abstract class OverlayStreamControl<T> : TabControl<T>
2019-05-22 18:51:16 +08:00
{
2020-03-05 04:08:58 +08:00
protected OverlayStreamControl()
2019-05-22 18:51:16 +08:00
{
RelativeSizeAxes = Axes.X;
AutoSizeAxes = Axes.Y;
}
public void Populate(List<T> streams) => streams.ForEach(AddItem);
protected override Dropdown<T> CreateDropdown() => null;
protected override TabItem<T> CreateTabItem(T value) => CreateStreamItem(value).With(item =>
2019-05-22 18:51:16 +08:00
{
item.SelectedItem.BindTo(Current);
});
[NotNull]
2020-03-05 04:08:58 +08:00
protected abstract OverlayStreamItem<T> CreateStreamItem(T value);
protected override TabFillFlowContainer CreateTabFlow() => new TabFillFlowContainer
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
AllowMultiline = true,
};
2019-05-22 18:51:16 +08:00
protected override bool OnHover(HoverEvent e)
{
2020-03-05 04:08:58 +08:00
foreach (var streamBadge in TabContainer.Children.OfType<OverlayStreamItem<T>>())
streamBadge.UserHoveringArea = true;
2019-05-22 18:51:16 +08:00
return base.OnHover(e);
}
protected override void OnHoverLost(HoverLostEvent e)
{
2020-03-05 04:08:58 +08:00
foreach (var streamBadge in TabContainer.Children.OfType<OverlayStreamItem<T>>())
streamBadge.UserHoveringArea = false;
2019-05-22 18:51:16 +08:00
base.OnHoverLost(e);
}
}
}