Tidy up OsuTabControl and FilterControl.

This commit is contained in:
Dean Herbert
2017-03-16 16:35:44 +09:00
parent 4bedd4d2d7
commit 334e389518
8 changed files with 122 additions and 89 deletions

View File

@ -15,7 +15,7 @@ namespace osu.Game.Graphics.UserInterface
protected override TabItem<T> CreateTabItem(T value) => new OsuTabItem<T> { Value = value };
public OsuTabControl(float offset = 0) : base(offset)
public OsuTabControl()
{
if (!typeof(T).IsEnum)
throw new InvalidOperationException("OsuTabControl only supports enums as the generic type argument");
@ -45,5 +45,12 @@ namespace osu.Game.Graphics.UserInterface
item.AccentColour = value;
}
}
protected override void Update()
{
base.Update();
DropDown.Header.Height = DrawHeight;
}
}
}

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;
namespace osu.Game.Graphics.UserInterface
{
public class OsuTabDropDownHeader : TabDropDownHeader
{
protected override string Label { get; set; }
public OsuTabDropDownHeader()
{
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

@ -6,18 +6,17 @@ using OpenTK;
using OpenTK.Graphics;
using osu.Framework.Allocation;
using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Primitives;
using osu.Framework.Graphics.Transforms;
using osu.Framework.Graphics.UserInterface;
using osu.Framework.Graphics.UserInterface.Tab;
using osu.Framework.Input;
namespace osu.Game.Graphics.UserInterface
{
public class OsuTabDropDownMenu<T> : TabDropDownMenu<T>
{
public override float HeaderWidth => 14;
public override float HeaderHeight => 24;
private Color4? accentColour;
public Color4 AccentColour
{
@ -25,7 +24,7 @@ namespace osu.Game.Graphics.UserInterface
set
{
accentColour = value;
Header.Colour = value;
((OsuTabDropDownHeader)Header).AccentColour = value;
foreach (var item in ItemList.OfType<OsuTabDropDownMenuItem<T>>())
item.AccentColour = value;
}
@ -33,7 +32,7 @@ namespace osu.Game.Graphics.UserInterface
protected override DropDownHeader CreateHeader() => new OsuTabDropDownHeader
{
Colour = AccentColour
AccentColour = AccentColour
};
protected override DropDownMenuItem<T> CreateDropDownItem(string key, T value) =>
@ -69,5 +68,63 @@ namespace osu.Game.Graphics.UserInterface
if (accentColour == null)
AccentColour = colours.Blue;
}
public class OsuTabDropDownHeader : DropDownHeader
{
protected override string Label { get; set; }
private Color4? accentColour;
public Color4 AccentColour
{
get { return accentColour.GetValueOrDefault(); }
set
{
accentColour = value;
BackgroundColourHover = value;
Foreground.Colour = value;
}
}
protected override bool OnHover(InputState state)
{
Foreground.Colour = BackgroundColour;
return base.OnHover(state);
}
protected override void OnHoverLost(InputState state)
{
Foreground.Colour = BackgroundColourHover;
base.OnHoverLost(state);
}
public OsuTabDropDownHeader()
{
RelativeSizeAxes = Axes.None;
AutoSizeAxes = Axes.X;
BackgroundColour = Color4.Black;
Background.Height = 0.5f;
Background.CornerRadius = 3;
Background.Masking = true;
Foreground.RelativeSizeAxes = Axes.None;
Foreground.AutoSizeAxes = Axes.X;
Foreground.RelativeSizeAxes = Axes.Y;
Foreground.Margin = new MarginPadding(5);
Foreground.Children = new Drawable[]
{
new TextAwesome
{
Icon = FontAwesome.fa_ellipsis_h,
TextSize = 14,
Origin = Anchor.Centre,
Anchor = Anchor.Centre,
}
};
Padding = new MarginPadding { Left = 5, Right = 5 };
}
}
}
}

View File

@ -81,12 +81,16 @@ namespace osu.Game.Graphics.UserInterface
public OsuTabItem()
{
AutoSizeAxes = Axes.Both;
AutoSizeAxes = Axes.X;
RelativeSizeAxes = Axes.Y;
Children = new Drawable[]
{
text = new OsuSpriteText
{
Margin = new MarginPadding(5),
Origin = Anchor.BottomLeft,
Anchor = Anchor.BottomLeft,
TextSize = 14,
Font = @"Exo2.0-Bold", // Font should only turn bold when active?
},