2019-03-04 04:24:19 +00:00
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
2018-09-24 15:57:44 +00:00
|
|
|
|
2018-09-24 19:51:40 +00:00
|
|
|
using osu.Framework.Graphics;
|
2018-09-24 15:57:44 +00:00
|
|
|
using osu.Framework.Graphics.Containers;
|
2019-06-21 06:47:41 +00:00
|
|
|
using osu.Framework.Graphics.Primitives;
|
2018-10-12 09:49:47 +00:00
|
|
|
using osu.Framework.Input.Events;
|
2018-11-22 01:25:30 +00:00
|
|
|
using osuTK;
|
2018-09-24 15:57:44 +00:00
|
|
|
|
|
|
|
namespace osu.Game.Tournament.Screens.Ladder
|
|
|
|
{
|
2019-06-13 07:11:15 +00:00
|
|
|
public class LadderDragContainer : Container
|
2018-09-24 15:57:44 +00:00
|
|
|
{
|
2018-10-12 09:49:47 +00:00
|
|
|
protected override bool OnDragStart(DragStartEvent e) => true;
|
2018-09-24 15:57:44 +00:00
|
|
|
|
2018-10-12 09:49:47 +00:00
|
|
|
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => true;
|
2018-09-24 15:57:44 +00:00
|
|
|
|
2018-09-24 19:51:40 +00:00
|
|
|
private Vector2 target;
|
|
|
|
|
|
|
|
private float scale = 1;
|
|
|
|
|
2019-06-21 06:47:41 +00:00
|
|
|
protected override bool ComputeIsMaskedAway(RectangleF maskingBounds) => false;
|
|
|
|
|
2018-10-12 09:49:47 +00:00
|
|
|
protected override bool OnDrag(DragEvent e)
|
2018-09-24 15:57:44 +00:00
|
|
|
{
|
2018-10-12 09:49:47 +00:00
|
|
|
this.MoveTo(target += e.Delta, 1000, Easing.OutQuint);
|
2018-09-25 01:46:09 +00:00
|
|
|
return true;
|
2018-09-24 15:57:44 +00:00
|
|
|
}
|
2018-09-24 19:51:40 +00:00
|
|
|
|
2019-06-13 07:11:15 +00:00
|
|
|
private const float min_scale = 0.6f;
|
|
|
|
private const float max_scale = 1.4f;
|
|
|
|
|
2018-10-12 09:49:47 +00:00
|
|
|
protected override bool OnScroll(ScrollEvent e)
|
2018-09-24 19:51:40 +00:00
|
|
|
{
|
2019-06-13 07:11:15 +00:00
|
|
|
var newScale = MathHelper.Clamp(scale + e.ScrollDelta.Y / 15 * scale, min_scale, max_scale);
|
2018-09-25 01:46:09 +00:00
|
|
|
|
2019-06-13 07:11:15 +00:00
|
|
|
this.MoveTo(target = target - e.MousePosition * (newScale - scale), 2000, Easing.OutQuint);
|
|
|
|
this.ScaleTo(scale = newScale, 2000, Easing.OutQuint);
|
2018-09-24 19:51:40 +00:00
|
|
|
|
2018-09-25 01:46:09 +00:00
|
|
|
return true;
|
2018-09-24 19:51:40 +00:00
|
|
|
}
|
2018-09-24 15:57:44 +00:00
|
|
|
}
|
|
|
|
}
|