From c9b82d52999f8c5f3f8c53e5a55327b8dfcf2beb Mon Sep 17 00:00:00 2001 From: xander Date: Mon, 12 Sep 2022 20:38:56 +0100 Subject: fix tooltips rendering below the scrollbar --- .../java/dev/isxander/yacl/gui/AbstractWidget.java | 4 ++++ .../dev/isxander/yacl/gui/OptionListWidget.java | 28 ++++++++++++++++++---- .../yacl/gui/controllers/ControllerWidget.java | 9 ++++--- 3 files changed, 34 insertions(+), 7 deletions(-) (limited to 'src/main/java/dev/isxander/yacl/gui') diff --git a/src/main/java/dev/isxander/yacl/gui/AbstractWidget.java b/src/main/java/dev/isxander/yacl/gui/AbstractWidget.java index 0886589..f81cc99 100644 --- a/src/main/java/dev/isxander/yacl/gui/AbstractWidget.java +++ b/src/main/java/dev/isxander/yacl/gui/AbstractWidget.java @@ -26,6 +26,10 @@ public abstract class AbstractWidget implements Element, Drawable, Selectable { this.dim = dim; } + public void postRender(MatrixStack matrices, int mouseX, int mouseY, float delta) { + + } + public void setDimension(Dimension dim) { this.dim = dim; } diff --git a/src/main/java/dev/isxander/yacl/gui/OptionListWidget.java b/src/main/java/dev/isxander/yacl/gui/OptionListWidget.java index 5b80e51..d6a28f3 100644 --- a/src/main/java/dev/isxander/yacl/gui/OptionListWidget.java +++ b/src/main/java/dev/isxander/yacl/gui/OptionListWidget.java @@ -140,6 +140,14 @@ public class OptionListWidget extends ElementListWidget } } + @Override + public void render(MatrixStack matrices, int mouseX, int mouseY, float delta) { + super.render(matrices, mouseX, mouseY, delta); + for (Entry entry : children()) { + entry.postRender(matrices, mouseX, mouseY, delta); + } + } + /* END cloth config code */ @Override @@ -206,6 +214,10 @@ public class OptionListWidget extends ElementListWidget } public abstract class Entry extends ElementListWidget.Entry { + public void postRender(MatrixStack matrices, int mouseX, int mouseY, float delta) { + + } + public boolean isViewable() { return true; } @@ -235,6 +247,11 @@ public class OptionListWidget extends ElementListWidget widget.render(matrices, mouseX, mouseY, tickDelta); } + @Override + public void postRender(MatrixStack matrices, int mouseX, int mouseY, float delta) { + widget.postRender(matrices, mouseX, mouseY, delta); + } + @Override public boolean mouseScrolled(double mouseX, double mouseY, double amount) { return widget.mouseScrolled(mouseX, mouseY, amount); @@ -314,14 +331,17 @@ public class OptionListWidget extends ElementListWidget wrappedName.drawCenterWithShadow(matrices, x + entryWidth / 2, y + getYPadding()); - if (hoveredTicks >= YACLConstants.HOVER_TICKS) { - screen.renderOrderedTooltip(matrices, wrappedTooltip, x - 6, y + entryHeight / 2 + 6 + (wrappedTooltip.size() * textRenderer.fontHeight) / 2); - } - prevMouseX = mouseX; prevMouseY = mouseY; } + @Override + public void postRender(MatrixStack matrices, int mouseX, int mouseY, float delta) { + if (hoveredTicks >= YACLConstants.HOVER_TICKS) { + screen.renderOrderedTooltip(matrices, wrappedTooltip, mouseX, mouseY); + } + } + public boolean isExpanded() { return groupExpanded; } diff --git a/src/main/java/dev/isxander/yacl/gui/controllers/ControllerWidget.java b/src/main/java/dev/isxander/yacl/gui/controllers/ControllerWidget.java index 498ecdd..54c426d 100644 --- a/src/main/java/dev/isxander/yacl/gui/controllers/ControllerWidget.java +++ b/src/main/java/dev/isxander/yacl/gui/controllers/ControllerWidget.java @@ -64,12 +64,15 @@ public abstract class ControllerWidget> extends Abstract drawHoveredControl(matrices, mouseX, mouseY, delta); } + prevMouseX = mouseX; + prevMouseY = mouseY; + } + + @Override + public void postRender(MatrixStack matrices, int mouseX, int mouseY, float delta) { if (hoveredTicks > YACLConstants.HOVER_TICKS) { screen.renderOrderedTooltip(matrices, wrappedTooltip, mouseX, mouseY); } - - prevMouseX = mouseX; - prevMouseY = mouseY; } protected void drawHoveredControl(MatrixStack matrices, int mouseX, int mouseY, float delta) { -- cgit