2019-05-22 10:51:16 +00: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 07:37:17 +00:00
|
|
|
|
#nullable disable
|
|
|
|
|
|
2019-05-22 10:51:16 +00: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 14:01:58 +00:00
|
|
|
|
using JetBrains.Annotations;
|
2019-05-22 10:51:16 +00:00
|
|
|
|
|
2020-03-03 14:01:58 +00:00
|
|
|
|
namespace osu.Game.Overlays
|
2019-05-22 10:51:16 +00:00
|
|
|
|
{
|
2020-03-04 20:08:58 +00:00
|
|
|
|
public abstract partial class OverlayStreamControl<T> : TabControl<T>
|
2019-05-22 10:51:16 +00:00
|
|
|
|
{
|
2020-03-04 20:08:58 +00:00
|
|
|
|
protected OverlayStreamControl()
|
2019-05-22 10:51:16 +00:00
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.X;
|
|
|
|
|
AutoSizeAxes = Axes.Y;
|
|
|
|
|
}
|
|
|
|
|
|
2020-03-03 14:01:58 +00: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 10:51:16 +00:00
|
|
|
|
{
|
2020-03-03 14:01:58 +00:00
|
|
|
|
item.SelectedItem.BindTo(Current);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
[NotNull]
|
2020-03-04 20:08:58 +00:00
|
|
|
|
protected abstract OverlayStreamItem<T> CreateStreamItem(T value);
|
2020-03-03 14:01:58 +00:00
|
|
|
|
|
|
|
|
|
protected override TabFillFlowContainer CreateTabFlow() => new TabFillFlowContainer
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
AutoSizeAxes = Axes.Y,
|
|
|
|
|
AllowMultiline = true,
|
|
|
|
|
};
|
2019-05-22 10:51:16 +00:00
|
|
|
|
|
|
|
|
|
protected override bool OnHover(HoverEvent e)
|
|
|
|
|
{
|
2020-03-04 20:08:58 +00:00
|
|
|
|
foreach (var streamBadge in TabContainer.Children.OfType<OverlayStreamItem<T>>())
|
2020-03-02 11:16:58 +00:00
|
|
|
|
streamBadge.UserHoveringArea = true;
|
2019-05-22 10:51:16 +00:00
|
|
|
|
|
|
|
|
|
return base.OnHover(e);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void OnHoverLost(HoverLostEvent e)
|
|
|
|
|
{
|
2020-03-04 20:08:58 +00:00
|
|
|
|
foreach (var streamBadge in TabContainer.Children.OfType<OverlayStreamItem<T>>())
|
2020-03-02 11:16:58 +00:00
|
|
|
|
streamBadge.UserHoveringArea = false;
|
2019-05-22 10:51:16 +00:00
|
|
|
|
|
|
|
|
|
base.OnHoverLost(e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|