diff --git a/osu.Game.Rulesets.Osu/Edit/Layers/Selection/OsuHitObjectOverlayLayer.cs b/osu.Game.Rulesets.Osu/Edit/Layers/Selection/OsuHitObjectOverlayLayer.cs deleted file mode 100644 index e0d1b34ca5..0000000000 --- a/osu.Game.Rulesets.Osu/Edit/Layers/Selection/OsuHitObjectOverlayLayer.cs +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (c) 2007-2018 ppy Pty Ltd . -// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE - -using osu.Game.Rulesets.Edit.Layers.Selection; -using osu.Game.Rulesets.Objects.Drawables; -using osu.Game.Rulesets.Osu.Edit.Layers.Selection.Overlays; -using osu.Game.Rulesets.Osu.Objects.Drawables; - -namespace osu.Game.Rulesets.Osu.Edit.Layers.Selection -{ - public class OsuHitObjectOverlayLayer : HitObjectOverlayLayer - { - protected override HitObjectOverlay CreateOverlayFor(DrawableHitObject hitObject) - { - switch (hitObject) - { - case DrawableHitCircle circle: - return new HitCircleOverlay(circle); - case DrawableSlider slider: - return new SliderOverlay(slider); - } - - return base.CreateOverlayFor(hitObject); - } - } -} diff --git a/osu.Game.Rulesets.Osu/Edit/Layers/Selection/Overlays/HitCircleOverlay.cs b/osu.Game.Rulesets.Osu/Edit/Layers/Selection/Overlays/HitCircleMask.cs similarity index 82% rename from osu.Game.Rulesets.Osu/Edit/Layers/Selection/Overlays/HitCircleOverlay.cs rename to osu.Game.Rulesets.Osu/Edit/Layers/Selection/Overlays/HitCircleMask.cs index ea5104af18..b48dd73bb5 100644 --- a/osu.Game.Rulesets.Osu/Edit/Layers/Selection/Overlays/HitCircleOverlay.cs +++ b/osu.Game.Rulesets.Osu/Edit/Layers/Selection/Overlays/HitCircleMask.cs @@ -4,15 +4,15 @@ using osu.Framework.Graphics; using osu.Framework.Allocation; using osu.Game.Graphics; -using osu.Game.Rulesets.Edit.Layers.Selection; +using osu.Game.Rulesets.Edit; using osu.Game.Rulesets.Osu.Objects.Drawables; using osu.Game.Rulesets.Osu.Objects.Drawables.Pieces; namespace osu.Game.Rulesets.Osu.Edit.Layers.Selection.Overlays { - public class HitCircleOverlay : HitObjectOverlay + public class HitCircleMask : HitObjectMask { - public HitCircleOverlay(DrawableHitCircle hitCircle) + public HitCircleMask(DrawableHitCircle hitCircle) : base(hitCircle) { Origin = Anchor.Centre; diff --git a/osu.Game.Rulesets.Osu/Edit/Layers/Selection/Overlays/SliderCircleOverlay.cs b/osu.Game.Rulesets.Osu/Edit/Layers/Selection/Overlays/SliderCircleMask.cs similarity index 73% rename from osu.Game.Rulesets.Osu/Edit/Layers/Selection/Overlays/SliderCircleOverlay.cs rename to osu.Game.Rulesets.Osu/Edit/Layers/Selection/Overlays/SliderCircleMask.cs index 3c7f8a067b..2de8c2f64e 100644 --- a/osu.Game.Rulesets.Osu/Edit/Layers/Selection/Overlays/SliderCircleOverlay.cs +++ b/osu.Game.Rulesets.Osu/Edit/Layers/Selection/Overlays/SliderCircleMask.cs @@ -4,28 +4,28 @@ using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Game.Graphics; -using osu.Game.Rulesets.Edit.Layers.Selection; +using osu.Game.Rulesets.Edit; using osu.Game.Rulesets.Osu.Objects.Drawables; using osu.Game.Rulesets.Osu.Objects.Drawables.Pieces; using OpenTK; namespace osu.Game.Rulesets.Osu.Edit.Layers.Selection.Overlays { - public class SliderCircleOverlay : HitObjectOverlay + public class SliderCircleMask : HitObjectMask { - public SliderCircleOverlay(DrawableHitCircle sliderHead, DrawableSlider slider) + public SliderCircleMask(DrawableHitCircle sliderHead, DrawableSlider slider) : this(sliderHead, sliderHead.Position, slider) { } - public SliderCircleOverlay(DrawableSliderTail sliderTail, DrawableSlider slider) + public SliderCircleMask(DrawableSliderTail sliderTail, DrawableSlider slider) : this(sliderTail, sliderTail.Position, slider) { } private readonly DrawableOsuHitObject hitObject; - private SliderCircleOverlay(DrawableOsuHitObject hitObject, Vector2 position, DrawableSlider slider) + private SliderCircleMask(DrawableOsuHitObject hitObject, Vector2 position, DrawableSlider slider) : base(hitObject) { this.hitObject = hitObject; diff --git a/osu.Game.Rulesets.Osu/Edit/Layers/Selection/Overlays/SliderOverlay.cs b/osu.Game.Rulesets.Osu/Edit/Layers/Selection/Overlays/SliderMask.cs similarity index 82% rename from osu.Game.Rulesets.Osu/Edit/Layers/Selection/Overlays/SliderOverlay.cs rename to osu.Game.Rulesets.Osu/Edit/Layers/Selection/Overlays/SliderMask.cs index d478130868..53f02617cd 100644 --- a/osu.Game.Rulesets.Osu/Edit/Layers/Selection/Overlays/SliderOverlay.cs +++ b/osu.Game.Rulesets.Osu/Edit/Layers/Selection/Overlays/SliderMask.cs @@ -4,7 +4,7 @@ using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Game.Graphics; -using osu.Game.Rulesets.Edit.Layers.Selection; +using osu.Game.Rulesets.Edit; using osu.Game.Rulesets.Osu.Objects; using osu.Game.Rulesets.Osu.Objects.Drawables; using osu.Game.Rulesets.Osu.Objects.Drawables.Pieces; @@ -13,12 +13,12 @@ using OpenTK.Graphics; namespace osu.Game.Rulesets.Osu.Edit.Layers.Selection.Overlays { - public class SliderOverlay : HitObjectOverlay + public class SliderMask : HitObjectMask { private readonly SliderBody body; private readonly DrawableSlider slider; - public SliderOverlay(DrawableSlider slider) + public SliderMask(DrawableSlider slider) : base(slider) { this.slider = slider; @@ -34,8 +34,8 @@ namespace osu.Game.Rulesets.Osu.Edit.Layers.Selection.Overlays AccentColour = Color4.Transparent, PathWidth = sliderObject.Scale * 64 }, - new SliderCircleOverlay(slider.HeadCircle, slider), - new SliderCircleOverlay(slider.TailCircle, slider), + new SliderCircleMask(slider.HeadCircle, slider), + new SliderCircleMask(slider.TailCircle, slider), }; sliderObject.PositionChanged += _ => Position = slider.Position; diff --git a/osu.Game.Rulesets.Osu/Edit/OsuHitObjectComposer.cs b/osu.Game.Rulesets.Osu/Edit/OsuHitObjectComposer.cs index 70d49a6b4f..026c85d909 100644 --- a/osu.Game.Rulesets.Osu/Edit/OsuHitObjectComposer.cs +++ b/osu.Game.Rulesets.Osu/Edit/OsuHitObjectComposer.cs @@ -5,10 +5,11 @@ using System.Collections.Generic; using osu.Framework.Graphics; using osu.Game.Beatmaps; using osu.Game.Rulesets.Edit; -using osu.Game.Rulesets.Edit.Layers.Selection; using osu.Game.Rulesets.Edit.Tools; -using osu.Game.Rulesets.Osu.Edit.Layers.Selection; +using osu.Game.Rulesets.Objects.Drawables; +using osu.Game.Rulesets.Osu.Edit.Layers.Selection.Overlays; using osu.Game.Rulesets.Osu.Objects; +using osu.Game.Rulesets.Osu.Objects.Drawables; using osu.Game.Rulesets.Osu.UI; using osu.Game.Rulesets.UI; @@ -32,6 +33,17 @@ namespace osu.Game.Rulesets.Osu.Edit protected override ScalableContainer CreateLayerContainer() => new ScalableContainer(OsuPlayfield.BASE_SIZE.X) { RelativeSizeAxes = Axes.Both }; - protected override HitObjectOverlayLayer CreateHitObjectOverlayLayer() => new OsuHitObjectOverlayLayer(); + public override HitObjectMask CreateMaskFor(DrawableHitObject hitObject) + { + switch (hitObject) + { + case DrawableHitCircle circle: + return new HitCircleMask(circle); + case DrawableSlider slider: + return new SliderMask(slider); + } + + return base.CreateMaskFor(hitObject); + } } } diff --git a/osu.Game.Rulesets.Osu/osu.Game.Rulesets.Osu.csproj b/osu.Game.Rulesets.Osu/osu.Game.Rulesets.Osu.csproj index d6fe87660f..b8f56c1f5d 100644 --- a/osu.Game.Rulesets.Osu/osu.Game.Rulesets.Osu.csproj +++ b/osu.Game.Rulesets.Osu/osu.Game.Rulesets.Osu.csproj @@ -64,10 +64,9 @@ - - - - + + + diff --git a/osu.Game.Tests/Visual/TestCaseEditorSelectionLayer.cs b/osu.Game.Tests/Visual/TestCaseEditorSelectionLayer.cs index dc8a13d044..a7e104dd81 100644 --- a/osu.Game.Tests/Visual/TestCaseEditorSelectionLayer.cs +++ b/osu.Game.Tests/Visual/TestCaseEditorSelectionLayer.cs @@ -8,13 +8,12 @@ using osu.Framework.Allocation; using OpenTK; using osu.Game.Beatmaps; using osu.Game.Rulesets.Edit; -using osu.Game.Rulesets.Edit.Layers.Selection; using osu.Game.Rulesets.Objects; using osu.Game.Rulesets.Osu; using osu.Game.Rulesets.Osu.Edit; -using osu.Game.Rulesets.Osu.Edit.Layers.Selection; using osu.Game.Rulesets.Osu.Edit.Layers.Selection.Overlays; using osu.Game.Rulesets.Osu.Objects; +using osu.Game.Screens.Edit.Screens.Compose.Layers; using osu.Game.Tests.Beatmaps; namespace osu.Game.Tests.Visual @@ -24,17 +23,15 @@ namespace osu.Game.Tests.Visual { public override IReadOnlyList RequiredTypes => new[] { - typeof(SelectionBox), typeof(SelectionLayer), - typeof(SelectionOverlay), + typeof(SelectionBox), typeof(HitObjectComposer), typeof(OsuHitObjectComposer), - typeof(HitObjectOverlayLayer), - typeof(OsuHitObjectOverlayLayer), - typeof(HitObjectOverlay), - typeof(HitCircleOverlay), - typeof(SliderOverlay), - typeof(SliderCircleOverlay) + typeof(HitObjectMaskLayer), + typeof(HitObjectMask), + typeof(HitCircleMask), + typeof(SliderMask), + typeof(SliderCircleMask) }; [BackgroundDependencyLoader] diff --git a/osu.Game/Rulesets/Edit/HitObjectComposer.cs b/osu.Game/Rulesets/Edit/HitObjectComposer.cs index 914640622b..3dd8d503ed 100644 --- a/osu.Game/Rulesets/Edit/HitObjectComposer.cs +++ b/osu.Game/Rulesets/Edit/HitObjectComposer.cs @@ -10,10 +10,10 @@ using osu.Framework.Graphics.Containers; using osu.Framework.Logging; using osu.Framework.Timing; using osu.Game.Beatmaps; -using osu.Game.Rulesets.Edit.Layers; -using osu.Game.Rulesets.Edit.Layers.Selection; using osu.Game.Rulesets.Edit.Tools; +using osu.Game.Rulesets.Objects.Drawables; using osu.Game.Rulesets.UI; +using osu.Game.Screens.Edit.Screens.Compose.Layers; using osu.Game.Screens.Edit.Screens.Compose.RadioButtons; namespace osu.Game.Rulesets.Edit @@ -49,7 +49,7 @@ namespace osu.Game.Rulesets.Edit return; } - HitObjectOverlayLayer hitObjectOverlayLayer = CreateHitObjectOverlayLayer(); + HitObjectMaskLayer hitObjectMaskLayer = new HitObjectMaskLayer(this); SelectionLayer selectionLayer = new SelectionLayer(rulesetContainer.Playfield); var layerBelowRuleset = new BorderLayer @@ -62,7 +62,7 @@ namespace osu.Game.Rulesets.Edit layerAboveRuleset.Children = new Drawable[] { selectionLayer, // Below object overlays for input - hitObjectOverlayLayer, + hitObjectMaskLayer, selectionLayer.CreateProxy() // Proxy above object overlays for selections }; @@ -106,10 +106,10 @@ namespace osu.Game.Rulesets.Edit } }; - selectionLayer.ObjectSelected += hitObjectOverlayLayer.AddOverlay; - selectionLayer.ObjectDeselected += hitObjectOverlayLayer.RemoveOverlay; - selectionLayer.SelectionCleared += hitObjectOverlayLayer.RemoveSelectionOverlay; - selectionLayer.SelectionFinished += hitObjectOverlayLayer.AddSelectionOverlay; + selectionLayer.ObjectSelected += hitObjectMaskLayer.AddOverlay; + selectionLayer.ObjectDeselected += hitObjectMaskLayer.RemoveOverlay; + selectionLayer.SelectionCleared += hitObjectMaskLayer.RemoveSelectionOverlay; + selectionLayer.SelectionFinished += hitObjectMaskLayer.AddSelectionOverlay; toolboxCollection.Items = new[] { new RadioButton("Select", () => setCompositionTool(null)) } @@ -140,14 +140,22 @@ namespace osu.Game.Rulesets.Edit protected abstract IReadOnlyList CompositionTools { get; } + /// + /// Creates a for a specific . + /// + /// The to create the overlay for. + public virtual HitObjectMask CreateMaskFor(DrawableHitObject hitObject) => null; + + /// + /// Creates a which outlines s + /// and handles all hitobject movement/pattern adjustments. + /// + /// The overlays. + public virtual SelectionBox CreateSelectionOverlay(IReadOnlyList overlays) => new SelectionBox(overlays); + /// /// Creates a which provides a layer above or below the . /// protected virtual ScalableContainer CreateLayerContainer() => new ScalableContainer { RelativeSizeAxes = Axes.Both }; - - /// - /// Creates the which overlays selected s. - /// - protected virtual HitObjectOverlayLayer CreateHitObjectOverlayLayer() => new HitObjectOverlayLayer(); } } diff --git a/osu.Game/Rulesets/Edit/Layers/Selection/HitObjectOverlay.cs b/osu.Game/Rulesets/Edit/HitObjectMask.cs similarity index 56% rename from osu.Game/Rulesets/Edit/Layers/Selection/HitObjectOverlay.cs rename to osu.Game/Rulesets/Edit/HitObjectMask.cs index 8c58275943..051b42fec6 100644 --- a/osu.Game/Rulesets/Edit/Layers/Selection/HitObjectOverlay.cs +++ b/osu.Game/Rulesets/Edit/HitObjectMask.cs @@ -4,13 +4,16 @@ using osu.Framework.Graphics.Containers; using osu.Game.Rulesets.Objects.Drawables; -namespace osu.Game.Rulesets.Edit.Layers.Selection +namespace osu.Game.Rulesets.Edit { - public class HitObjectOverlay : Container + /// + /// A mask placed above a adding editing functionality. + /// + public class HitObjectMask : Container { public readonly DrawableHitObject HitObject; - public HitObjectOverlay(DrawableHitObject hitObject) + public HitObjectMask(DrawableHitObject hitObject) { HitObject = hitObject; } diff --git a/osu.Game/Rulesets/Edit/Layers/Selection/SelectionBox.cs b/osu.Game/Rulesets/Edit/Layers/Selection/SelectionBox.cs deleted file mode 100644 index 1c25846ee3..0000000000 --- a/osu.Game/Rulesets/Edit/Layers/Selection/SelectionBox.cs +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright (c) 2007-2018 ppy Pty Ltd . -// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE - -using osu.Framework.Graphics; -using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Primitives; -using osu.Framework.Graphics.Shapes; -using OpenTK.Graphics; - -namespace osu.Game.Rulesets.Edit.Layers.Selection -{ - /// - /// A box that represents a drag selection. - /// - public class SelectionBox : VisibilityContainer - { - public const float BORDER_RADIUS = 2; - - /// - /// Creates a new . - /// - public SelectionBox() - { - Masking = true; - BorderColour = Color4.White; - BorderThickness = BORDER_RADIUS; - - Child = new Box - { - RelativeSizeAxes = Axes.Both, - Alpha = 0.1f - }; - } - - public void SetDragRectangle(RectangleF rectangle) - { - var topLeft = Parent.ToLocalSpace(rectangle.TopLeft); - var bottomRight = Parent.ToLocalSpace(rectangle.BottomRight); - - Position = topLeft; - Size = bottomRight - topLeft; - } - - public override bool DisposeOnDeathRemoval => true; - - protected override void PopIn() => this.FadeIn(250, Easing.OutQuint); - protected override void PopOut() => this.FadeOut(250, Easing.OutQuint); - } -} diff --git a/osu.Game/Rulesets/Edit/Layers/BorderLayer.cs b/osu.Game/Screens/Edit/Screens/Compose/Layers/BorderLayer.cs similarity index 92% rename from osu.Game/Rulesets/Edit/Layers/BorderLayer.cs rename to osu.Game/Screens/Edit/Screens/Compose/Layers/BorderLayer.cs index 54c30b8d89..49cf078d36 100644 --- a/osu.Game/Rulesets/Edit/Layers/BorderLayer.cs +++ b/osu.Game/Screens/Edit/Screens/Compose/Layers/BorderLayer.cs @@ -6,7 +6,7 @@ using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; using OpenTK.Graphics; -namespace osu.Game.Rulesets.Edit.Layers +namespace osu.Game.Screens.Edit.Screens.Compose.Layers { public class BorderLayer : Container { diff --git a/osu.Game/Rulesets/Edit/Layers/Selection/HitObjectOverlayLayer.cs b/osu.Game/Screens/Edit/Screens/Compose/Layers/HitObjectMaskLayer.cs similarity index 51% rename from osu.Game/Rulesets/Edit/Layers/Selection/HitObjectOverlayLayer.cs rename to osu.Game/Screens/Edit/Screens/Compose/Layers/HitObjectMaskLayer.cs index 24d594f59a..63b5538ad7 100644 --- a/osu.Game/Rulesets/Edit/Layers/Selection/HitObjectOverlayLayer.cs +++ b/osu.Game/Screens/Edit/Screens/Compose/Layers/HitObjectMaskLayer.cs @@ -1,23 +1,25 @@ // Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using System.Collections.Generic; using System.Linq; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; +using osu.Game.Rulesets.Edit; using osu.Game.Rulesets.Objects.Drawables; -namespace osu.Game.Rulesets.Edit.Layers.Selection +namespace osu.Game.Screens.Edit.Screens.Compose.Layers { - public class HitObjectOverlayLayer : CompositeDrawable + public class HitObjectMaskLayer : CompositeDrawable { - private readonly Container overlayContainer; + private readonly HitObjectComposer composer; + private readonly Container overlayContainer; - public HitObjectOverlayLayer() + public HitObjectMaskLayer(HitObjectComposer composer) { + this.composer = composer; RelativeSizeAxes = Axes.Both; - InternalChild = overlayContainer = new Container { RelativeSizeAxes = Axes.Both }; + InternalChild = overlayContainer = new Container { RelativeSizeAxes = Axes.Both }; } /// @@ -26,7 +28,7 @@ namespace osu.Game.Rulesets.Edit.Layers.Selection /// The to create an overlay for. public void AddOverlay(DrawableHitObject hitObject) { - var overlay = CreateOverlayFor(hitObject); + var overlay = composer.CreateMaskFor(hitObject); if (overlay == null) return; @@ -47,27 +49,14 @@ namespace osu.Game.Rulesets.Edit.Layers.Selection existing.Expire(); } - private SelectionOverlay currentSelectionOverlay; + private SelectionBox currentSelectionBox; - public void AddSelectionOverlay() => AddInternal(currentSelectionOverlay = CreateSelectionOverlay(overlayContainer)); + public void AddSelectionOverlay() => AddInternal(currentSelectionBox = composer.CreateSelectionOverlay(overlayContainer)); public void RemoveSelectionOverlay() { - currentSelectionOverlay?.Hide(); - currentSelectionOverlay?.Expire(); + currentSelectionBox?.Hide(); + currentSelectionBox?.Expire(); } - - /// - /// Creates a for a specific . - /// - /// The to create the overlay for. - protected virtual HitObjectOverlay CreateOverlayFor(DrawableHitObject hitObject) => null; - - /// - /// Creates a which outlines s - /// and handles all hitobject movement/pattern adjustments. - /// - /// The overlays. - protected virtual SelectionOverlay CreateSelectionOverlay(IReadOnlyList overlays) => new SelectionOverlay(overlays); } } diff --git a/osu.Game/Rulesets/Edit/Layers/Selection/SelectionOverlay.cs b/osu.Game/Screens/Edit/Screens/Compose/Layers/SelectionBox.cs similarity index 83% rename from osu.Game/Rulesets/Edit/Layers/Selection/SelectionOverlay.cs rename to osu.Game/Screens/Edit/Screens/Compose/Layers/SelectionBox.cs index c3bb5911f8..0e5d824559 100644 --- a/osu.Game/Rulesets/Edit/Layers/Selection/SelectionOverlay.cs +++ b/osu.Game/Screens/Edit/Screens/Compose/Layers/SelectionBox.cs @@ -9,25 +9,28 @@ using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; using osu.Framework.Input; using osu.Game.Graphics; +using osu.Game.Rulesets.Edit; using osu.Game.Rulesets.Edit.Types; using osu.Game.Rulesets.Objects.Drawables; using OpenTK; -namespace osu.Game.Rulesets.Edit.Layers.Selection +namespace osu.Game.Screens.Edit.Screens.Compose.Layers { /// - /// A box which encloses s. + /// A box which surrounds s and provides interactive handles, context menus etc. /// - public class SelectionOverlay : VisibilityContainer + public class SelectionBox : VisibilityContainer { - private readonly IReadOnlyList overlays; + private readonly IReadOnlyList overlays; - public SelectionOverlay(IReadOnlyList overlays) + public const float BORDER_RADIUS = 2; + + public SelectionBox(IReadOnlyList overlays) { this.overlays = overlays; Masking = true; - BorderThickness = SelectionBox.BORDER_RADIUS; + BorderThickness = BORDER_RADIUS; InternalChild = new Box { diff --git a/osu.Game/Rulesets/Edit/Layers/Selection/SelectionLayer.cs b/osu.Game/Screens/Edit/Screens/Compose/Layers/SelectionLayer.cs similarity index 78% rename from osu.Game/Rulesets/Edit/Layers/Selection/SelectionLayer.cs rename to osu.Game/Screens/Edit/Screens/Compose/Layers/SelectionLayer.cs index 2f8b9165c4..8c66007bb7 100644 --- a/osu.Game/Rulesets/Edit/Layers/Selection/SelectionLayer.cs +++ b/osu.Game/Screens/Edit/Screens/Compose/Layers/SelectionLayer.cs @@ -8,12 +8,14 @@ using osu.Framework.Extensions.IEnumerableExtensions; 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.Rulesets.Objects.Drawables; using osu.Game.Rulesets.UI; using OpenTK; +using OpenTK.Graphics; -namespace osu.Game.Rulesets.Edit.Layers.Selection +namespace osu.Game.Screens.Edit.Screens.Compose.Layers { public class SelectionLayer : CompositeDrawable { @@ -46,7 +48,7 @@ namespace osu.Game.Rulesets.Edit.Layers.Selection RelativeSizeAxes = Axes.Both; } - private SelectionBox selectionBox; + private DragBox dragBox; private readonly HashSet selectedHitObjects = new HashSet(); @@ -58,20 +60,20 @@ namespace osu.Game.Rulesets.Edit.Layers.Selection protected override bool OnDragStart(InputState state) { - AddInternal(selectionBox = new SelectionBox()); + AddInternal(dragBox = new DragBox()); return true; } protected override bool OnDrag(InputState state) { - selectionBox.Show(); + dragBox.Show(); var dragPosition = state.Mouse.NativeState.Position; var dragStartPosition = state.Mouse.NativeState.PositionMouseDown ?? dragPosition; var screenSpaceDragQuad = new Quad(dragStartPosition.X, dragStartPosition.Y, dragPosition.X - dragStartPosition.X, dragPosition.Y - dragStartPosition.Y); - selectionBox.SetDragRectangle(screenSpaceDragQuad.AABBFloat); + dragBox.SetDragRectangle(screenSpaceDragQuad.AABBFloat); selectQuad(screenSpaceDragQuad); return true; @@ -79,8 +81,8 @@ namespace osu.Game.Rulesets.Edit.Layers.Selection protected override bool OnDragEnd(InputState state) { - selectionBox.Hide(); - selectionBox.Expire(); + dragBox.Hide(); + dragBox.Expire(); finishSelection(); @@ -197,5 +199,41 @@ namespace osu.Game.Rulesets.Edit.Layers.Selection return; SelectionFinished?.Invoke(); } + + /// + /// A box that represents a drag selection. + /// + private class DragBox : VisibilityContainer + { + /// + /// Creates a new . + /// + public DragBox() + { + Masking = true; + BorderColour = Color4.White; + BorderThickness = SelectionBox.BORDER_RADIUS; + + Child = new Box + { + RelativeSizeAxes = Axes.Both, + Alpha = 0.1f + }; + } + + public void SetDragRectangle(RectangleF rectangle) + { + var topLeft = Parent.ToLocalSpace(rectangle.TopLeft); + var bottomRight = Parent.ToLocalSpace(rectangle.BottomRight); + + Position = topLeft; + Size = bottomRight - topLeft; + } + + public override bool DisposeOnDeathRemoval => true; + + protected override void PopIn() => this.FadeIn(250, Easing.OutQuint); + protected override void PopOut() => this.FadeOut(250, Easing.OutQuint); + } } } diff --git a/osu.Game/Screens/Edit/Screens/EditorScreen.cs b/osu.Game/Screens/Edit/Screens/EditorScreen.cs index 2e654b4373..009830502e 100644 --- a/osu.Game/Screens/Edit/Screens/EditorScreen.cs +++ b/osu.Game/Screens/Edit/Screens/EditorScreen.cs @@ -8,6 +8,9 @@ using osu.Game.Beatmaps; namespace osu.Game.Screens.Edit.Screens { + /// + /// TODO: eventually make this inherit Screen and add a local scren stack inside the Editor. + /// public class EditorScreen : Container { public readonly Bindable Beatmap = new Bindable(); diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index fa99ae616a..14d2381640 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -361,10 +361,7 @@ - - - - + @@ -379,6 +376,10 @@ + + + + @@ -393,8 +394,6 @@ - -