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