diff options
author | Juuxel <6596629+Juuxel@users.noreply.github.com> | 2020-05-08 21:07:03 +0300 |
---|---|---|
committer | Juuxel <6596629+Juuxel@users.noreply.github.com> | 2020-05-08 21:07:03 +0300 |
commit | 1046028cffb66f2993ea0dfb72c15b24bccc8995 (patch) | |
tree | 5c6c69a4be93312abad6651e2716aaa8dfdfc6ea /src/main/java | |
parent | cca884e8beb6e0f92c09b2d238b65d26a4b1887f (diff) | |
download | LibGui-1046028cffb66f2993ea0dfb72c15b24bccc8995.tar.gz LibGui-1046028cffb66f2993ea0dfb72c15b24bccc8995.tar.bz2 LibGui-1046028cffb66f2993ea0dfb72c15b24bccc8995.zip |
Sliders now slide properly in inverse directions as well
Scrolling scroll bars!
Diffstat (limited to 'src/main/java')
-rw-r--r-- | src/main/java/io/github/cottonmc/cotton/gui/widget/WAbstractSlider.java | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/main/java/io/github/cottonmc/cotton/gui/widget/WAbstractSlider.java b/src/main/java/io/github/cottonmc/cotton/gui/widget/WAbstractSlider.java index d864b3b..c8570fd 100644 --- a/src/main/java/io/github/cottonmc/cotton/gui/widget/WAbstractSlider.java +++ b/src/main/java/io/github/cottonmc/cotton/gui/widget/WAbstractSlider.java @@ -170,8 +170,12 @@ public abstract class WAbstractSlider extends WWidget { @Environment(EnvType.CLIENT) @Override public void onMouseScroll(int x, int y, double amount) { + if (direction == Direction.LEFT || direction == Direction.DOWN) { + amount = -amount; + } + int previous = value; - value = MathHelper.clamp(value + (int) (valueToCoordRatio * amount * 2), min, max); + value = MathHelper.clamp(value + (int) Math.signum(amount) * MathHelper.ceil(valueToCoordRatio * Math.abs(amount) * 2), min, max); if (previous != value) { onValueChanged(value); |