2017-08-28 16:55:50 +08:00
|
|
|
|
// 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.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
|
using osu.Framework.Graphics.Shapes;
|
|
|
|
|
using osu.Framework.Graphics.UserInterface;
|
2017-09-06 20:14:29 +08:00
|
|
|
|
using osu.Framework.Input;
|
2017-08-28 16:55:50 +08:00
|
|
|
|
using osu.Game.Graphics;
|
|
|
|
|
using osu.Game.Graphics.UserInterface;
|
|
|
|
|
using OpenTK;
|
|
|
|
|
using OpenTK.Graphics;
|
|
|
|
|
|
|
|
|
|
namespace osu.Game.Screens.Edit.Menus
|
|
|
|
|
{
|
2017-09-06 20:14:29 +08:00
|
|
|
|
public class EditorMenuBar : OsuMenu
|
2017-08-28 16:55:50 +08:00
|
|
|
|
{
|
2017-09-06 20:14:29 +08:00
|
|
|
|
public EditorMenuBar()
|
|
|
|
|
: base(Direction.Horizontal)
|
2017-08-28 16:55:50 +08:00
|
|
|
|
{
|
2017-09-06 20:14:29 +08:00
|
|
|
|
AlwaysOpen = true;
|
|
|
|
|
RequireClickToOpen = true;
|
|
|
|
|
|
|
|
|
|
ItemsContainer.Padding = new MarginPadding(0);
|
|
|
|
|
BackgroundColour = Color4.Transparent;
|
|
|
|
|
}
|
2017-08-28 16:55:50 +08:00
|
|
|
|
|
2017-09-06 20:14:29 +08:00
|
|
|
|
protected override Framework.Graphics.UserInterface.Menu CreateSubMenu() => new SubMenu();
|
2017-08-28 16:55:50 +08:00
|
|
|
|
|
2017-09-06 20:14:29 +08:00
|
|
|
|
protected override DrawableMenuItem CreateDrawableMenuItem(MenuItem item) => new DrawableEditorBarMenuItem(item);
|
2017-08-28 16:55:50 +08:00
|
|
|
|
|
2017-09-06 20:14:29 +08:00
|
|
|
|
private class DrawableEditorBarMenuItem : DrawableOsuMenuItem
|
|
|
|
|
{
|
|
|
|
|
private Color4 openedForegroundColour;
|
|
|
|
|
private Color4 openedBackgroundColour;
|
|
|
|
|
|
|
|
|
|
public DrawableEditorBarMenuItem(MenuItem item)
|
2017-08-28 16:55:50 +08:00
|
|
|
|
: base(item)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load(OsuColour colours)
|
|
|
|
|
{
|
2017-09-06 20:14:29 +08:00
|
|
|
|
ForegroundColour = ForegroundColourHover = colours.BlueLight;
|
|
|
|
|
BackgroundColour = BackgroundColourHover = Color4.Transparent;
|
|
|
|
|
openedForegroundColour = Color4.White;
|
|
|
|
|
openedBackgroundColour = colours.Gray3;
|
2017-08-28 16:55:50 +08:00
|
|
|
|
}
|
|
|
|
|
|
2017-09-06 20:14:29 +08:00
|
|
|
|
protected override void UpdateBackgroundColour()
|
2017-08-28 16:55:50 +08:00
|
|
|
|
{
|
2017-09-06 20:14:29 +08:00
|
|
|
|
if (State == MenuItemState.Selected)
|
|
|
|
|
Background.FadeColour(openedBackgroundColour);
|
|
|
|
|
else
|
|
|
|
|
base.UpdateBackgroundColour();
|
2017-08-28 16:55:50 +08:00
|
|
|
|
}
|
|
|
|
|
|
2017-09-06 20:14:29 +08:00
|
|
|
|
protected override void UpdateForegroundColour()
|
2017-08-28 16:55:50 +08:00
|
|
|
|
{
|
2017-09-06 20:14:29 +08:00
|
|
|
|
if (State == MenuItemState.Selected)
|
|
|
|
|
Foreground.FadeColour(openedForegroundColour);
|
|
|
|
|
else
|
|
|
|
|
base.UpdateForegroundColour();
|
2017-08-28 16:55:50 +08:00
|
|
|
|
}
|
|
|
|
|
|
2017-09-06 20:14:29 +08:00
|
|
|
|
protected override Drawable CreateBackground() => new Container
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Masking = true,
|
|
|
|
|
Child = new Container
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Height = 2,
|
|
|
|
|
Masking = true,
|
|
|
|
|
CornerRadius = 4,
|
|
|
|
|
Child = new Box { RelativeSizeAxes = Axes.Both }
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
}
|
2017-08-28 16:55:50 +08:00
|
|
|
|
|
2017-09-06 20:14:29 +08:00
|
|
|
|
private class SubMenu : OsuMenu
|
|
|
|
|
{
|
|
|
|
|
public SubMenu()
|
|
|
|
|
: base(Direction.Vertical)
|
|
|
|
|
{
|
|
|
|
|
OriginPosition = new Vector2(5, 1);
|
|
|
|
|
ItemsContainer.Padding = new MarginPadding { Top = 5, Bottom = 5 };
|
|
|
|
|
}
|
2017-08-28 16:55:50 +08:00
|
|
|
|
|
2017-09-06 20:14:29 +08:00
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load(OsuColour colours)
|
2017-08-28 16:55:50 +08:00
|
|
|
|
{
|
2017-09-06 20:14:29 +08:00
|
|
|
|
BackgroundColour = colours.Gray3;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override Framework.Graphics.UserInterface.Menu CreateSubMenu() => new SubMenu();
|
|
|
|
|
|
|
|
|
|
protected override DrawableMenuItem CreateDrawableMenuItem(MenuItem item) => new DrawableSubMenuItem(item);
|
|
|
|
|
|
|
|
|
|
private class DrawableSubMenuItem : DrawableOsuMenuItem
|
|
|
|
|
{
|
|
|
|
|
public DrawableSubMenuItem(MenuItem item)
|
|
|
|
|
: base(item)
|
2017-08-28 16:55:50 +08:00
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2017-09-06 20:14:29 +08:00
|
|
|
|
protected override bool OnHover(InputState state)
|
2017-08-28 16:55:50 +08:00
|
|
|
|
{
|
2017-09-06 20:14:29 +08:00
|
|
|
|
if (Item is EditorMenuSpacer)
|
|
|
|
|
return true;
|
|
|
|
|
return base.OnHover(state);
|
2017-08-28 16:55:50 +08:00
|
|
|
|
}
|
|
|
|
|
|
2017-09-06 20:14:29 +08:00
|
|
|
|
protected override bool OnClick(InputState state)
|
2017-08-28 16:55:50 +08:00
|
|
|
|
{
|
2017-09-06 20:14:29 +08:00
|
|
|
|
if (Item is EditorMenuSpacer)
|
|
|
|
|
return true;
|
|
|
|
|
return base.OnClick(state);
|
2017-08-28 16:55:50 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|