1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-15 11:47:24 +08:00
osu-lazer/osu.Game/Overlays/Changelog/UpdateStreamBadgeArea.cs

74 lines
2.2 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 osu.Game.Online.API.Requests.Responses;
using System.Collections.Generic;
using System.Linq;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.UserInterface;
2020-02-21 23:12:23 +08:00
using osu.Framework.Allocation;
2019-05-22 18:51:16 +08:00
namespace osu.Game.Overlays.Changelog
{
public class UpdateStreamBadgeArea : TabControl<APIUpdateStream>
{
2020-02-21 23:12:23 +08:00
[BackgroundDependencyLoader]
private void load(OverlayColourProvider colourProvider)
2019-05-22 18:51:16 +08:00
{
RelativeSizeAxes = Axes.X;
AutoSizeAxes = Axes.Y;
AddInternal(new Box
{
RelativeSizeAxes = Axes.Both,
2020-02-21 23:12:23 +08:00
Colour = colourProvider.Background5,
2019-05-22 18:51:16 +08:00
});
}
public void Populate(List<APIUpdateStream> streams)
{
2020-02-21 23:12:23 +08:00
foreach (var updateStream in streams)
2019-05-23 11:41:45 +08:00
AddItem(updateStream);
2019-05-22 18:51:16 +08:00
}
protected override bool OnHover(HoverEvent e)
{
2020-02-21 23:12:23 +08:00
foreach (var streamBadge in TabContainer.Children.OfType<UpdateStreamBadge>())
2019-05-22 18:51:16 +08:00
streamBadge.EnableDim();
return base.OnHover(e);
}
protected override void OnHoverLost(HoverLostEvent e)
{
2020-02-21 23:12:23 +08:00
foreach (var streamBadge in TabContainer.Children.OfType<UpdateStreamBadge>())
2019-05-22 18:51:16 +08:00
streamBadge.DisableDim();
base.OnHoverLost(e);
}
protected override TabFillFlowContainer CreateTabFlow()
{
var flow = base.CreateTabFlow();
flow.RelativeSizeAxes = Axes.X;
flow.AutoSizeAxes = Axes.Y;
flow.AllowMultiline = true;
flow.Padding = new MarginPadding
{
Vertical = 20,
Horizontal = 85,
2019-05-22 18:51:16 +08:00
};
return flow;
}
protected override Dropdown<APIUpdateStream> CreateDropdown() => null;
protected override TabItem<APIUpdateStream> CreateTabItem(APIUpdateStream value) =>
new UpdateStreamBadge(value) { SelectedTab = { BindTarget = Current } };
2019-05-22 18:51:16 +08:00
}
}