aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJuuxel <kasperi.kauppi@gmail.com>2019-08-27 21:28:46 +0300
committerJuuxel <kasperi.kauppi@gmail.com>2019-08-27 21:28:46 +0300
commitff9d53f7bcf8719578a6b87ec697fa6957bd209c (patch)
treedf7fc34dd5dd24fb03d0786564bd604d14de0f61
parente6e0a169f43b20485f1bddf9993d21dd661f15d2 (diff)
downloadLibGui-ff9d53f7bcf8719578a6b87ec697fa6957bd209c.tar.gz
LibGui-ff9d53f7bcf8719578a6b87ec697fa6957bd209c.tar.bz2
LibGui-ff9d53f7bcf8719578a6b87ec697fa6957bd209c.zip
Some slider cleanup
-rw-r--r--build.gradle2
-rw-r--r--src/main/java/io/github/cottonmc/cotton/gui/widget/WSlider.java9
2 files changed, 3 insertions, 8 deletions
diff --git a/build.gradle b/build.gradle
index ad484fd..c453a51 100644
--- a/build.gradle
+++ b/build.gradle
@@ -150,4 +150,4 @@ artifactory {
} else {
println "Cannot configure artifactory; please define ext.artifactoryUsername and ext.artifactoryPassword before running artifactoryPublish"
}
-}
+} \ No newline at end of file
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);
}
}