diff options
author | Sturmlilie <jonas.kulla@alumni.fh-aachen.de> | 2020-11-07 19:56:17 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-07 20:56:17 +0200 |
commit | 079affc72f727aec82e57fa65d0fddc2aa43b15d (patch) | |
tree | a29573127614c43795a6c699402af0232a594e54 | |
parent | 08b2cdc14dda1f2640f9f42443748a818480d855 (diff) | |
download | LibGui-079affc72f727aec82e57fa65d0fddc2aa43b15d.tar.gz LibGui-079affc72f727aec82e57fa65d0fddc2aa43b15d.tar.bz2 LibGui-079affc72f727aec82e57fa65d0fddc2aa43b15d.zip |
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.
-rw-r--r-- | src/main/java/io/github/cottonmc/cotton/gui/widget/WScrollBar.java | 3 |
1 files changed, 1 insertions, 2 deletions
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)); } |