diff options
author | Juuxel <kasperi.kauppi@gmail.com> | 2019-08-27 21:28:46 +0300 |
---|---|---|
committer | Juuxel <kasperi.kauppi@gmail.com> | 2019-08-27 21:28:46 +0300 |
commit | ff9d53f7bcf8719578a6b87ec697fa6957bd209c (patch) | |
tree | df7fc34dd5dd24fb03d0786564bd604d14de0f61 /src/main/java/io | |
parent | e6e0a169f43b20485f1bddf9993d21dd661f15d2 (diff) | |
download | LibGui-ff9d53f7bcf8719578a6b87ec697fa6957bd209c.tar.gz LibGui-ff9d53f7bcf8719578a6b87ec697fa6957bd209c.tar.bz2 LibGui-ff9d53f7bcf8719578a6b87ec697fa6957bd209c.zip |
Some slider cleanup
Diffstat (limited to 'src/main/java/io')
-rw-r--r-- | src/main/java/io/github/cottonmc/cotton/gui/widget/WSlider.java | 9 |
1 files changed, 2 insertions, 7 deletions
diff --git a/src/main/java/io/github/cottonmc/cotton/gui/widget/WSlider.java b/src/main/java/io/github/cottonmc/cotton/gui/widget/WSlider.java index e308b14..7de2deb 100644 --- a/src/main/java/io/github/cottonmc/cotton/gui/widget/WSlider.java +++ b/src/main/java/io/github/cottonmc/cotton/gui/widget/WSlider.java @@ -43,10 +43,6 @@ public class WSlider extends WWidget { @Nullable private BackgroundPainter backgroundPainter = null; - // Used for visuals and detecting dragging after the user starts dragging - // on top of the slider, but then moves the mouse out but still within the widget's boundary. -// private boolean dragging = false; - public WSlider(int min, int max, Axis axis) { if (max <= min) throw new IllegalArgumentException("Minimum value must be smaller than the maximum!"); @@ -96,10 +92,9 @@ public class WSlider extends WWidget { @Override public void onMouseDrag(int x, int y, int button) { if (isFocused()) { - //dragging = true; int pos = (axis == Axis.VERTICAL ? (height - y) : x) - THUMB_SIZE / 2; - int futureValue = min + (int) (valueToCoordRatio * pos); - value = MathHelper.clamp(futureValue, min, max); + int rawValue = min + (int) (valueToCoordRatio * pos); + value = MathHelper.clamp(rawValue, min, max); if (valueChangeListener != null) valueChangeListener.accept(value); } } |