1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-12 04:49:40 +08:00
osu-lazer/osu.Game/Overlays/SearchableList/SearchableListOverlay.cs

125 lines
4.2 KiB
C#
Raw Normal View History

2017-05-26 13:16:56 +08:00
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// 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;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Input;
using osu.Game.Graphics.Backgrounds;
2017-05-26 13:44:09 +08:00
namespace osu.Game.Overlays.SearchableList
{
2017-05-26 13:44:09 +08:00
public abstract class SearchableListOverlay : WaveOverlayContainer
{
public static readonly float WIDTH_PADDING = 80;
}
public abstract class SearchableListOverlay<T,U,S> : SearchableListOverlay
{
private readonly Container scrollContainer;
2017-05-26 13:44:09 +08:00
protected readonly SearchableListHeader<T> Header;
protected readonly SearchableListFilterControl<U,S> Filter;
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();
protected abstract SearchableListFilterControl<U,S> CreateFilterControl();
2017-05-26 14:10:36 +08:00
protected SearchableListOverlay()
{
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[]
{
new ScrollContainer
{
RelativeSizeAxes = Axes.Both,
ScrollDraggerVisible = false,
Children = new[]
{
ScrollFlow = new FillFlowContainer
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
2017-05-26 14:10:36 +08:00
Padding = new MarginPadding { Horizontal = WIDTH_PADDING },
Direction = FillDirection.Vertical,
},
},
},
},
},
new FillFlowContainer
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Direction = FillDirection.Vertical,
AlwaysReceiveInput = true,
Children = new Drawable[]
{
Header = CreateHeader(),
Filter = CreateFilterControl(),
},
},
};
Filter.Search.Exit = Hide;
}
protected override void Update()
{
base.Update();
scrollContainer.Padding = new MarginPadding { Top = Header.Height + Filter.Height };
}
protected override bool OnFocus(InputState state)
{
2017-05-30 09:52:38 +08:00
InputManager.ChangeFocus(Filter.Search);
return false;
}
protected override void PopIn()
{
base.PopIn();
Filter.Search.HoldFocus = true;
}
protected override void PopOut()
{
base.PopOut();
Filter.Search.HoldFocus = false;
}
}
}