mirror of
https://github.com/osukey/osukey.git
synced 2025-07-01 16:29:58 +09:00
Move OsuTabDropdown to it's own file
This commit is contained in:
@ -39,7 +39,7 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
|
|
||||||
private readonly Box strip;
|
private readonly Box strip;
|
||||||
|
|
||||||
protected override Dropdown<T> CreateDropdown() => new OsuTabDropdown();
|
protected override Dropdown<T> CreateDropdown() => new OsuTabDropdown<T>();
|
||||||
|
|
||||||
protected override TabItem<T> CreateTabItem(T value) => new OsuTabItem(value);
|
protected override TabItem<T> CreateTabItem(T value) => new OsuTabItem(value);
|
||||||
|
|
||||||
@ -180,100 +180,5 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
|
|
||||||
protected override void OnDeactivated() => fadeInactive();
|
protected override void OnDeactivated() => fadeInactive();
|
||||||
}
|
}
|
||||||
|
|
||||||
// todo: this needs to go
|
|
||||||
private class OsuTabDropdown : OsuDropdown<T>
|
|
||||||
{
|
|
||||||
public OsuTabDropdown()
|
|
||||||
{
|
|
||||||
RelativeSizeAxes = Axes.X;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override DropdownMenu CreateMenu() => new OsuTabDropdownMenu();
|
|
||||||
|
|
||||||
protected override DropdownHeader CreateHeader() => new OsuTabDropdownHeader
|
|
||||||
{
|
|
||||||
Anchor = Anchor.TopRight,
|
|
||||||
Origin = Anchor.TopRight
|
|
||||||
};
|
|
||||||
|
|
||||||
private class OsuTabDropdownMenu : OsuDropdownMenu
|
|
||||||
{
|
|
||||||
public OsuTabDropdownMenu()
|
|
||||||
{
|
|
||||||
Anchor = Anchor.TopRight;
|
|
||||||
Origin = Anchor.TopRight;
|
|
||||||
|
|
||||||
BackgroundColour = Color4.Black.Opacity(0.7f);
|
|
||||||
MaxHeight = 400;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override DrawableDropdownMenuItem CreateDrawableDropdownMenuItem(MenuItem item) => new DrawableOsuTabDropdownMenuItem(item) { AccentColour = AccentColour };
|
|
||||||
|
|
||||||
private class DrawableOsuTabDropdownMenuItem : DrawableOsuDropdownMenuItem
|
|
||||||
{
|
|
||||||
public DrawableOsuTabDropdownMenuItem(MenuItem item)
|
|
||||||
: base(item)
|
|
||||||
{
|
|
||||||
ForegroundColourHover = Color4.Black;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected class OsuTabDropdownHeader : OsuDropdownHeader
|
|
||||||
{
|
|
||||||
public override Color4 AccentColour
|
|
||||||
{
|
|
||||||
get => base.AccentColour;
|
|
||||||
set
|
|
||||||
{
|
|
||||||
base.AccentColour = value;
|
|
||||||
Foreground.Colour = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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 SpriteIcon
|
|
||||||
{
|
|
||||||
Icon = FontAwesome.Solid.EllipsisH,
|
|
||||||
Size = new Vector2(14),
|
|
||||||
Origin = Anchor.Centre,
|
|
||||||
Anchor = Anchor.Centre,
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
Padding = new MarginPadding { Left = 5, Right = 5 };
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override bool OnHover(HoverEvent e)
|
|
||||||
{
|
|
||||||
Foreground.Colour = BackgroundColour;
|
|
||||||
return base.OnHover(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void OnHoverLost(HoverLostEvent e)
|
|
||||||
{
|
|
||||||
Foreground.Colour = BackgroundColourHover;
|
|
||||||
base.OnHoverLost(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
107
osu.Game/Graphics/UserInterface/OsuTabDropdown.cs
Normal file
107
osu.Game/Graphics/UserInterface/OsuTabDropdown.cs
Normal file
@ -0,0 +1,107 @@
|
|||||||
|
// 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.
|
||||||
|
|
||||||
|
using osuTK;
|
||||||
|
using osuTK.Graphics;
|
||||||
|
using osu.Framework.Extensions.Color4Extensions;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Graphics.Sprites;
|
||||||
|
using osu.Framework.Graphics.UserInterface;
|
||||||
|
using osu.Framework.Input.Events;
|
||||||
|
|
||||||
|
namespace osu.Game.Graphics.UserInterface
|
||||||
|
{
|
||||||
|
public class OsuTabDropdown<T> : OsuDropdown<T>
|
||||||
|
{
|
||||||
|
public OsuTabDropdown()
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.X;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override DropdownMenu CreateMenu() => new OsuTabDropdownMenu();
|
||||||
|
|
||||||
|
protected override DropdownHeader CreateHeader() => new OsuTabDropdownHeader
|
||||||
|
{
|
||||||
|
Anchor = Anchor.TopRight,
|
||||||
|
Origin = Anchor.TopRight
|
||||||
|
};
|
||||||
|
|
||||||
|
private class OsuTabDropdownMenu : OsuDropdownMenu
|
||||||
|
{
|
||||||
|
public OsuTabDropdownMenu()
|
||||||
|
{
|
||||||
|
Anchor = Anchor.TopRight;
|
||||||
|
Origin = Anchor.TopRight;
|
||||||
|
|
||||||
|
BackgroundColour = Color4.Black.Opacity(0.7f);
|
||||||
|
MaxHeight = 400;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override DrawableDropdownMenuItem CreateDrawableDropdownMenuItem(MenuItem item) => new DrawableOsuTabDropdownMenuItem(item) { AccentColour = AccentColour };
|
||||||
|
|
||||||
|
private class DrawableOsuTabDropdownMenuItem : DrawableOsuDropdownMenuItem
|
||||||
|
{
|
||||||
|
public DrawableOsuTabDropdownMenuItem(MenuItem item)
|
||||||
|
: base(item)
|
||||||
|
{
|
||||||
|
ForegroundColourHover = Color4.Black;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected class OsuTabDropdownHeader : OsuDropdownHeader
|
||||||
|
{
|
||||||
|
public override Color4 AccentColour
|
||||||
|
{
|
||||||
|
get => base.AccentColour;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
base.AccentColour = value;
|
||||||
|
Foreground.Colour = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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 SpriteIcon
|
||||||
|
{
|
||||||
|
Icon = FontAwesome.Solid.EllipsisH,
|
||||||
|
Size = new Vector2(14),
|
||||||
|
Origin = Anchor.Centre,
|
||||||
|
Anchor = Anchor.Centre,
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
Padding = new MarginPadding { Left = 5, Right = 5 };
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override bool OnHover(HoverEvent e)
|
||||||
|
{
|
||||||
|
Foreground.Colour = BackgroundColour;
|
||||||
|
return base.OnHover(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void OnHoverLost(HoverLostEvent e)
|
||||||
|
{
|
||||||
|
Foreground.Colour = BackgroundColourHover;
|
||||||
|
base.OnHoverLost(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user