diff options
author | isXander <xander@isxander.dev> | 2024-02-29 22:24:57 +0000 |
---|---|---|
committer | isXander <xander@isxander.dev> | 2024-02-29 22:24:57 +0000 |
commit | 9dce73ba8c10960e6502825b14c91e6ec56393a4 (patch) | |
tree | f53a26ea3c6efcea5ee7dd466ad2373ad6123dee /common/src/main/java/dev/isxander/yacl3/gui | |
parent | 0a10f11494db07f974b416c1f69184728b68374c (diff) | |
download | YetAnotherConfigLib-9dce73ba8c10960e6502825b14c91e6ec56393a4.tar.gz YetAnotherConfigLib-9dce73ba8c10960e6502825b14c91e6ec56393a4.tar.bz2 YetAnotherConfigLib-9dce73ba8c10960e6502825b14c91e6ec56393a4.zip |
Fix keyboard/controller navigation not properly scrolling when overflowing
Diffstat (limited to 'common/src/main/java/dev/isxander/yacl3/gui')
-rw-r--r-- | common/src/main/java/dev/isxander/yacl3/gui/ElementListWidgetExt.java | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/common/src/main/java/dev/isxander/yacl3/gui/ElementListWidgetExt.java b/common/src/main/java/dev/isxander/yacl3/gui/ElementListWidgetExt.java index 91cda1f..3ae9bdb 100644 --- a/common/src/main/java/dev/isxander/yacl3/gui/ElementListWidgetExt.java +++ b/common/src/main/java/dev/isxander/yacl3/gui/ElementListWidgetExt.java @@ -124,6 +124,20 @@ public class ElementListWidgetExt<E extends ElementListWidgetExt.Entry<E>> exten } @Override + protected void ensureVisible(E entry) { + int i = this.getRowTop(this.children().indexOf(entry)); + int j = i - this.getY() - 4 - entry.getItemHeight(); + if (j < 0) { + this.setScrollAmount(this.getScrollAmount() + j); + } + + int k = this.getBottom() - i - entry.getItemHeight() * 2; + if (k < 0) { + this.setScrollAmount(this.getScrollAmount() - k); + } + } + + @Override protected void renderList(GuiGraphics graphics, int mouseX, int mouseY, float delta) { int left = this.getRowLeft(); int right = this.getRowWidth(); |