aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MScrollBar.java
diff options
context:
space:
mode:
authorsyeyoung <cyong06@naver.com>2021-08-01 23:43:10 +0900
committersyeyoung <cyong06@naver.com>2021-08-01 23:43:10 +0900
commitd1c36c2412b98350f8336e38361e49b3655982d5 (patch)
tree34f2d6396f69840f623254b5c6e50c3563f5cfda /src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MScrollBar.java
parent16a4367663f5ed2a909804de6d319c97c9854ecc (diff)
downloadSkyblock-Dungeons-Guide-d1c36c2412b98350f8336e38361e49b3655982d5.tar.gz
Skyblock-Dungeons-Guide-d1c36c2412b98350f8336e38361e49b3655982d5.tar.bz2
Skyblock-Dungeons-Guide-d1c36c2412b98350f8336e38361e49b3655982d5.zip
Too many changes to describe
Config gui overhaul.
Diffstat (limited to 'src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MScrollBar.java')
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MScrollBar.java33
1 files changed, 32 insertions, 1 deletions
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MScrollBar.java b/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MScrollBar.java
index 1797297a..82e91dab 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MScrollBar.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MScrollBar.java
@@ -42,6 +42,30 @@ public class MScrollBar extends MPanel {
@Setter
private int width = 10;
+ public void setMax(int max) {
+ this.max = max;
+
+ current = MathHelper.clamp_int(current, min, max - thumbSize);
+ if (max - min < thumbSize) current = min;
+ if (onUpdate != null) onUpdate.run();
+ }
+
+ public void setMin(int min) {
+ this.min = min;
+
+ current = MathHelper.clamp_int(current, min, max - thumbSize);
+ if (max - min < thumbSize) current = min;
+ if (onUpdate != null) onUpdate.run();
+ }
+
+ public void setThumbSize(int thumbSize) {
+ this.thumbSize = thumbSize;
+
+ current = MathHelper.clamp_int(current, min, max - thumbSize);
+ if (max - min < thumbSize) current = min;
+ if (onUpdate != null) onUpdate.run();
+ }
+
public void addToCurrent(int dv) {
int current2 = current + dv;
@@ -72,6 +96,12 @@ public class MScrollBar extends MPanel {
this.onUpdate = onUpdate;
}
+ @Override
+ public void setBounds(Rectangle bounds) {
+ super.setBounds(bounds);
+ lastThumbRect.width = 0; lastThumbRect.height = 0;
+ }
+
private Rectangle lastThumbRect = new Rectangle();
@Override
public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle scissor) {
@@ -156,7 +186,8 @@ public class MScrollBar extends MPanel {
public void mouseMoved(int absMouseX, int absMouseY, int relMouseX0, int relMouseY0) {
if (grabbed)
setCursor(EnumCursor.CLOSED_HAND);
- else if (lastThumbRect.contains(relMouseX0, relMouseY0))
+ else if (lastThumbRect.contains(relMouseX0, relMouseY0)) {
setCursor(EnumCursor.OPEN_HAND);
+ }
}
}