mirror of
https://github.com/ppy/osu.git
synced 2025-01-07 21:32:57 +08:00
Move dropdown out of display style selector
This commit is contained in:
parent
f0dd463416
commit
d0c2a1b9d3
@ -1,7 +1,6 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// 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.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using System;
|
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
@ -11,28 +10,15 @@ using osu.Game.Graphics.Containers;
|
|||||||
|
|
||||||
namespace osu.Game.Overlays.SearchableList
|
namespace osu.Game.Overlays.SearchableList
|
||||||
{
|
{
|
||||||
public class DisplayStyleControl<T> : Container
|
public class DisplayStyleControl : CompositeDrawable
|
||||||
where T : struct, Enum
|
|
||||||
{
|
{
|
||||||
public readonly SlimEnumDropdown<T> Dropdown;
|
|
||||||
public readonly Bindable<PanelDisplayStyle> DisplayStyle = new Bindable<PanelDisplayStyle>();
|
public readonly Bindable<PanelDisplayStyle> DisplayStyle = new Bindable<PanelDisplayStyle>();
|
||||||
|
|
||||||
public DisplayStyleControl()
|
public DisplayStyleControl()
|
||||||
{
|
{
|
||||||
AutoSizeAxes = Axes.Both;
|
AutoSizeAxes = Axes.Both;
|
||||||
|
|
||||||
Children = new[]
|
InternalChild = new FillFlowContainer
|
||||||
{
|
|
||||||
new FillFlowContainer
|
|
||||||
{
|
|
||||||
AutoSizeAxes = Axes.Both,
|
|
||||||
Anchor = Anchor.TopRight,
|
|
||||||
Origin = Anchor.TopRight,
|
|
||||||
Spacing = new Vector2(10f, 0f),
|
|
||||||
Direction = FillDirection.Horizontal,
|
|
||||||
Children = new Drawable[]
|
|
||||||
{
|
|
||||||
new FillFlowContainer
|
|
||||||
{
|
{
|
||||||
AutoSizeAxes = Axes.Both,
|
AutoSizeAxes = Axes.Both,
|
||||||
Spacing = new Vector2(5f, 0f),
|
Spacing = new Vector2(5f, 0f),
|
||||||
@ -42,14 +28,6 @@ namespace osu.Game.Overlays.SearchableList
|
|||||||
new DisplayStyleToggleButton(FontAwesome.Solid.ThLarge, PanelDisplayStyle.Grid, DisplayStyle),
|
new DisplayStyleToggleButton(FontAwesome.Solid.ThLarge, PanelDisplayStyle.Grid, DisplayStyle),
|
||||||
new DisplayStyleToggleButton(FontAwesome.Solid.ListUl, PanelDisplayStyle.List, DisplayStyle),
|
new DisplayStyleToggleButton(FontAwesome.Solid.ListUl, PanelDisplayStyle.List, DisplayStyle),
|
||||||
},
|
},
|
||||||
},
|
|
||||||
Dropdown = new SlimEnumDropdown<T>
|
|
||||||
{
|
|
||||||
RelativeSizeAxes = Axes.None,
|
|
||||||
Width = 160f,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
DisplayStyle.Value = PanelDisplayStyle.Grid;
|
DisplayStyle.Value = PanelDisplayStyle.Grid;
|
||||||
|
@ -19,12 +19,14 @@ namespace osu.Game.Overlays.SearchableList
|
|||||||
{
|
{
|
||||||
private const float padding = 10;
|
private const float padding = 10;
|
||||||
|
|
||||||
private readonly Container filterContainer;
|
private readonly Drawable filterContainer;
|
||||||
|
private readonly Drawable rightFilterContainer;
|
||||||
private readonly Box tabStrip;
|
private readonly Box tabStrip;
|
||||||
|
|
||||||
public readonly SearchTextBox Search;
|
public readonly SearchTextBox Search;
|
||||||
public readonly PageTabControl<TTab> Tabs;
|
public readonly PageTabControl<TTab> Tabs;
|
||||||
public readonly DisplayStyleControl<TCategory> DisplayStyleControl;
|
public readonly SlimEnumDropdown<TCategory> Dropdown;
|
||||||
|
public readonly DisplayStyleControl DisplayStyleControl;
|
||||||
|
|
||||||
protected abstract Color4 BackgroundColour { get; }
|
protected abstract Color4 BackgroundColour { get; }
|
||||||
protected abstract TTab DefaultTab { get; }
|
protected abstract TTab DefaultTab { get; }
|
||||||
@ -42,7 +44,7 @@ namespace osu.Game.Overlays.SearchableList
|
|||||||
|
|
||||||
var controls = CreateSupplementaryControls();
|
var controls = CreateSupplementaryControls();
|
||||||
Container controlsContainer;
|
Container controlsContainer;
|
||||||
Children = new Drawable[]
|
Children = new[]
|
||||||
{
|
{
|
||||||
filterContainer = new Container
|
filterContainer = new Container
|
||||||
{
|
{
|
||||||
@ -104,11 +106,27 @@ namespace osu.Game.Overlays.SearchableList
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
DisplayStyleControl = new DisplayStyleControl<TCategory>
|
rightFilterContainer = new FillFlowContainer
|
||||||
|
{
|
||||||
|
Anchor = Anchor.TopRight,
|
||||||
|
Origin = Anchor.TopRight,
|
||||||
|
AutoSizeAxes = Axes.Both,
|
||||||
|
Children = new Drawable[]
|
||||||
|
{
|
||||||
|
Dropdown = new SlimEnumDropdown<TCategory>
|
||||||
|
{
|
||||||
|
Anchor = Anchor.TopRight,
|
||||||
|
Origin = Anchor.TopRight,
|
||||||
|
RelativeSizeAxes = Axes.None,
|
||||||
|
Width = 160f,
|
||||||
|
},
|
||||||
|
DisplayStyleControl = new DisplayStyleControl
|
||||||
{
|
{
|
||||||
Anchor = Anchor.TopRight,
|
Anchor = Anchor.TopRight,
|
||||||
Origin = Anchor.TopRight,
|
Origin = Anchor.TopRight,
|
||||||
},
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if (controls != null) controlsContainer.Children = new[] { controls };
|
if (controls != null) controlsContainer.Children = new[] { controls };
|
||||||
@ -116,8 +134,8 @@ namespace osu.Game.Overlays.SearchableList
|
|||||||
Tabs.Current.Value = DefaultTab;
|
Tabs.Current.Value = DefaultTab;
|
||||||
Tabs.Current.TriggerChange();
|
Tabs.Current.TriggerChange();
|
||||||
|
|
||||||
DisplayStyleControl.Dropdown.Current.Value = DefaultCategory;
|
Dropdown.Current.Value = DefaultCategory;
|
||||||
DisplayStyleControl.Dropdown.Current.TriggerChange();
|
Dropdown.Current.TriggerChange();
|
||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
|
@ -72,7 +72,7 @@ namespace osu.Game.Overlays
|
|||||||
Filter.Tabs.Current.ValueChanged += _ => onFilterUpdate();
|
Filter.Tabs.Current.ValueChanged += _ => onFilterUpdate();
|
||||||
|
|
||||||
Filter.DisplayStyleControl.DisplayStyle.ValueChanged += _ => recreatePanels();
|
Filter.DisplayStyleControl.DisplayStyle.ValueChanged += _ => recreatePanels();
|
||||||
Filter.DisplayStyleControl.Dropdown.Current.ValueChanged += _ => recreatePanels();
|
Filter.Dropdown.Current.ValueChanged += _ => recreatePanels();
|
||||||
|
|
||||||
currentQuery.BindTo(Filter.Search.Current);
|
currentQuery.BindTo(Filter.Search.Current);
|
||||||
currentQuery.ValueChanged += query =>
|
currentQuery.ValueChanged += query =>
|
||||||
@ -155,7 +155,7 @@ namespace osu.Game.Overlays
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Filter.DisplayStyleControl.Dropdown.Current.Value == SortDirection.Descending)
|
if (Filter.Dropdown.Current.Value == SortDirection.Descending)
|
||||||
sortedUsers = sortedUsers.Reverse();
|
sortedUsers = sortedUsers.Reverse();
|
||||||
|
|
||||||
var newPanels = new FillFlowContainer<UserPanel>
|
var newPanels = new FillFlowContainer<UserPanel>
|
||||||
|
Loading…
Reference in New Issue
Block a user