aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/dev/isxander/yacl/gui
diff options
context:
space:
mode:
authorxander <xander@isxander.dev>2022-09-02 11:10:42 +0100
committerxander <xander@isxander.dev>2022-09-02 11:10:42 +0100
commit7c58fdd5aa54e88c1526c49adacaf97cf3810eba (patch)
tree06aa3e2260f3f56d2295f8b96a9b10681421d927 /src/main/java/dev/isxander/yacl/gui
parent1772186447fc01c1008caef402774e1a65a065e9 (diff)
downloadYetAnotherConfigLib-7c58fdd5aa54e88c1526c49adacaf97cf3810eba.tar.gz
YetAnotherConfigLib-7c58fdd5aa54e88c1526c49adacaf97cf3810eba.tar.bz2
YetAnotherConfigLib-7c58fdd5aa54e88c1526c49adacaf97cf3810eba.zip
allow slider dragging to continue outside of bounds
increase thumb-height by 2px
Diffstat (limited to 'src/main/java/dev/isxander/yacl/gui')
-rw-r--r--src/main/java/dev/isxander/yacl/gui/controllers/slider/SliderControllerElement.java9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/main/java/dev/isxander/yacl/gui/controllers/slider/SliderControllerElement.java b/src/main/java/dev/isxander/yacl/gui/controllers/slider/SliderControllerElement.java
index 104140d..997ba7d 100644
--- a/src/main/java/dev/isxander/yacl/gui/controllers/slider/SliderControllerElement.java
+++ b/src/main/java/dev/isxander/yacl/gui/controllers/slider/SliderControllerElement.java
@@ -67,7 +67,7 @@ public class SliderControllerElement extends ControllerWidget<ISliderController<
@Override
public boolean mouseDragged(double mouseX, double mouseY, int button, double deltaX, double deltaY) {
- if (button != 0 || !sliderBounds.isPointInside((int) mouseX, (int) mouseY))
+ if (button != 0 || !mouseDown)
return false;
setValueFromMouse(mouseX);
@@ -93,6 +93,11 @@ public class SliderControllerElement extends ControllerWidget<ISliderController<
return super.mouseReleased(mouseX, mouseY, button);
}
+ @Override
+ public boolean isMouseOver(double mouseX, double mouseY) {
+ return super.isMouseOver(mouseX, mouseY) || mouseDown;
+ }
+
private void setValueFromMouse(double mouseX) {
double value = (mouseX - sliderBounds.x()) / sliderBounds.width() * control.range();
double roundedValue = MathHelper.clamp(min + (interval * Math.round(value / interval)), min, max); // extremely imprecise, requires clamping
@@ -112,7 +117,7 @@ public class SliderControllerElement extends ControllerWidget<ISliderController<
@Override
public void setDimension(Dimension<Integer> dim) {
super.setDimension(dim);
- sliderBounds = Dimension.ofInt(dim.xLimit() - getXPadding() - getThumbWidth() / 2 - dim.width() / 3, dim.centerY() - 4, dim.width() / 3, 8);
+ sliderBounds = Dimension.ofInt(dim.xLimit() - getXPadding() - getThumbWidth() / 2 - dim.width() / 3, dim.centerY() - 5, dim.width() / 3, 10);
}
private int getThumbX() {