From 1046028cffb66f2993ea0dfb72c15b24bccc8995 Mon Sep 17 00:00:00 2001 From: Juuxel <6596629+Juuxel@users.noreply.github.com> Date: Fri, 8 May 2020 21:07:03 +0300 Subject: Sliders now slide properly in inverse directions as well Scrolling scroll bars! --- .../java/io/github/cottonmc/cotton/gui/widget/WAbstractSlider.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/main') 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); -- cgit