2017-05-26 13:16:56 +08:00
|
|
|
|
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
2017-05-26 11:52:01 +08:00
|
|
|
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
|
|
|
|
|
|
|
|
|
using OpenTK.Graphics;
|
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2017-06-20 13:54:23 +08:00
|
|
|
|
using osu.Framework.Graphics.Shapes;
|
2017-05-26 11:52:01 +08:00
|
|
|
|
using osu.Framework.Input;
|
|
|
|
|
using osu.Game.Graphics.Backgrounds;
|
2017-07-12 17:57:44 +08:00
|
|
|
|
using osu.Game.Graphics.Containers;
|
2017-05-26 11:52:01 +08:00
|
|
|
|
|
2017-05-26 13:44:09 +08:00
|
|
|
|
namespace osu.Game.Overlays.SearchableList
|
2017-05-26 11:52:01 +08:00
|
|
|
|
{
|
2017-05-26 13:44:09 +08:00
|
|
|
|
public abstract class SearchableListOverlay : WaveOverlayContainer
|
2017-05-26 11:52:01 +08:00
|
|
|
|
{
|
|
|
|
|
public static readonly float WIDTH_PADDING = 80;
|
|
|
|
|
}
|
|
|
|
|
|
2017-06-07 19:44:54 +08:00
|
|
|
|
public abstract class SearchableListOverlay<T, U, S> : SearchableListOverlay
|
2017-05-26 11:52:01 +08:00
|
|
|
|
{
|
|
|
|
|
private readonly Container scrollContainer;
|
|
|
|
|
|
2017-05-26 13:44:09 +08:00
|
|
|
|
protected readonly SearchableListHeader<T> Header;
|
2017-06-07 19:44:54 +08:00
|
|
|
|
protected readonly SearchableListFilterControl<U, S> Filter;
|
2017-05-26 11:52:01 +08:00
|
|
|
|
protected readonly FillFlowContainer ScrollFlow;
|
|
|
|
|
|
|
|
|
|
protected abstract Color4 BackgroundColour { get; }
|
|
|
|
|
protected abstract Color4 TrianglesColourLight { get; }
|
|
|
|
|
protected abstract Color4 TrianglesColourDark { get; }
|
2017-05-26 13:44:09 +08:00
|
|
|
|
protected abstract SearchableListHeader<T> CreateHeader();
|
2017-06-07 19:44:54 +08:00
|
|
|
|
protected abstract SearchableListFilterControl<U, S> CreateFilterControl();
|
2017-05-26 11:52:01 +08:00
|
|
|
|
|
2017-05-26 14:10:36 +08:00
|
|
|
|
protected SearchableListOverlay()
|
2017-05-26 11:52:01 +08:00
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both;
|
|
|
|
|
|
|
|
|
|
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,
|
|
|
|
|
Children = new[]
|
|
|
|
|
{
|
2017-07-12 17:57:44 +08:00
|
|
|
|
new OsuScrollContainer
|
2017-05-26 11:52:01 +08:00
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2017-05-31 16:28:50 +08:00
|
|
|
|
ScrollbarVisible = false,
|
2017-05-26 11:52:01 +08:00
|
|
|
|
Children = new[]
|
|
|
|
|
{
|
|
|
|
|
ScrollFlow = new FillFlowContainer
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
AutoSizeAxes = Axes.Y,
|
2017-06-07 21:11:10 +08:00
|
|
|
|
Padding = new MarginPadding { Horizontal = WIDTH_PADDING, Bottom = 50 },
|
2017-05-26 11:52:01 +08:00
|
|
|
|
Direction = FillDirection.Vertical,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
2017-05-30 09:39:59 +08:00
|
|
|
|
new FillFlowContainer
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
AutoSizeAxes = Axes.Y,
|
|
|
|
|
Direction = FillDirection.Vertical,
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
Header = CreateHeader(),
|
|
|
|
|
Filter = CreateFilterControl(),
|
|
|
|
|
},
|
|
|
|
|
},
|
2017-05-26 11:52:01 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
Filter.Search.Exit = Hide;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void Update()
|
|
|
|
|
{
|
|
|
|
|
base.Update();
|
|
|
|
|
|
|
|
|
|
scrollContainer.Padding = new MarginPadding { Top = Header.Height + Filter.Height };
|
|
|
|
|
}
|
|
|
|
|
|
2017-05-31 16:28:50 +08:00
|
|
|
|
protected override void OnFocus(InputState state)
|
2017-05-26 11:52:01 +08:00
|
|
|
|
{
|
2017-08-16 12:07:18 +08:00
|
|
|
|
GetContainingInputManager().ChangeFocus(Filter.Search);
|
2017-05-26 11:52:01 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void PopIn()
|
|
|
|
|
{
|
|
|
|
|
base.PopIn();
|
|
|
|
|
|
|
|
|
|
Filter.Search.HoldFocus = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void PopOut()
|
|
|
|
|
{
|
|
|
|
|
base.PopOut();
|
|
|
|
|
|
|
|
|
|
Filter.Search.HoldFocus = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|