From 661754ffb1e7150659d7dc43d3a7d024d776f0b5 Mon Sep 17 00:00:00 2001 From: Juuxel <6596629+Juuxel@users.noreply.github.com> Date: Mon, 20 Jan 2020 20:47:00 +0200 Subject: Actually fix WClippedPanel Thanks @vini2003! --- .../java/io/github/cottonmc/cotton/gui/widget/WClippedPanel.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/main') diff --git a/src/main/java/io/github/cottonmc/cotton/gui/widget/WClippedPanel.java b/src/main/java/io/github/cottonmc/cotton/gui/widget/WClippedPanel.java index 23acfc0..191e7ef 100644 --- a/src/main/java/io/github/cottonmc/cotton/gui/widget/WClippedPanel.java +++ b/src/main/java/io/github/cottonmc/cotton/gui/widget/WClippedPanel.java @@ -24,10 +24,13 @@ public class WClippedPanel extends WPanel { GL11.glEnable(GL11.GL_SCISSOR_TEST); MinecraftClient mc = MinecraftClient.getInstance(); + int rawHeight = mc.getWindow().getHeight(); double scaleFactor = mc.getWindow().getScaleFactor(); int scaledWidth = (int) (getWidth() * scaleFactor); int scaledHeight = (int) (getHeight() * scaleFactor); - GL11.glScissor((int) (x * scaleFactor), (int) ((y + scaleFactor * (1 - this.y + 18)) * scaleFactor), scaledWidth, scaledHeight); + + // Expression for Y coordinate adapted from vini2003's Spinnery (code snippet released under WTFPL) + GL11.glScissor((int) (x * scaleFactor), (int) (rawHeight - (y * scaleFactor) - scaledHeight), scaledWidth, scaledHeight); for(WWidget child : children) { child.paintBackground(x + child.getX(), y + child.getY(), mouseX-child.getX(), mouseY-child.getY()); -- cgit