mirror of
https://github.com/osukey/osukey.git
synced 2025-08-04 07:06:35 +09:00
Remove intermediate Screens namespace
This commit is contained in:
189
osu.Game/Screens/Edit/Components/Menus/EditorMenuBar.cs
Normal file
189
osu.Game/Screens/Edit/Components/Menus/EditorMenuBar.cs
Normal file
@ -0,0 +1,189 @@
|
||||
// Copyright (c) 2007-2018 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.Configuration;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Graphics.UserInterface;
|
||||
using osu.Framework.Input.Events;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using OpenTK;
|
||||
using OpenTK.Graphics;
|
||||
|
||||
namespace osu.Game.Screens.Edit.Components.Menus
|
||||
{
|
||||
public class EditorMenuBar : OsuMenu
|
||||
{
|
||||
public readonly Bindable<EditorScreenMode> Mode = new Bindable<EditorScreenMode>();
|
||||
|
||||
public EditorMenuBar()
|
||||
: base(Direction.Horizontal, true)
|
||||
{
|
||||
RelativeSizeAxes = Axes.X;
|
||||
|
||||
MaskingContainer.CornerRadius = 0;
|
||||
ItemsContainer.Padding = new MarginPadding { Left = 100 };
|
||||
BackgroundColour = OsuColour.FromHex("111");
|
||||
|
||||
ScreenSelectionTabControl tabControl;
|
||||
AddRangeInternal(new Drawable[]
|
||||
{
|
||||
tabControl = new ScreenSelectionTabControl
|
||||
{
|
||||
Anchor = Anchor.BottomRight,
|
||||
Origin = Anchor.BottomRight,
|
||||
X = -15
|
||||
}
|
||||
});
|
||||
|
||||
Mode.BindTo(tabControl.Current);
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
Mode.TriggerChange();
|
||||
}
|
||||
|
||||
protected override Framework.Graphics.UserInterface.Menu CreateSubMenu() => new SubMenu();
|
||||
|
||||
protected override DrawableMenuItem CreateDrawableMenuItem(MenuItem item) => new DrawableEditorBarMenuItem(item);
|
||||
|
||||
private class DrawableEditorBarMenuItem : DrawableOsuMenuItem
|
||||
{
|
||||
private BackgroundBox background;
|
||||
|
||||
public DrawableEditorBarMenuItem(MenuItem item)
|
||||
: base(item)
|
||||
{
|
||||
Anchor = Anchor.CentreLeft;
|
||||
Origin = Anchor.CentreLeft;
|
||||
|
||||
StateChanged += stateChanged;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours)
|
||||
{
|
||||
ForegroundColour = colours.BlueLight;
|
||||
BackgroundColour = Color4.Transparent;
|
||||
ForegroundColourHover = Color4.White;
|
||||
BackgroundColourHover = colours.Gray3;
|
||||
}
|
||||
|
||||
public override void SetFlowDirection(Direction direction)
|
||||
{
|
||||
AutoSizeAxes = Axes.Both;
|
||||
}
|
||||
|
||||
protected override void UpdateBackgroundColour()
|
||||
{
|
||||
if (State == MenuItemState.Selected)
|
||||
Background.FadeColour(BackgroundColourHover);
|
||||
else
|
||||
base.UpdateBackgroundColour();
|
||||
}
|
||||
|
||||
protected override void UpdateForegroundColour()
|
||||
{
|
||||
if (State == MenuItemState.Selected)
|
||||
Foreground.FadeColour(ForegroundColourHover);
|
||||
else
|
||||
base.UpdateForegroundColour();
|
||||
}
|
||||
|
||||
private void stateChanged(MenuItemState newState)
|
||||
{
|
||||
if (newState == MenuItemState.Selected)
|
||||
background.Expand();
|
||||
else
|
||||
background.Contract();
|
||||
}
|
||||
|
||||
protected override Drawable CreateBackground() => background = new BackgroundBox();
|
||||
protected override DrawableOsuMenuItem.TextContainer CreateTextContainer() => new TextContainer();
|
||||
|
||||
private new class TextContainer : DrawableOsuMenuItem.TextContainer
|
||||
{
|
||||
public TextContainer()
|
||||
{
|
||||
NormalText.TextSize = BoldText.TextSize = 14;
|
||||
NormalText.Margin = BoldText.Margin = new MarginPadding { Horizontal = 10, Vertical = MARGIN_VERTICAL };
|
||||
}
|
||||
}
|
||||
|
||||
private class BackgroundBox : CompositeDrawable
|
||||
{
|
||||
private readonly Container innerBackground;
|
||||
|
||||
public BackgroundBox()
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both;
|
||||
Masking = true;
|
||||
InternalChild = innerBackground = new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Masking = true,
|
||||
CornerRadius = 4,
|
||||
Child = new Box { RelativeSizeAxes = Axes.Both }
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Expands the background such that it doesn't show the bottom corners.
|
||||
/// </summary>
|
||||
public void Expand() => innerBackground.Height = 2;
|
||||
|
||||
/// <summary>
|
||||
/// Contracts the background such that it shows the bottom corners.
|
||||
/// </summary>
|
||||
public void Contract() => innerBackground.Height = 1;
|
||||
}
|
||||
}
|
||||
|
||||
private class SubMenu : OsuMenu
|
||||
{
|
||||
public SubMenu()
|
||||
: base(Direction.Vertical)
|
||||
{
|
||||
OriginPosition = new Vector2(5, 1);
|
||||
ItemsContainer.Padding = new MarginPadding { Top = 5, Bottom = 5 };
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours)
|
||||
{
|
||||
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)
|
||||
{
|
||||
}
|
||||
|
||||
protected override bool OnHover(HoverEvent e)
|
||||
{
|
||||
if (Item is EditorMenuItemSpacer)
|
||||
return true;
|
||||
return base.OnHover(e);
|
||||
}
|
||||
|
||||
protected override bool OnClick(ClickEvent e)
|
||||
{
|
||||
if (Item is EditorMenuItemSpacer)
|
||||
return true;
|
||||
return base.OnClick(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
23
osu.Game/Screens/Edit/Components/Menus/EditorMenuItem.cs
Normal file
23
osu.Game/Screens/Edit/Components/Menus/EditorMenuItem.cs
Normal file
@ -0,0 +1,23 @@
|
||||
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using System;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
|
||||
namespace osu.Game.Screens.Edit.Components.Menus
|
||||
{
|
||||
public class EditorMenuItem : OsuMenuItem
|
||||
{
|
||||
private const int min_text_length = 40;
|
||||
|
||||
public EditorMenuItem(string text, MenuItemType type = MenuItemType.Standard)
|
||||
: base(text.PadRight(min_text_length), type)
|
||||
{
|
||||
}
|
||||
|
||||
public EditorMenuItem(string text, MenuItemType type, Action action)
|
||||
: base(text.PadRight(min_text_length), type, action)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
namespace osu.Game.Screens.Edit.Components.Menus
|
||||
{
|
||||
public class EditorMenuItemSpacer : EditorMenuItem
|
||||
{
|
||||
public EditorMenuItemSpacer()
|
||||
: base(" ")
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,74 @@
|
||||
// Copyright (c) 2007-2018 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.Shapes;
|
||||
using osu.Framework.Graphics.UserInterface;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using OpenTK;
|
||||
using OpenTK.Graphics;
|
||||
|
||||
namespace osu.Game.Screens.Edit.Components.Menus
|
||||
{
|
||||
public class ScreenSelectionTabControl : OsuTabControl<EditorScreenMode>
|
||||
{
|
||||
public ScreenSelectionTabControl()
|
||||
{
|
||||
AutoSizeAxes = Axes.X;
|
||||
RelativeSizeAxes = Axes.Y;
|
||||
|
||||
TabContainer.RelativeSizeAxes &= ~Axes.X;
|
||||
TabContainer.AutoSizeAxes = Axes.X;
|
||||
TabContainer.Padding = new MarginPadding();
|
||||
|
||||
AddInternal(new Box
|
||||
{
|
||||
Anchor = Anchor.BottomLeft,
|
||||
Origin = Anchor.BottomLeft,
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Height = 1,
|
||||
Colour = Color4.White.Opacity(0.2f),
|
||||
});
|
||||
|
||||
Current.Value = EditorScreenMode.Compose;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours)
|
||||
{
|
||||
AccentColour = colours.Yellow;
|
||||
}
|
||||
|
||||
protected override Dropdown<EditorScreenMode> CreateDropdown() => null;
|
||||
|
||||
protected override TabItem<EditorScreenMode> CreateTabItem(EditorScreenMode value) => new TabItem(value);
|
||||
|
||||
private class TabItem : OsuTabItem
|
||||
{
|
||||
private const float transition_length = 250;
|
||||
|
||||
public TabItem(EditorScreenMode value)
|
||||
: base(value)
|
||||
{
|
||||
Text.Margin = new MarginPadding();
|
||||
Text.Anchor = Anchor.CentreLeft;
|
||||
Text.Origin = Anchor.CentreLeft;
|
||||
}
|
||||
|
||||
protected override void OnActivated()
|
||||
{
|
||||
base.OnActivated();
|
||||
Bar.ScaleTo(new Vector2(1, 5), transition_length, Easing.OutQuint);
|
||||
}
|
||||
|
||||
protected override void OnDeactivated()
|
||||
{
|
||||
base.OnDeactivated();
|
||||
Bar.ScaleTo(Vector2.One, transition_length, Easing.OutQuint);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user