diff options
author | Wyvest <45589059+Wyvest@users.noreply.github.com> | 2022-06-12 17:21:36 +0700 |
---|---|---|
committer | Wyvest <45589059+Wyvest@users.noreply.github.com> | 2022-06-12 17:21:36 +0700 |
commit | 636df2c2b3b8e4aa0de64cf3b9aa5c089afd70a9 (patch) | |
tree | 521d8bc2f6e6f307f62e12a3deb7a05f0f72213e /src/main/java/cc/polyfrost/oneconfig/gui/pages/Page.java | |
parent | da5288bd5c80611acfeb1ebe33af1860f27f23fc (diff) | |
parent | cf8b1a7f962ad3a9c31e6698fb7caf82aac42a18 (diff) | |
download | OneConfig-636df2c2b3b8e4aa0de64cf3b9aa5c089afd70a9.tar.gz OneConfig-636df2c2b3b8e4aa0de64cf3b9aa5c089afd70a9.tar.bz2 OneConfig-636df2c2b3b8e4aa0de64cf3b9aa5c089afd70a9.zip |
Merge remote-tracking branch 'origin/master'
Diffstat (limited to 'src/main/java/cc/polyfrost/oneconfig/gui/pages/Page.java')
-rw-r--r-- | src/main/java/cc/polyfrost/oneconfig/gui/pages/Page.java | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/pages/Page.java b/src/main/java/cc/polyfrost/oneconfig/gui/pages/Page.java index 882289d..fff9482 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/pages/Page.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/pages/Page.java @@ -16,9 +16,9 @@ import org.lwjgl.input.Mouse; */ public abstract class Page { protected final String title; - private Animation scrollAnimation; + protected Animation scrollAnimation; private final ColorAnimation colorAnimation = new ColorAnimation(new ColorPalette(Colors.TRANSPARENT, Colors.GRAY_400_60, Colors.GRAY_400_60)); - private float scrollTarget; + protected float scrollTarget; private long scrollTime; private boolean mouseWasDown, dragging; private float yStart; @@ -69,23 +69,24 @@ public abstract class Page { } ScissorManager.resetScissor(vg, scissor); - if(!(scrollBarLength > 727f)) { + if (!(scrollBarLength > 727f)) { final float scrollBarY = (scroll / maxScroll) * 720f; final boolean isMouseDown = Mouse.isButtonDown(0); - final boolean scrollHover = InputUtils.isAreaHovered(x + 1042, (int) (y - scrollBarY), 12, (int) scrollBarLength) || (System.currentTimeMillis() - scrollTime < 1000); - final boolean hovered = scrollHover && Mouse.isButtonDown(0); - if (hovered && isMouseDown && !mouseWasDown) { + final boolean scrollHover = InputUtils.isAreaHovered(x + 1042, (int) (y - scrollBarY), 12, (int) scrollBarLength); + final boolean scrollTimePeriod = (System.currentTimeMillis() - scrollTime < 1000); + final boolean hovered = (scrollHover || scrollTimePeriod) && Mouse.isButtonDown(0); + if (scrollHover && isMouseDown && !mouseWasDown) { yStart = InputUtils.mouseY(); dragging = true; } mouseWasDown = isMouseDown; - if(dragging) { + if (dragging) { scrollTarget = -(InputUtils.mouseY() - yStart) * maxScroll / 728f; if (scrollTarget > 0f) scrollTarget = 0f; else if (scrollTarget < -maxScroll + 728) scrollTarget = -maxScroll + 728; scrollAnimation = new EaseOutQuad(150, scroll, scrollTarget, false); } - RenderManager.drawRoundedRect(vg, x + 1044, y - scrollBarY, 8, scrollBarLength, colorAnimation.getColor(scrollHover, dragging), 4f); + RenderManager.drawRoundedRect(vg, x + 1044, y - scrollBarY, 8, scrollBarLength, colorAnimation.getColor(scrollHover || scrollTimePeriod, dragging), 4f); } } |