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.
|
|
|
|
|
|
2022-06-17 15:37:17 +08:00
|
|
|
|
#nullable disable
|
|
|
|
|
|
2019-05-22 18:51:16 +08:00
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Input.Events;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using osu.Framework.Graphics.UserInterface;
|
2020-03-03 22:01:58 +08:00
|
|
|
|
using JetBrains.Annotations;
|
2019-05-22 18:51:16 +08:00
|
|
|
|
|
2020-03-03 22:01:58 +08:00
|
|
|
|
namespace osu.Game.Overlays
|
2019-05-22 18:51:16 +08:00
|
|
|
|
{
|
2022-11-24 13:32:20 +08:00
|
|
|
|
public abstract partial 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;
|
|
|
|
|
}
|
|
|
|
|
|
2020-03-03 22:01:58 +08:00
|
|
|
|
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
|
|
|
|
{
|
2020-03-03 22:01:58 +08:00
|
|
|
|
item.SelectedItem.BindTo(Current);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
[NotNull]
|
2020-03-05 04:08:58 +08:00
|
|
|
|
protected abstract OverlayStreamItem<T> CreateStreamItem(T value);
|
2020-03-03 22:01:58 +08:00
|
|
|
|
|
|
|
|
|
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>>())
|
2020-03-02 19:16:58 +08:00
|
|
|
|
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>>())
|
2020-03-02 19:16:58 +08:00
|
|
|
|
streamBadge.UserHoveringArea = false;
|
2019-05-22 18:51:16 +08:00
|
|
|
|
|
|
|
|
|
base.OnHoverLost(e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|