1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-27 07:43:22 +08:00
osu-lazer/osu.Game/Overlays/SearchableList/SearchableListOverlay.cs

130 lines
4.3 KiB
C#
Raw Normal View History

// 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.
2018-04-13 17:19:50 +08:00
2019-12-07 19:56:56 +08:00
using System;
2018-11-20 15:51:59 +08:00
using osuTK.Graphics;
2018-04-13 17:19:50 +08:00
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
2018-10-02 11:02:47 +08:00
using osu.Framework.Input.Events;
2018-04-13 17:19:50 +08:00
using osu.Game.Graphics.Backgrounds;
using osu.Game.Graphics.Containers;
using osu.Game.Graphics.Cursor;
2018-04-13 17:19:50 +08:00
namespace osu.Game.Overlays.SearchableList
{
2019-05-14 13:18:06 +08:00
public abstract class SearchableListOverlay : FullscreenOverlay
2018-04-13 17:19:50 +08:00
{
public const float WIDTH_PADDING = 80;
2020-01-24 17:24:35 +08:00
protected SearchableListOverlay(OverlayColourScheme colourScheme)
: base(colourScheme)
{
}
2018-04-13 17:19:50 +08:00
}
2019-12-07 19:56:56 +08:00
public abstract class SearchableListOverlay<THeader, TTab, TCategory> : SearchableListOverlay
where THeader : struct, Enum
where TTab : struct, Enum
where TCategory : struct, Enum
2018-04-13 17:19:50 +08:00
{
private readonly Container scrollContainer;
2019-12-07 19:56:56 +08:00
protected readonly SearchableListHeader<THeader> Header;
protected readonly SearchableListFilterControl<TTab, TCategory> Filter;
2018-04-13 17:19:50 +08:00
protected readonly FillFlowContainer ScrollFlow;
protected abstract Color4 BackgroundColour { get; }
protected abstract Color4 TrianglesColourLight { get; }
protected abstract Color4 TrianglesColourDark { get; }
2019-12-07 19:56:56 +08:00
protected abstract SearchableListHeader<THeader> CreateHeader();
protected abstract SearchableListFilterControl<TTab, TCategory> CreateFilterControl();
2018-04-13 17:19:50 +08:00
2020-01-24 17:24:35 +08:00
protected SearchableListOverlay(OverlayColourScheme colourScheme)
: base(colourScheme)
2018-04-13 17:19:50 +08:00
{
Children = new Drawable[]
{
new Box
{
RelativeSizeAxes = Axes.Both,
Colour = BackgroundColour,
},
new Container
{
RelativeSizeAxes = Axes.Both,
Masking = true,
Children = new[]
{
new Triangles
{
RelativeSizeAxes = Axes.Both,
TriangleScale = 5,
ColourLight = TrianglesColourLight,
ColourDark = TrianglesColourDark,
},
},
},
scrollContainer = new Container
{
RelativeSizeAxes = Axes.Both,
Child = new OsuContextMenuContainer
2018-04-13 17:19:50 +08:00
{
RelativeSizeAxes = Axes.Both,
Masking = true,
Child = new OsuScrollContainer
2018-04-13 17:19:50 +08:00
{
RelativeSizeAxes = Axes.Both,
ScrollbarVisible = false,
Child = ScrollFlow = new FillFlowContainer
2018-04-13 17:19:50 +08:00
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
2020-03-04 16:46:35 +08:00
Padding = new MarginPadding { Horizontal = 10, Bottom = 50 },
Direction = FillDirection.Vertical,
2018-04-13 17:19:50 +08:00
},
},
},
},
new FillFlowContainer
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Direction = FillDirection.Vertical,
Children = new Drawable[]
{
Header = CreateHeader(),
Filter = CreateFilterControl(),
},
},
};
}
protected override void Update()
{
base.Update();
scrollContainer.Padding = new MarginPadding { Top = Header.Height + Filter.Height };
}
2018-10-02 11:02:47 +08:00
protected override void OnFocus(FocusEvent e)
2018-04-13 17:19:50 +08:00
{
Filter.Search.TakeFocus();
2018-04-13 17:19:50 +08:00
}
protected override void PopIn()
{
base.PopIn();
Filter.Search.HoldFocus = true;
}
protected override void PopOut()
{
base.PopOut();
Filter.Search.HoldFocus = false;
}
}
}