mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 21:07:33 +08:00
Fix display style dropdown scaling the filter control
This commit is contained in:
parent
5e4558cc54
commit
b6cb9d3229
@ -2,6 +2,7 @@
|
|||||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using OpenTK;
|
||||||
using OpenTK.Graphics;
|
using OpenTK.Graphics;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Extensions.Color4Extensions;
|
using osu.Framework.Extensions.Color4Extensions;
|
||||||
@ -17,6 +18,7 @@ namespace osu.Game.Overlays.SearchableList
|
|||||||
{
|
{
|
||||||
private const float padding = 10;
|
private const float padding = 10;
|
||||||
|
|
||||||
|
private readonly Container filterContainer;
|
||||||
private readonly Box tabStrip;
|
private readonly Box tabStrip;
|
||||||
|
|
||||||
public readonly SearchTextBox Search;
|
public readonly SearchTextBox Search;
|
||||||
@ -27,65 +29,73 @@ namespace osu.Game.Overlays.SearchableList
|
|||||||
protected abstract T DefaultTab { get; }
|
protected abstract T DefaultTab { get; }
|
||||||
protected virtual Drawable CreateSupplementaryControls() => null;
|
protected virtual Drawable CreateSupplementaryControls() => null;
|
||||||
|
|
||||||
|
protected override bool InternalContains(Vector2 screenSpacePos) => base.InternalContains(screenSpacePos) || DisplayStyleControl.Dropdown.Contains(screenSpacePos);
|
||||||
|
|
||||||
protected SearchableListFilterControl()
|
protected SearchableListFilterControl()
|
||||||
{
|
{
|
||||||
if (!typeof(T).IsEnum)
|
if (!typeof(T).IsEnum)
|
||||||
throw new InvalidOperationException("SearchableListFilterControl's sort tabs only support enums as the generic type argument");
|
throw new InvalidOperationException("SearchableListFilterControl's sort tabs only support enums as the generic type argument");
|
||||||
|
|
||||||
RelativeSizeAxes = Axes.X;
|
RelativeSizeAxes = Axes.X;
|
||||||
AutoSizeAxes = Axes.Y;
|
|
||||||
|
|
||||||
var controls = CreateSupplementaryControls();
|
var controls = CreateSupplementaryControls();
|
||||||
Container controlsContainer;
|
Container controlsContainer;
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
new Box
|
filterContainer = new Container
|
||||||
{
|
|
||||||
RelativeSizeAxes = Axes.Both,
|
|
||||||
Colour = BackgroundColour,
|
|
||||||
Alpha = 0.9f,
|
|
||||||
},
|
|
||||||
tabStrip = new Box
|
|
||||||
{
|
|
||||||
Anchor = Anchor.BottomLeft,
|
|
||||||
Origin = Anchor.BottomLeft,
|
|
||||||
RelativeSizeAxes = Axes.X,
|
|
||||||
Height = 1,
|
|
||||||
},
|
|
||||||
new FillFlowContainer
|
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.X,
|
RelativeSizeAxes = Axes.X,
|
||||||
AutoSizeAxes = Axes.Y,
|
AutoSizeAxes = Axes.Y,
|
||||||
Padding = new MarginPadding { Top = padding, Horizontal = SearchableListOverlay.WIDTH_PADDING },
|
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
Search = new FilterSearchTextBox
|
new Box
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.X,
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Colour = BackgroundColour,
|
||||||
|
Alpha = 0.9f,
|
||||||
},
|
},
|
||||||
controlsContainer = new Container
|
tabStrip = new Box
|
||||||
|
{
|
||||||
|
Anchor = Anchor.BottomLeft,
|
||||||
|
Origin = Anchor.BottomLeft,
|
||||||
|
RelativeSizeAxes = Axes.X,
|
||||||
|
Height = 1,
|
||||||
|
},
|
||||||
|
new FillFlowContainer
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.X,
|
RelativeSizeAxes = Axes.X,
|
||||||
AutoSizeAxes = Axes.Y,
|
AutoSizeAxes = Axes.Y,
|
||||||
Margin = new MarginPadding { Top = controls != null ? padding : 0 },
|
Padding = new MarginPadding { Top = padding, Horizontal = SearchableListOverlay.WIDTH_PADDING },
|
||||||
},
|
Children = new Drawable[]
|
||||||
Tabs = new PageTabControl<T>
|
{
|
||||||
{
|
Search = new FilterSearchTextBox
|
||||||
RelativeSizeAxes = Axes.X,
|
{
|
||||||
},
|
RelativeSizeAxes = Axes.X,
|
||||||
new Box //keep the tab strip part of autosize, but don't put it in the flow container
|
},
|
||||||
{
|
controlsContainer = new Container
|
||||||
RelativeSizeAxes = Axes.X,
|
{
|
||||||
Height = 1,
|
RelativeSizeAxes = Axes.X,
|
||||||
Colour = Color4.White.Opacity(0),
|
AutoSizeAxes = Axes.Y,
|
||||||
|
Margin = new MarginPadding { Top = controls != null ? padding : 0 },
|
||||||
|
},
|
||||||
|
Tabs = new PageTabControl<T>
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.X,
|
||||||
|
},
|
||||||
|
new Box //keep the tab strip part of autosize, but don't put it in the flow container
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.X,
|
||||||
|
Height = 1,
|
||||||
|
Colour = Color4.White.Opacity(0),
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
DisplayStyleControl = new DisplayStyleControl<U>
|
DisplayStyleControl = new DisplayStyleControl<U>
|
||||||
{
|
{
|
||||||
Anchor = Anchor.BottomRight,
|
Anchor = Anchor.TopRight,
|
||||||
Origin = Anchor.BottomRight,
|
Origin = Anchor.TopRight,
|
||||||
Margin = new MarginPadding { Bottom = 5, Right = SearchableListOverlay.WIDTH_PADDING },
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -101,6 +111,14 @@ namespace osu.Game.Overlays.SearchableList
|
|||||||
tabStrip.Colour = colours.Yellow;
|
tabStrip.Colour = colours.Yellow;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void Update()
|
||||||
|
{
|
||||||
|
base.Update();
|
||||||
|
|
||||||
|
Height = filterContainer.Height;
|
||||||
|
DisplayStyleControl.Margin = new MarginPadding { Top = filterContainer.Height - 35, Right = SearchableListOverlay.WIDTH_PADDING };
|
||||||
|
}
|
||||||
|
|
||||||
private class FilterSearchTextBox : SearchTextBox
|
private class FilterSearchTextBox : SearchTextBox
|
||||||
{
|
{
|
||||||
protected override Color4 BackgroundUnfocused => backgroundColour;
|
protected override Color4 BackgroundUnfocused => backgroundColour;
|
||||||
|
@ -55,17 +55,6 @@ namespace osu.Game.Overlays.SearchableList
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
new FillFlowContainer
|
|
||||||
{
|
|
||||||
RelativeSizeAxes = Axes.X,
|
|
||||||
AutoSizeAxes = Axes.Y,
|
|
||||||
Direction = FillDirection.Vertical,
|
|
||||||
Children = new Drawable[]
|
|
||||||
{
|
|
||||||
Header = CreateHeader(),
|
|
||||||
Filter = CreateFilterControl(),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
scrollContainer = new Container
|
scrollContainer = new Container
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
@ -88,6 +77,18 @@ namespace osu.Game.Overlays.SearchableList
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
new FillFlowContainer
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.X,
|
||||||
|
AutoSizeAxes = Axes.Y,
|
||||||
|
Direction = FillDirection.Vertical,
|
||||||
|
AlwaysReceiveInput = true,
|
||||||
|
Children = new Drawable[]
|
||||||
|
{
|
||||||
|
Header = CreateHeader(),
|
||||||
|
Filter = CreateFilterControl(),
|
||||||
|
},
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
Filter.Search.Exit = Hide;
|
Filter.Search.Exit = Hide;
|
||||||
|
Loading…
Reference in New Issue
Block a user