From 079affc72f727aec82e57fa65d0fddc2aa43b15d Mon Sep 17 00:00:00 2001 From: Sturmlilie Date: Sat, 7 Nov 2020 19:56:17 +0100 Subject: WScrollBar: More intuitive drag scroll threshold (#91) Use the movable area (ie. scroll bar length minus handle length) instead of just the scroll bar length. This makes it so the handle actually feels like it's sticking to the cursor while scrolling. --- src/main/java/io/github/cottonmc/cotton/gui/widget/WScrollBar.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/main/java') diff --git a/src/main/java/io/github/cottonmc/cotton/gui/widget/WScrollBar.java b/src/main/java/io/github/cottonmc/cotton/gui/widget/WScrollBar.java index 8687c52..cfcdfc1 100644 --- a/src/main/java/io/github/cottonmc/cotton/gui/widget/WScrollBar.java +++ b/src/main/java/io/github/cottonmc/cotton/gui/widget/WScrollBar.java @@ -130,8 +130,7 @@ public class WScrollBar extends WWidget { } public int pixelsToValues(int pixels) { - int bar = (axis==Axis.HORIZONTAL) ? width-2 : height-2; - //int bar = getMovableDistance(); + int bar = getMovableDistance(); float percent = pixels / (float)bar; return (int)(percent*(maxValue-window)); } -- cgit