Rearrange things somewhat

This commit is contained in:
Drew DeVault
2017-03-15 20:11:50 -04:00
parent cac6c42aac
commit 3aecbf5739
8 changed files with 40 additions and 35 deletions

View File

@ -9,12 +9,12 @@ using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Primitives;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.UserInterface.Tab;
using osu.Game.Graphics;
using osu.Game.Graphics.UserInterface;
using osu.Game.Graphics.Sprites;
using osu.Game.Screens.Select.Filter;
using osu.Game.Screens.Select.Tab;
using Container = osu.Framework.Graphics.Containers.Container;
using osu.Framework.Graphics.UserInterface.Tab;
namespace osu.Game.Screens.Select
{
@ -23,8 +23,10 @@ namespace osu.Game.Screens.Select
public Action FilterChanged;
public string Search => searchTextBox.Text;
private SortMode sort = SortMode.Title;
public SortMode Sort {
public SortMode Sort
{
get { return sort; }
set
{
@ -37,7 +39,8 @@ namespace osu.Game.Screens.Select
}
private GroupMode group = GroupMode.All;
public GroupMode Group {
public GroupMode Group
{
get { return group; }
set
{
@ -105,7 +108,7 @@ namespace osu.Game.Screens.Select
Anchor = Anchor.TopLeft,
Position = new Vector2(0, 23)
},
groupTabs = new FilterTabControl<GroupMode>
groupTabs = new OsuTabControl<GroupMode>
{
Width = 230,
AutoSort = true
@ -128,7 +131,7 @@ namespace osu.Game.Screens.Select
Bottom = 5
},
},
sortTabs = new FilterTabControl<SortMode>(87)
sortTabs = new OsuTabControl<SortMode>(87)
{
Width = 191,
AutoSort = true

View File

@ -1,24 +0,0 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using osu.Framework.Graphics.UserInterface.Tab;
namespace osu.Game.Screens.Select.Tab
{
public class FilterTabControl<T> : TabControl<T>
{
protected override TabDropDownMenu<T> CreateDropDownMenu() => new FilterTabDropDownMenu<T>();
protected override TabItem<T> CreateTabItem(T value) => new FilterTabItem<T> { Value = value };
public FilterTabControl(float offset = 0) : base(offset)
{
if (!typeof(T).IsEnum)
throw new InvalidOperationException("FilterTabControl only supports enums as the generic type argument");
foreach (var val in (T[])Enum.GetValues(typeof(T)))
AddTab(val);
}
}
}

View File

@ -1,29 +0,0 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Framework.Graphics;
using osu.Framework.Graphics.Primitives;
using osu.Framework.Graphics.UserInterface.Tab;
using osu.Game.Graphics;
namespace osu.Game.Screens.Select.Tab
{
public class FilterTabDropDownHeader : TabDropDownHeader
{
protected override string Label { get; set; }
public FilterTabDropDownHeader() {
Foreground.Children = new Drawable[]
{
new TextAwesome
{
Icon = FontAwesome.fa_ellipsis_h,
TextSize = 14,
Margin = new MarginPadding{ Top = 6, Bottom = 4 },
Origin = Anchor.BottomLeft,
Anchor = Anchor.BottomLeft,
}
};
}
}
}

View File

@ -1,55 +0,0 @@
// 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;
using OpenTK.Graphics;
using osu.Framework.Allocation;
using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics.Primitives;
using osu.Framework.Graphics.Transforms;
using osu.Framework.Graphics.UserInterface;
using osu.Framework.Graphics.UserInterface.Tab;
using osu.Game.Graphics;
using osu.Game.Screens.Select.Filter;
namespace osu.Game.Screens.Select.Tab
{
public class FilterTabDropDownMenu<T> : TabDropDownMenu<T>
{
public override float HeaderWidth => 14;
public override float HeaderHeight => 24;
protected override DropDownHeader CreateHeader() => new FilterTabDropDownHeader();
protected override DropDownMenuItem<T> CreateDropDownItem(string key, T value) => new FilterTabDropDownMenuItem<T>(key, value);
public FilterTabDropDownMenu()
{
MaxDropDownHeight = int.MaxValue;
ContentContainer.CornerRadius = 4;
ContentBackground.Colour = Color4.Black.Opacity(0.9f);
ScrollContainer.ScrollDraggerVisible = false;
DropDownItemsContainer.Padding = new MarginPadding { Left = 5, Bottom = 7, Right = 5, Top = 7 };
}
protected override void AnimateOpen()
{
ContentContainer.FadeIn(300, EasingTypes.OutQuint);
}
protected override void AnimateClose()
{
ContentContainer.FadeOut(300, EasingTypes.OutQuint);
}
protected override void UpdateContentHeight()
{
ContentContainer.ResizeTo(new Vector2(1, State == DropDownMenuState.Opened ? ContentHeight : 0), 300, EasingTypes.OutQuint);
}
[BackgroundDependencyLoader]
private void load(OsuColour colours) {
Header.Colour = typeof(T) == typeof(SortMode) ? colours.GreenLight : colours.Blue;
}
}
}

View File

@ -1,52 +0,0 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Framework.Allocation;
using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Primitives;
using osu.Framework.Graphics.UserInterface;
using osu.Game.Graphics;
using OpenTK.Graphics;
using osu.Game.Graphics.Sprites;
using osu.Game.Screens.Select.Filter;
namespace osu.Game.Screens.Select.Tab
{
public class FilterTabDropDownMenuItem<T> : DropDownMenuItem<T>
{
public FilterTabDropDownMenuItem(string text, T value) : base(text, value)
{
Foreground.Padding = new MarginPadding { Top = 4, Bottom = 4 };
Foreground.Margin = new MarginPadding { Left = 7 };
Masking = true;
CornerRadius = 6;
Foreground.Add(new OsuSpriteText
{
Text = text,
Origin = Anchor.CentreLeft,
Anchor = Anchor.CentreLeft,
});
}
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
BackgroundColour = Color4.Black.Opacity(0f);
ForegroundColourHover = Color4.Black;
ForegroundColourSelected = Color4.Black;
if (typeof(T) == typeof(SortMode))
{
BackgroundColourHover = colours.GreenLight;
BackgroundColourSelected = colours.GreenLight;
}
else
{
BackgroundColourHover = colours.Blue;
BackgroundColourSelected = colours.Blue;
}
}
}
}

View File

@ -1,111 +0,0 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using OpenTK.Graphics;
using osu.Framework.Allocation;
using osu.Framework.Extensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Primitives;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.UserInterface.Tab;
using osu.Framework.Input;
using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
using osu.Game.Screens.Select.Filter;
namespace osu.Game.Screens.Select.Tab
{
public class FilterTabItem<T> : TabItem<T>
{
private SpriteText text;
private Box box;
private Color4 fadeColour;
public new T Value
{
get { return base.Value; }
set
{
base.Value = value;
text.Text = (value as Enum)?.GetDescription();
}
}
public override bool Active
{
get { return base.Active; }
set
{
if (value)
fadeActive();
else
fadeInactive();
base.Active = value;
}
}
private void fadeActive()
{
box.FadeIn(300);
text.FadeColour(Color4.White, 300);
}
private void fadeInactive()
{
box.FadeOut(300);
text.FadeColour(fadeColour, 300);
}
protected override bool OnHover(InputState state) {
if (!Active)
fadeActive();
return true;
}
protected override void OnHoverLost(InputState state) {
if (!Active)
fadeInactive();
}
public FilterTabItem()
{
AutoSizeAxes = Axes.Both;
Children = new Drawable[]
{
text = new OsuSpriteText
{
Margin = new MarginPadding(5),
TextSize = 14,
Font = @"Exo2.0-Bold", // Font should only turn bold when active?
},
box = new Box
{
RelativeSizeAxes = Axes.X,
Height = 1,
Alpha = 0,
Colour = Color4.White,
Origin = Anchor.BottomLeft,
Anchor = Anchor.BottomLeft,
}
};
}
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
if (typeof(T) == typeof(SortMode))
{
fadeColour = colours.GreenLight;
if (!Active)
text.Colour = colours.GreenLight;
}
else
{
fadeColour = colours.Blue;
if (!Active)
text.Colour = colours.Blue;
}
}
}
}