aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
authorxander <xander@isxander.dev>2022-09-12 20:38:56 +0100
committerxander <xander@isxander.dev>2022-09-12 20:38:56 +0100
commitc9b82d52999f8c5f3f8c53e5a55327b8dfcf2beb (patch)
tree324d19ef04331fc33a5d38f7e0f5852613fb71f1 /src/main/java
parent5e0574b1cb6ef22bf70ce52a0c0e187450189c6c (diff)
downloadYetAnotherConfigLib-c9b82d52999f8c5f3f8c53e5a55327b8dfcf2beb.tar.gz
YetAnotherConfigLib-c9b82d52999f8c5f3f8c53e5a55327b8dfcf2beb.tar.bz2
YetAnotherConfigLib-c9b82d52999f8c5f3f8c53e5a55327b8dfcf2beb.zip
fix tooltips rendering below the scrollbar
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/dev/isxander/yacl/gui/AbstractWidget.java4
-rw-r--r--src/main/java/dev/isxander/yacl/gui/OptionListWidget.java28
-rw-r--r--src/main/java/dev/isxander/yacl/gui/controllers/ControllerWidget.java9
3 files changed, 34 insertions, 7 deletions
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<Integer> 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<OptionListWidget.Entry>
}
}
+ @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<OptionListWidget.Entry>
}
public abstract class Entry extends ElementListWidget.Entry<Entry> {
+ public void postRender(MatrixStack matrices, int mouseX, int mouseY, float delta) {
+
+ }
+
public boolean isViewable() {
return true;
}
@@ -236,6 +248,11 @@ public class OptionListWidget extends ElementListWidget<OptionListWidget.Entry>
}
@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<OptionListWidget.Entry>
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<T extends Controller<?>> 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) {