Limit zoom range of bracket display

This commit is contained in:
Dean Herbert 2019-06-13 16:11:15 +09:00
parent a0503fcbe3
commit 4af16262e3
2 changed files with 9 additions and 9 deletions

View File

@ -8,7 +8,7 @@ using osuTK;
namespace osu.Game.Tournament.Screens.Ladder namespace osu.Game.Tournament.Screens.Ladder
{ {
public class ScrollableContainer : Container public class LadderDragContainer : Container
{ {
protected override bool OnDragStart(DragStartEvent e) => true; protected override bool OnDragStart(DragStartEvent e) => true;
@ -24,12 +24,15 @@ namespace osu.Game.Tournament.Screens.Ladder
return true; return true;
} }
private const float min_scale = 0.6f;
private const float max_scale = 1.4f;
protected override bool OnScroll(ScrollEvent e) protected override bool OnScroll(ScrollEvent e)
{ {
var newScale = scale + e.ScrollDelta.Y / 15 * scale; var newScale = MathHelper.Clamp(scale + e.ScrollDelta.Y / 15 * scale, min_scale, max_scale);
this.MoveTo(target = target - e.MousePosition * (newScale - scale), 1000, Easing.OutQuint);
this.ScaleTo(scale = newScale, 1000, Easing.OutQuint); this.MoveTo(target = target - e.MousePosition * (newScale - scale), 2000, Easing.OutQuint);
this.ScaleTo(scale = newScale, 2000, Easing.OutQuint);
return true; return true;
} }

View File

@ -22,7 +22,7 @@ namespace osu.Game.Tournament.Screens.Ladder
private Container<Path> paths; private Container<Path> paths;
private Container headings; private Container headings;
protected ScrollableContainer ScrollContent; protected LadderDragContainer ScrollContent;
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(OsuColour colours, Storage storage) private void load(OsuColour colours, Storage storage)
@ -42,7 +42,7 @@ namespace osu.Game.Tournament.Screens.Ladder
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Loop = true, Loop = true,
}, },
ScrollContent = new ScrollableContainer ScrollContent = new LadderDragContainer
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Children = new Drawable[] Children = new Drawable[]
@ -133,8 +133,5 @@ namespace osu.Game.Tournament.Screens.Ladder
layout.Validate(); layout.Validate();
} }
// todo: remove after ppy/osu-framework#1980 is merged.
public override bool HandlePositionalInput => true;
} }
} }