From 09c51df2bd1da9f76a306bc2383a86c1a034fa0f Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Mon, 18 Dec 2017 19:21:26 +0900 Subject: [PATCH] Marker* -> Handle --- .../Layers/Selection/{Marker.cs => Handle.cs} | 210 +++++++++--------- ...{MarkerContainer.cs => HandleContainer.cs} | 32 +-- .../Layers/Selection/HitObjectSelectionBox.cs | 6 +- .../{CentreMarker.cs => OriginHandle.cs} | 6 +- osu.Game/osu.Game.csproj | 6 +- 5 files changed, 130 insertions(+), 130 deletions(-) rename osu.Game/Rulesets/Edit/Layers/Selection/{Marker.cs => Handle.cs} (88%) rename osu.Game/Rulesets/Edit/Layers/Selection/{MarkerContainer.cs => HandleContainer.cs} (74%) rename osu.Game/Rulesets/Edit/Layers/Selection/{CentreMarker.cs => OriginHandle.cs} (86%) diff --git a/osu.Game/Rulesets/Edit/Layers/Selection/Marker.cs b/osu.Game/Rulesets/Edit/Layers/Selection/Handle.cs similarity index 88% rename from osu.Game/Rulesets/Edit/Layers/Selection/Marker.cs rename to osu.Game/Rulesets/Edit/Layers/Selection/Handle.cs index 956415a800..e93fe886e1 100644 --- a/osu.Game/Rulesets/Edit/Layers/Selection/Marker.cs +++ b/osu.Game/Rulesets/Edit/Layers/Selection/Handle.cs @@ -1,105 +1,105 @@ -// Copyright (c) 2007-2017 ppy Pty Ltd . -// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE - -using System; -using osu.Framework.Allocation; -using osu.Framework.Graphics; -using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Primitives; -using osu.Framework.Graphics.Shapes; -using osu.Framework.Input; -using osu.Game.Graphics; -using OpenTK; -using OpenTK.Graphics; - -namespace osu.Game.Rulesets.Edit.Layers.Selection -{ - /// - /// Represents a marker visible on the border of a which exposes - /// properties that are used to resize a . - /// - public class Marker : CompositeDrawable - { - private const float marker_size = 10; - - /// - /// Invoked when this requires the current drag rectangle. - /// - public Func GetDragRectangle; - - /// - /// Invoked when this wants to update the drag rectangle. - /// - public Action UpdateDragRectangle; - - /// - /// Invoked when this has finished updates to the drag rectangle. - /// - public Action FinishCapture; - - private Color4 normalColour; - private Color4 hoverColour; - - public Marker() - { - Size = new Vector2(marker_size); - - InternalChild = new CircularContainer - { - RelativeSizeAxes = Axes.Both, - Masking = true, - Child = new Box { RelativeSizeAxes = Axes.Both } - }; - } - - [BackgroundDependencyLoader] - private void load(OsuColour colours) - { - Colour = normalColour = colours.Yellow; - hoverColour = colours.YellowDarker; - } - - protected override bool OnDragStart(InputState state) => true; - - protected override bool OnDrag(InputState state) - { - var currentRectangle = GetDragRectangle(); - - float left = currentRectangle.Left; - float right = currentRectangle.Right; - float top = currentRectangle.Top; - float bottom = currentRectangle.Bottom; - - // Apply modifications to the capture rectangle - if ((Anchor & Anchor.y0) > 0) - top += state.Mouse.Delta.Y; - else if ((Anchor & Anchor.y2) > 0) - bottom += state.Mouse.Delta.Y; - - if ((Anchor & Anchor.x0) > 0) - left += state.Mouse.Delta.X; - else if ((Anchor & Anchor.x2) > 0) - right += state.Mouse.Delta.X; - - UpdateDragRectangle(RectangleF.FromLTRB(left, top, right, bottom)); - return true; - } - - protected override bool OnDragEnd(InputState state) - { - FinishCapture(); - return true; - } - - protected override bool OnHover(InputState state) - { - this.FadeColour(hoverColour, 100); - return true; - } - - protected override void OnHoverLost(InputState state) - { - this.FadeColour(normalColour, 100); - } - } -} +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using System; +using osu.Framework.Allocation; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Primitives; +using osu.Framework.Graphics.Shapes; +using osu.Framework.Input; +using osu.Game.Graphics; +using OpenTK; +using OpenTK.Graphics; + +namespace osu.Game.Rulesets.Edit.Layers.Selection +{ + /// + /// Represents a marker visible on the border of a which exposes + /// properties that are used to resize a . + /// + public class Handle : CompositeDrawable + { + private const float marker_size = 10; + + /// + /// Invoked when this requires the current drag rectangle. + /// + public Func GetDragRectangle; + + /// + /// Invoked when this wants to update the drag rectangle. + /// + public Action UpdateDragRectangle; + + /// + /// Invoked when this has finished updates to the drag rectangle. + /// + public Action FinishCapture; + + private Color4 normalColour; + private Color4 hoverColour; + + public Handle() + { + Size = new Vector2(marker_size); + + InternalChild = new CircularContainer + { + RelativeSizeAxes = Axes.Both, + Masking = true, + Child = new Box { RelativeSizeAxes = Axes.Both } + }; + } + + [BackgroundDependencyLoader] + private void load(OsuColour colours) + { + Colour = normalColour = colours.Yellow; + hoverColour = colours.YellowDarker; + } + + protected override bool OnDragStart(InputState state) => true; + + protected override bool OnDrag(InputState state) + { + var currentRectangle = GetDragRectangle(); + + float left = currentRectangle.Left; + float right = currentRectangle.Right; + float top = currentRectangle.Top; + float bottom = currentRectangle.Bottom; + + // Apply modifications to the capture rectangle + if ((Anchor & Anchor.y0) > 0) + top += state.Mouse.Delta.Y; + else if ((Anchor & Anchor.y2) > 0) + bottom += state.Mouse.Delta.Y; + + if ((Anchor & Anchor.x0) > 0) + left += state.Mouse.Delta.X; + else if ((Anchor & Anchor.x2) > 0) + right += state.Mouse.Delta.X; + + UpdateDragRectangle(RectangleF.FromLTRB(left, top, right, bottom)); + return true; + } + + protected override bool OnDragEnd(InputState state) + { + FinishCapture(); + return true; + } + + protected override bool OnHover(InputState state) + { + this.FadeColour(hoverColour, 100); + return true; + } + + protected override void OnHoverLost(InputState state) + { + this.FadeColour(normalColour, 100); + } + } +} diff --git a/osu.Game/Rulesets/Edit/Layers/Selection/MarkerContainer.cs b/osu.Game/Rulesets/Edit/Layers/Selection/HandleContainer.cs similarity index 74% rename from osu.Game/Rulesets/Edit/Layers/Selection/MarkerContainer.cs rename to osu.Game/Rulesets/Edit/Layers/Selection/HandleContainer.cs index e222583348..f6777908d7 100644 --- a/osu.Game/Rulesets/Edit/Layers/Selection/MarkerContainer.cs +++ b/osu.Game/Rulesets/Edit/Layers/Selection/HandleContainer.cs @@ -11,77 +11,77 @@ using osu.Framework.Graphics.Primitives; namespace osu.Game.Rulesets.Edit.Layers.Selection { /// - /// A that has s around its border. + /// A that has s around its border. /// - public class MarkerContainer : CompositeDrawable + public class HandleContainer : CompositeDrawable { /// - /// Invoked when a requires the current drag rectangle. + /// Invoked when a requires the current drag rectangle. /// public Func GetDragRectangle; /// - /// Invoked when a wants to update the drag rectangle. + /// Invoked when a wants to update the drag rectangle. /// public Action UpdateDragRectangle; /// - /// Invoked when a has finished updates to the drag rectangle. + /// Invoked when a has finished updates to the drag rectangle. /// public Action FinishCapture; - public MarkerContainer() + public HandleContainer() { InternalChildren = new Drawable[] { - new Marker + new Handle { Anchor = Anchor.TopLeft, Origin = Anchor.Centre }, - new Marker + new Handle { Anchor = Anchor.TopCentre, Origin = Anchor.Centre }, - new Marker + new Handle { Anchor = Anchor.TopRight, Origin = Anchor.Centre }, - new Marker + new Handle { Anchor = Anchor.CentreLeft, Origin = Anchor.Centre }, - new Marker + new Handle { Anchor = Anchor.BottomLeft, Origin = Anchor.Centre }, - new Marker + new Handle { Anchor = Anchor.CentreRight, Origin = Anchor.Centre }, - new Marker + new Handle { Anchor = Anchor.BottomRight, Origin = Anchor.Centre }, - new Marker + new Handle { Anchor = Anchor.BottomCentre, Origin = Anchor.Centre }, - new CentreMarker + new OriginHandle { Anchor = Anchor.Centre, Origin = Anchor.Centre } }; - InternalChildren.OfType().ForEach(m => + InternalChildren.OfType().ForEach(m => { m.GetDragRectangle = () => GetDragRectangle(); m.UpdateDragRectangle = r => UpdateDragRectangle(r); diff --git a/osu.Game/Rulesets/Edit/Layers/Selection/HitObjectSelectionBox.cs b/osu.Game/Rulesets/Edit/Layers/Selection/HitObjectSelectionBox.cs index 6ea2778a9e..ce8f8b7ded 100644 --- a/osu.Game/Rulesets/Edit/Layers/Selection/HitObjectSelectionBox.cs +++ b/osu.Game/Rulesets/Edit/Layers/Selection/HitObjectSelectionBox.cs @@ -30,7 +30,7 @@ namespace osu.Game.Rulesets.Edit.Layers.Selection private readonly Container borderMask; private readonly Drawable background; - private readonly MarkerContainer markers; + private readonly HandleContainer handles; private Color4 captureFinishedColour; @@ -65,7 +65,7 @@ namespace osu.Game.Rulesets.Edit.Layers.Selection }, } }, - markers = new MarkerContainer + handles = new HandleContainer { RelativeSizeAxes = Axes.Both, Alpha = 0, @@ -159,7 +159,7 @@ namespace osu.Game.Rulesets.Edit.Layers.Selection // Transform into markers to let the user modify the drag selection further. background.Delay(50).FadeOut(200); - markers.FadeIn(200); + handles.FadeIn(200); Selection.Value = new SelectionInfo { diff --git a/osu.Game/Rulesets/Edit/Layers/Selection/CentreMarker.cs b/osu.Game/Rulesets/Edit/Layers/Selection/OriginHandle.cs similarity index 86% rename from osu.Game/Rulesets/Edit/Layers/Selection/CentreMarker.cs rename to osu.Game/Rulesets/Edit/Layers/Selection/OriginHandle.cs index 0ed7339134..8326ebeeac 100644 --- a/osu.Game/Rulesets/Edit/Layers/Selection/CentreMarker.cs +++ b/osu.Game/Rulesets/Edit/Layers/Selection/OriginHandle.cs @@ -11,14 +11,14 @@ using OpenTK; namespace osu.Game.Rulesets.Edit.Layers.Selection { /// - /// Represents the centre of a . + /// Represents the origin of a . /// - public class CentreMarker : CompositeDrawable + public class OriginHandle : CompositeDrawable { private const float marker_size = 10; private const float line_width = 2; - public CentreMarker() + public OriginHandle() { Size = new Vector2(marker_size); diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 514f91f80a..cf095b17a3 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -307,10 +307,10 @@ - + - - + +