mirror of
https://github.com/ppy/osu.git
synced 2024-11-06 06:57:39 +08:00
Make everything share DropDown implementations again. Remove unnecessary files.
This commit is contained in:
parent
64825c32c5
commit
110bdbd0c1
@ -21,6 +21,17 @@ namespace osu.Game.Graphics.UserInterface
|
||||
set { label.Text = value; }
|
||||
}
|
||||
|
||||
private Color4? accentColour;
|
||||
public virtual Color4 AccentColour
|
||||
{
|
||||
get { return accentColour.GetValueOrDefault(); }
|
||||
set
|
||||
{
|
||||
accentColour = value;
|
||||
BackgroundColourHover = value;
|
||||
}
|
||||
}
|
||||
|
||||
public OsuDropDownHeader()
|
||||
{
|
||||
Foreground.Padding = new MarginPadding(4);
|
||||
@ -30,7 +41,7 @@ namespace osu.Game.Graphics.UserInterface
|
||||
CornerRadius = 4;
|
||||
Height = 40;
|
||||
|
||||
Children = new[]
|
||||
Foreground.Children = new Drawable[]
|
||||
{
|
||||
label = new OsuSpriteText
|
||||
{
|
||||
@ -51,7 +62,7 @@ namespace osu.Game.Graphics.UserInterface
|
||||
private void load(OsuColour colours)
|
||||
{
|
||||
BackgroundColour = Color4.Black.Opacity(0.5f);
|
||||
BackgroundColourHover = colours.PinkDarker;
|
||||
BackgroundColourHover = accentColour ?? colours.PinkDarker;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,39 +1,61 @@
|
||||
// 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.Linq;
|
||||
using osu.Framework.Allocation;
|
||||
using OpenTK;
|
||||
using OpenTK.Graphics;
|
||||
using osu.Framework.Extensions.Color4Extensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Primitives;
|
||||
using osu.Framework.Graphics.Transforms;
|
||||
using osu.Framework.Graphics.UserInterface;
|
||||
|
||||
namespace osu.Game.Graphics.UserInterface
|
||||
{
|
||||
public class OsuDropDownMenu<U> : DropDownMenu<U>
|
||||
public class OsuDropDownMenu<T> : DropDownMenu<T>
|
||||
{
|
||||
protected override DropDownHeader CreateHeader() => new OsuDropDownHeader();
|
||||
protected override DropDownHeader CreateHeader() => new OsuDropDownHeader { AccentColour = AccentColour };
|
||||
|
||||
private Color4? accentColour;
|
||||
public virtual Color4 AccentColour
|
||||
{
|
||||
get { return accentColour.GetValueOrDefault(); }
|
||||
set
|
||||
{
|
||||
accentColour = value;
|
||||
if (Header != null)
|
||||
((OsuDropDownHeader)Header).AccentColour = value;
|
||||
foreach (var item in ItemList.OfType<OsuDropDownMenuItem<T>>())
|
||||
item.AccentColour = value;
|
||||
}
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours)
|
||||
{
|
||||
if (accentColour == null)
|
||||
AccentColour = colours.PinkDarker;
|
||||
}
|
||||
|
||||
public OsuDropDownMenu()
|
||||
{
|
||||
ContentContainer.CornerRadius = 4;
|
||||
ContentBackground.Colour = Color4.Black.Opacity(0.5f);
|
||||
|
||||
DropDownItemsContainer.Padding = new MarginPadding(5);
|
||||
}
|
||||
|
||||
protected override void AnimateOpen()
|
||||
{
|
||||
ContentContainer.FadeIn(300, EasingTypes.OutQuint);
|
||||
}
|
||||
protected override void AnimateOpen() => ContentContainer.FadeIn(300, EasingTypes.OutQuint);
|
||||
|
||||
protected override void AnimateClose()
|
||||
{
|
||||
ContentContainer.FadeOut(300, EasingTypes.OutQuint);
|
||||
}
|
||||
protected override void AnimateClose() => ContentContainer.FadeOut(300, EasingTypes.OutQuint);
|
||||
|
||||
protected override void UpdateContentHeight()
|
||||
{
|
||||
ContentContainer.ResizeTo(State == DropDownMenuState.Opened ? new Vector2(1, ContentHeight) : new Vector2(1, 0), 300, EasingTypes.OutQuint);
|
||||
var actualHeight = (RelativeSizeAxes & Axes.Y) > 0 ? 1 : ContentHeight;
|
||||
ContentContainer.ResizeTo(new Vector2(1, State == DropDownMenuState.Opened ? actualHeight : 0), 300, EasingTypes.OutQuint);
|
||||
}
|
||||
|
||||
protected override DropDownMenuItem<U> CreateDropDownItem(string key, U value) => new OsuDropDownMenuItem<U>(key, value);
|
||||
protected override DropDownMenuItem<T> CreateDropDownItem(string key, T value) => new OsuDropDownMenuItem<T>(key, value) { AccentColour = AccentColour };
|
||||
}
|
||||
}
|
@ -18,6 +18,9 @@ namespace osu.Game.Graphics.UserInterface
|
||||
{
|
||||
Foreground.Padding = new MarginPadding(2);
|
||||
|
||||
Masking = true;
|
||||
CornerRadius = 6;
|
||||
|
||||
Children = new[]
|
||||
{
|
||||
new FillFlowContainer
|
||||
@ -27,12 +30,15 @@ namespace osu.Game.Graphics.UserInterface
|
||||
AutoSizeAxes = Axes.Y,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new TextAwesome
|
||||
chevron = new TextAwesome
|
||||
{
|
||||
AlwaysPresent = true,
|
||||
Icon = FontAwesome.fa_chevron_right,
|
||||
UseFullGlyphHeight = false,
|
||||
Colour = Color4.Black,
|
||||
TextSize = 12,
|
||||
Margin = new MarginPadding { Right = 3 },
|
||||
Alpha = 0.5f,
|
||||
TextSize = 8,
|
||||
Margin = new MarginPadding { Left = 3, Right = 3 },
|
||||
Origin = Anchor.CentreLeft,
|
||||
Anchor = Anchor.CentreLeft,
|
||||
},
|
||||
@ -46,11 +52,33 @@ namespace osu.Game.Graphics.UserInterface
|
||||
};
|
||||
}
|
||||
|
||||
private Color4? accentColour;
|
||||
|
||||
private TextAwesome chevron;
|
||||
|
||||
protected override void FormatForeground(bool hover = false)
|
||||
{
|
||||
base.FormatForeground(hover);
|
||||
chevron.Alpha = hover ? 1 : 0;
|
||||
}
|
||||
|
||||
public Color4 AccentColour
|
||||
{
|
||||
get { return accentColour.GetValueOrDefault(); }
|
||||
set
|
||||
{
|
||||
accentColour = value;
|
||||
BackgroundColourHover = BackgroundColourSelected = value;
|
||||
FormatBackground();
|
||||
FormatForeground();
|
||||
}
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours)
|
||||
{
|
||||
BackgroundColour = Color4.Black.Opacity(0.5f);
|
||||
BackgroundColourHover = colours.PinkDarker;
|
||||
BackgroundColour = Color4.Transparent;
|
||||
BackgroundColourHover = accentColour ?? colours.PinkDarker;
|
||||
BackgroundColourSelected = Color4.Black.Opacity(0.5f);
|
||||
}
|
||||
}
|
||||
|
@ -5,18 +5,24 @@ using System;
|
||||
using System.Linq;
|
||||
using OpenTK.Graphics;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics.UserInterface.Tab;
|
||||
using osu.Framework.Extensions.Color4Extensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Primitives;
|
||||
using osu.Framework.Graphics.UserInterface;
|
||||
using osu.Framework.Input;
|
||||
|
||||
namespace osu.Game.Graphics.UserInterface
|
||||
{
|
||||
public class OsuTabControl<T> : TabControl<T>
|
||||
{
|
||||
protected override TabDropDownMenu<T> CreateDropDownMenu() => new OsuTabDropDownMenu<T>();
|
||||
protected override DropDownMenu<T> CreateDropDownMenu() => new OsuTabDropDownMenu<T>();
|
||||
|
||||
protected override TabItem<T> CreateTabItem(T value) => new OsuTabItem<T> { Value = value };
|
||||
|
||||
public OsuTabControl()
|
||||
{
|
||||
AlwaysReceiveInput = true;
|
||||
|
||||
if (!typeof(T).IsEnum)
|
||||
throw new InvalidOperationException("OsuTabControl only supports enums as the generic type argument");
|
||||
|
||||
@ -45,5 +51,88 @@ namespace osu.Game.Graphics.UserInterface
|
||||
item.AccentColour = value;
|
||||
}
|
||||
}
|
||||
|
||||
public class OsuTabDropDownMenu<T1> : OsuDropDownMenu<T1>
|
||||
{
|
||||
protected override DropDownHeader CreateHeader() => new OsuTabDropDownHeader
|
||||
{
|
||||
AccentColour = AccentColour,
|
||||
Anchor = Anchor.TopRight,
|
||||
Origin = Anchor.TopRight,
|
||||
};
|
||||
|
||||
protected override DropDownMenuItem<T1> CreateDropDownItem(string key, T1 value)
|
||||
{
|
||||
var item = base.CreateDropDownItem(key, value);
|
||||
item.ForegroundColourHover = Color4.Black;
|
||||
return item;
|
||||
}
|
||||
|
||||
public OsuTabDropDownMenu()
|
||||
{
|
||||
ContentContainer.Anchor = Anchor.TopRight;
|
||||
ContentContainer.Origin = Anchor.TopRight;
|
||||
|
||||
RelativeSizeAxes = Axes.X;
|
||||
|
||||
ContentBackground.Colour = Color4.Black.Opacity(0.7f);
|
||||
MaxDropDownHeight = 400;
|
||||
}
|
||||
|
||||
public class OsuTabDropDownHeader : OsuDropDownHeader
|
||||
{
|
||||
public override Color4 AccentColour
|
||||
{
|
||||
get { return base.AccentColour; }
|
||||
set
|
||||
{
|
||||
base.AccentColour = 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.Opacity(0.5f);
|
||||
|
||||
Background.Height = 0.5f;
|
||||
Background.CornerRadius = 5;
|
||||
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 };
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,130 +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.Linq;
|
||||
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>
|
||||
{
|
||||
private Color4? accentColour;
|
||||
public Color4 AccentColour
|
||||
{
|
||||
get { return accentColour.GetValueOrDefault(); }
|
||||
set
|
||||
{
|
||||
accentColour = value;
|
||||
((OsuTabDropDownHeader)Header).AccentColour = value;
|
||||
foreach (var item in ItemList.OfType<OsuTabDropDownMenuItem<T>>())
|
||||
item.AccentColour = value;
|
||||
}
|
||||
}
|
||||
|
||||
protected override DropDownHeader CreateHeader() => new OsuTabDropDownHeader
|
||||
{
|
||||
AccentColour = AccentColour
|
||||
};
|
||||
|
||||
protected override DropDownMenuItem<T> CreateDropDownItem(string key, T value) =>
|
||||
new OsuTabDropDownMenuItem<T>(key, value) { AccentColour = AccentColour };
|
||||
|
||||
public OsuTabDropDownMenu()
|
||||
{
|
||||
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)
|
||||
{
|
||||
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 };
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,54 +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 OpenTK.Graphics;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
|
||||
namespace osu.Game.Graphics.UserInterface
|
||||
{
|
||||
public class OsuTabDropDownMenuItem<T> : DropDownMenuItem<T>
|
||||
{
|
||||
public OsuTabDropDownMenuItem(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,
|
||||
});
|
||||
}
|
||||
|
||||
private Color4? accentColour;
|
||||
public Color4 AccentColour
|
||||
{
|
||||
get { return accentColour.GetValueOrDefault(); }
|
||||
set
|
||||
{
|
||||
accentColour = value;
|
||||
BackgroundColourHover = BackgroundColourSelected = value;
|
||||
FormatBackground();
|
||||
FormatForeground();
|
||||
}
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours)
|
||||
{
|
||||
BackgroundColour = Color4.Black.Opacity(0f);
|
||||
ForegroundColourHover = Color4.Black;
|
||||
ForegroundColourSelected = Color4.Black;
|
||||
if (accentColour == null)
|
||||
AccentColour = colours.Blue;
|
||||
}
|
||||
}
|
||||
}
|
@ -8,7 +8,7 @@ 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.Graphics.UserInterface;
|
||||
using osu.Framework.Input;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
|
||||
|
@ -4,7 +4,6 @@
|
||||
using System.Linq;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using OpenTK;
|
||||
using OpenTK.Graphics;
|
||||
using osu.Framework.Input;
|
||||
|
||||
|
@ -2,7 +2,6 @@
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using osu.Framework.Input;
|
||||
using OpenTK;
|
||||
using OpenTK.Input;
|
||||
|
||||
namespace osu.Game.Screens.Play
|
||||
|
@ -9,11 +9,11 @@ using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Primitives;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Graphics.UserInterface;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Screens.Select.Filter;
|
||||
using Container = osu.Framework.Graphics.Containers.Container;
|
||||
using osu.Framework.Graphics.UserInterface.Tab;
|
||||
using osu.Framework.Input;
|
||||
|
||||
namespace osu.Game.Screens.Select
|
||||
|
@ -350,8 +350,6 @@
|
||||
<Compile Include="Screens\Select\Options\BeatmapOptionsButton.cs" />
|
||||
<Compile Include="Screens\Select\Options\BeatmapOptionsOverlay.cs" />
|
||||
<Compile Include="Graphics\UserInterface\OsuTabControl.cs" />
|
||||
<Compile Include="Graphics\UserInterface\OsuTabDropDownMenu.cs" />
|
||||
<Compile Include="Graphics\UserInterface\OsuTabDropDownMenuItem.cs" />
|
||||
<Compile Include="Graphics\UserInterface\OsuTabItem.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
Loading…
Reference in New Issue
Block a user