aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
authorJuuxel <6596629+Juuxel@users.noreply.github.com>2020-05-08 22:47:06 +0300
committerJuuxel <6596629+Juuxel@users.noreply.github.com>2020-05-08 22:47:06 +0300
commit21c781b162ab649e10c076343cec9dd0f8736deb (patch)
treeb1e1c1b46750bdfa86e3f99b11ef3b2625e75e48 /src/main/java
parentfe0277477fbf0290429c1d593afc7bcc63db3a35 (diff)
downloadLibGui-21c781b162ab649e10c076343cec9dd0f8736deb.tar.gz
LibGui-21c781b162ab649e10c076343cec9dd0f8736deb.tar.bz2
LibGui-21c781b162ab649e10c076343cec9dd0f8736deb.zip
Fix slider scrolling with keys
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/io/github/cottonmc/cotton/gui/widget/WAbstractSlider.java28
1 files changed, 19 insertions, 9 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 8f93221..3367b1d 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
@@ -336,28 +336,38 @@ public abstract class WAbstractSlider extends WWidget {
}
}
- private static boolean isDecreasingKey(int ch) {
- return ch == GLFW.GLFW_KEY_LEFT || ch == GLFW.GLFW_KEY_DOWN;
+ private boolean isDecreasingKey(int ch) {
+ return direction.isInverted()
+ ? (ch == GLFW.GLFW_KEY_RIGHT || ch == GLFW.GLFW_KEY_UP)
+ : (ch == GLFW.GLFW_KEY_LEFT || ch == GLFW.GLFW_KEY_DOWN);
}
- private static boolean isIncreasingKey(int ch) {
- return ch == GLFW.GLFW_KEY_RIGHT || ch == GLFW.GLFW_KEY_UP;
+ private boolean isIncreasingKey(int ch) {
+ return direction.isInverted()
+ ? (ch == GLFW.GLFW_KEY_LEFT || ch == GLFW.GLFW_KEY_DOWN)
+ : (ch == GLFW.GLFW_KEY_RIGHT || ch == GLFW.GLFW_KEY_UP);
}
public enum Direction {
- UP(Axis.VERTICAL),
- DOWN(Axis.VERTICAL),
- LEFT(Axis.HORIZONTAL),
- RIGHT(Axis.HORIZONTAL);
+ UP(Axis.VERTICAL, false),
+ DOWN(Axis.VERTICAL, true),
+ LEFT(Axis.HORIZONTAL, true),
+ RIGHT(Axis.HORIZONTAL, false);
private final Axis axis;
+ private final boolean inverted;
- Direction(Axis axis) {
+ Direction(Axis axis, boolean inverted) {
this.axis = axis;
+ this.inverted = inverted;
}
public Axis getAxis() {
return axis;
}
+
+ public boolean isInverted() {
+ return inverted;
+ }
}
}