Skip to content

Commit c9b82d5

Browse files
committed
fix tooltips rendering below the scrollbar
1 parent 5e0574b commit c9b82d5

3 files changed

Lines changed: 34 additions & 7 deletions

File tree

src/main/java/dev/isxander/yacl/gui/AbstractWidget.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ public AbstractWidget(Dimension<Integer> dim) {
2626
this.dim = dim;
2727
}
2828

29+
public void postRender(MatrixStack matrices, int mouseX, int mouseY, float delta) {
30+
31+
}
32+
2933
public void setDimension(Dimension<Integer> dim) {
3034
this.dim = dim;
3135
}

src/main/java/dev/isxander/yacl/gui/OptionListWidget.java

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,14 @@ protected void renderList(MatrixStack matrices, int mouseX, int mouseY, float de
140140
}
141141
}
142142

143+
@Override
144+
public void render(MatrixStack matrices, int mouseX, int mouseY, float delta) {
145+
super.render(matrices, mouseX, mouseY, delta);
146+
for (Entry entry : children()) {
147+
entry.postRender(matrices, mouseX, mouseY, delta);
148+
}
149+
}
150+
143151
/* END cloth config code */
144152

145153
@Override
@@ -206,6 +214,10 @@ public List<Entry> children() {
206214
}
207215

208216
public abstract class Entry extends ElementListWidget.Entry<Entry> {
217+
public void postRender(MatrixStack matrices, int mouseX, int mouseY, float delta) {
218+
219+
}
220+
209221
public boolean isViewable() {
210222
return true;
211223
}
@@ -235,6 +247,11 @@ public void render(MatrixStack matrices, int index, int y, int x, int entryWidth
235247
widget.render(matrices, mouseX, mouseY, tickDelta);
236248
}
237249

250+
@Override
251+
public void postRender(MatrixStack matrices, int mouseX, int mouseY, float delta) {
252+
widget.postRender(matrices, mouseX, mouseY, delta);
253+
}
254+
238255
@Override
239256
public boolean mouseScrolled(double mouseX, double mouseY, double amount) {
240257
return widget.mouseScrolled(mouseX, mouseY, amount);
@@ -314,14 +331,17 @@ public void render(MatrixStack matrices, int index, int y, int x, int entryWidth
314331

315332
wrappedName.drawCenterWithShadow(matrices, x + entryWidth / 2, y + getYPadding());
316333

317-
if (hoveredTicks >= YACLConstants.HOVER_TICKS) {
318-
screen.renderOrderedTooltip(matrices, wrappedTooltip, x - 6, y + entryHeight / 2 + 6 + (wrappedTooltip.size() * textRenderer.fontHeight) / 2);
319-
}
320-
321334
prevMouseX = mouseX;
322335
prevMouseY = mouseY;
323336
}
324337

338+
@Override
339+
public void postRender(MatrixStack matrices, int mouseX, int mouseY, float delta) {
340+
if (hoveredTicks >= YACLConstants.HOVER_TICKS) {
341+
screen.renderOrderedTooltip(matrices, wrappedTooltip, mouseX, mouseY);
342+
}
343+
}
344+
325345
public boolean isExpanded() {
326346
return groupExpanded;
327347
}

src/main/java/dev/isxander/yacl/gui/controllers/ControllerWidget.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,15 @@ public void render(MatrixStack matrices, int mouseX, int mouseY, float delta) {
6464
drawHoveredControl(matrices, mouseX, mouseY, delta);
6565
}
6666

67+
prevMouseX = mouseX;
68+
prevMouseY = mouseY;
69+
}
70+
71+
@Override
72+
public void postRender(MatrixStack matrices, int mouseX, int mouseY, float delta) {
6773
if (hoveredTicks > YACLConstants.HOVER_TICKS) {
6874
screen.renderOrderedTooltip(matrices, wrappedTooltip, mouseX, mouseY);
6975
}
70-
71-
prevMouseX = mouseX;
72-
prevMouseY = mouseY;
7376
}
7477

7578
protected void drawHoveredControl(MatrixStack matrices, int mouseX, int mouseY, float delta) {

0 commit comments

Comments
 (0)