Initial right click context menu implementation

This commit is contained in:
smoogipoo
2019-11-07 22:51:49 +09:00
parent 92d8526370
commit abb3a6ca5b
3 changed files with 162 additions and 70 deletions

View File

@ -17,6 +17,7 @@ using osu.Game.Rulesets.Edit.Tools;
using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Objects.Drawables;
using osuTK;
using osuTK.Input;
namespace osu.Game.Screens.Edit.Compose.Components
{
@ -95,12 +96,18 @@ namespace osu.Game.Screens.Edit.Compose.Components
protected override bool OnMouseDown(MouseDownEvent e)
{
if (e.Button == MouseButton.Right)
return false;
beginClickSelection(e);
return true;
}
protected override bool OnClick(ClickEvent e)
{
if (e.Button == MouseButton.Right)
return false;
// Deselection should only occur if no selected blueprints are hovered
// A special case for when a blueprint was selected via this click is added since OnClick() may occur outside the hitobject and should not trigger deselection
if (endClickSelection() || selectionHandler.SelectedBlueprints.Any(b => b.IsHovered))
@ -112,6 +119,9 @@ namespace osu.Game.Screens.Edit.Compose.Components
protected override bool OnDoubleClick(DoubleClickEvent e)
{
if (e.Button == MouseButton.Right)
return false;
SelectionBlueprint clickedBlueprint = selectionHandler.SelectedBlueprints.FirstOrDefault(b => b.IsHovered);
if (clickedBlueprint == null)
@ -123,6 +133,9 @@ namespace osu.Game.Screens.Edit.Compose.Components
protected override bool OnMouseUp(MouseUpEvent e)
{
if (e.Button == MouseButton.Right)
return false;
// Special case for when a drag happened instead of a click
Schedule(() => endClickSelection());
return true;
@ -141,6 +154,9 @@ namespace osu.Game.Screens.Edit.Compose.Components
protected override bool OnDragStart(DragStartEvent e)
{
if (e.Button == MouseButton.Right)
return false;
if (!beginSelectionMovement())
{
dragBox.UpdateDrag(e);
@ -152,6 +168,9 @@ namespace osu.Game.Screens.Edit.Compose.Components
protected override bool OnDrag(DragEvent e)
{
if (e.Button == MouseButton.Right)
return false;
if (!moveCurrentSelection(e))
dragBox.UpdateDrag(e);
@ -160,6 +179,9 @@ namespace osu.Game.Screens.Edit.Compose.Components
protected override bool OnDragEnd(DragEndEvent e)
{
if (e.Button == MouseButton.Right)
return false;
if (!finishSelectionMovement())
{
dragBox.FadeOut(250, Easing.OutQuint);