Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions osu.Game.Tests/Visual/Editing/TestSceneEditorClipboard.cs
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,8 @@ public void TestCopyPaste(bool deselectAfterCopy)
{
AddStep("deselect", () => EditorBeatmap.SelectedHitObjects.Clear());

AddUntilStep("timeline selection box is not visible", () => Editor.ChildrenOfType<Timeline>().First().ChildrenOfType<EditorSelectionHandler>().First().Alpha == 0);
AddUntilStep("composer selection box is not visible", () => Editor.ChildrenOfType<HitObjectComposer>().First().ChildrenOfType<EditorSelectionHandler>().First().Alpha == 0);
AddUntilStep("timeline selection box is not visible", () => Editor.ChildrenOfType<Timeline>().First().ChildrenOfType<SelectionBox>().First().Alpha == 0);
AddUntilStep("composer selection box is not visible", () => Editor.ChildrenOfType<HitObjectComposer>().First().ChildrenOfType<SelectionBox>().First().Alpha == 0);
}

AddStep("paste hitobject", () => Editor.Paste());
Expand Down
48 changes: 41 additions & 7 deletions osu.Game/Screens/Edit/Compose/Components/SelectionBox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,16 @@
using osu.Framework.Graphics.Sprites;
using osu.Framework.Input.Events;
using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
using osuTK;
using osuTK.Input;

namespace osu.Game.Screens.Edit.Compose.Components
{
public class SelectionBox : CompositeDrawable
{
public const float BORDER_RADIUS = 3;

public Func<float, bool> OnRotation;
public Func<Vector2, Anchor, bool> OnScale;
public Func<Direction, bool> OnFlip;
Expand Down Expand Up @@ -92,21 +95,32 @@ public bool CanScaleY
}
}

private string text;

public string Text
{
get => text;
set
{
if (value == text)
return;

text = value;
if (selectionDetailsText != null)
selectionDetailsText.Text = value;
}
}

private Container dragHandles;
private FillFlowContainer buttons;

public const float BORDER_RADIUS = 3;
private OsuSpriteText selectionDetailsText;

[Resolved]
private OsuColour colours { get; set; }

[BackgroundDependencyLoader]
private void load()
{
RelativeSizeAxes = Axes.Both;

recreate();
}
private void load() => recreate();

protected override bool OnKeyDown(KeyDownEvent e)
{
Expand Down Expand Up @@ -144,6 +158,26 @@ private void recreate()

InternalChildren = new Drawable[]
{
new Container
{
Name = "info text",
AutoSizeAxes = Axes.Both,
Children = new Drawable[]
{
new Box
{
Colour = colours.YellowDark,
RelativeSizeAxes = Axes.Both,
},
selectionDetailsText = new OsuSpriteText
{
Padding = new MarginPadding(2),
Colour = colours.Gray0,
Font = OsuFont.Default.With(size: 11),
Text = text,
}
}
},
new Container
{
Masking = true,
Expand Down
43 changes: 5 additions & 38 deletions osu.Game/Screens/Edit/Compose/Components/SelectionHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,11 @@
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Cursor;
using osu.Framework.Graphics.Primitives;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.UserInterface;
using osu.Framework.Input;
using osu.Framework.Input.Bindings;
using osu.Framework.Input.Events;
using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
using osu.Game.Graphics.UserInterface;
using osu.Game.Rulesets.Edit;
using osuTK;
Expand All @@ -43,10 +41,6 @@ public abstract class SelectionHandler<T> : CompositeDrawable, IKeyBindingHandle

private readonly List<SelectionBlueprint<T>> selectedBlueprints;

private Drawable content;

private OsuSpriteText selectionDetailsText;

protected SelectionBox SelectionBox { get; private set; }

[Resolved(CanBeNull = true)]
Expand All @@ -58,39 +52,12 @@ protected SelectionHandler()

RelativeSizeAxes = Axes.Both;
AlwaysPresent = true;
Alpha = 0;
}

[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
InternalChild = content = new Container
{
Children = new Drawable[]
{
// todo: should maybe be inside the SelectionBox?
new Container
{
Name = "info text",
AutoSizeAxes = Axes.Both,
Children = new Drawable[]
{
new Box
{
Colour = colours.YellowDark,
RelativeSizeAxes = Axes.Both,
},
selectionDetailsText = new OsuSpriteText
{
Padding = new MarginPadding(2),
Colour = colours.Gray0,
Font = OsuFont.Default.With(size: 11)
}
}
},
SelectionBox = CreateSelectionBox(),
}
};
InternalChild = SelectionBox = CreateSelectionBox();

SelectedItems.CollectionChanged += (sender, args) =>
{
Expand Down Expand Up @@ -306,9 +273,9 @@ private void updateVisibility()
{
int count = SelectedItems.Count;

selectionDetailsText.Text = count > 0 ? count.ToString() : string.Empty;
SelectionBox.Text = count > 0 ? count.ToString() : string.Empty;

this.FadeTo(count > 0 ? 1 : 0);
SelectionBox.FadeTo(count > 0 ? 1 : 0);
OnSelectionChanged();
}

Expand All @@ -335,8 +302,8 @@ protected override void Update()

selectionRect = selectionRect.Inflate(5f);

content.Position = selectionRect.Location;
content.Size = selectionRect.Size;
SelectionBox.Position = selectionRect.Location;
SelectionBox.Size = selectionRect.Size;
}

#endregion
Expand Down