mirror of
https://github.com/ppy/osu
synced 2025-01-10 08:09:40 +00:00
allow tablet area to be dragged
This commit is contained in:
parent
b5dda407a8
commit
c86c1a9029
@ -11,6 +11,7 @@ using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Primitives;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Input.Events;
|
||||
using osu.Framework.Input.Handlers.Tablet;
|
||||
using osu.Framework.Utils;
|
||||
using osu.Game.Graphics;
|
||||
@ -66,7 +67,7 @@ namespace osu.Game.Overlays.Settings.Sections.Input
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = colour.Gray1,
|
||||
},
|
||||
usableAreaContainer = new Container
|
||||
usableAreaContainer = new UsableAreaContainer(handler)
|
||||
{
|
||||
Origin = Anchor.Centre,
|
||||
Children = new Drawable[]
|
||||
@ -225,4 +226,28 @@ namespace osu.Game.Overlays.Settings.Sections.Input
|
||||
tabletContainer.Scale = new Vector2(1 / adjust);
|
||||
}
|
||||
}
|
||||
|
||||
public partial class UsableAreaContainer : Container
|
||||
{
|
||||
private readonly Bindable<Vector2> areaOffset;
|
||||
|
||||
public UsableAreaContainer(ITabletHandler tabletHandler)
|
||||
{
|
||||
areaOffset = tabletHandler.AreaOffset.GetBoundCopy();
|
||||
}
|
||||
|
||||
protected override bool OnDragStart(DragStartEvent e) => true;
|
||||
|
||||
protected override void OnDrag(DragEvent e)
|
||||
{
|
||||
var newPos = Position + e.Delta;
|
||||
this.MoveTo(Vector2.Clamp(newPos, Vector2.Zero, Parent.Size));
|
||||
}
|
||||
|
||||
protected override void OnDragEnd(DragEndEvent e)
|
||||
{
|
||||
areaOffset.Value = Position;
|
||||
base.OnDragEnd(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user