From 4794e12bed6dd8b597c1d66aa3902f38eb44e019 Mon Sep 17 00:00:00 2001 From: Leo dev Date: Mon, 21 Apr 2025 17:10:28 +0200 Subject: [PATCH] almost there --- .../org/saturnclient/ui2/RenderScope.java | 60 ++++++------------- .../org/saturnclient/ui2/elements/Button.java | 9 ++- 2 files changed, 23 insertions(+), 46 deletions(-) diff --git a/src/main/java/org/saturnclient/ui2/RenderScope.java b/src/main/java/org/saturnclient/ui2/RenderScope.java index a439623..bd7ebe3 100644 --- a/src/main/java/org/saturnclient/ui2/RenderScope.java +++ b/src/main/java/org/saturnclient/ui2/RenderScope.java @@ -71,8 +71,8 @@ public class RenderScope { } public void drawRoundedCorner(int width, int height, int radius, int color) { - int w = width * 10; - int h = height * 10; + int w = width * 20; + int h = height * 20; for (int y = 0; y < h; y++) { int startX; @@ -89,26 +89,17 @@ public class RenderScope { } } - public void drawRoundedRectangle(int x, int y, int width, int height, int radius, int color) { - int cornerWidth = width / 2; - int cornerHeight = height / 2; - + private void drawRoundedSide(int cornerWidth, int cornerHeight, int radius, int color) { + // Top this.matrices.push(); - this.matrices.translate(x, y, 0); + this.matrices.scale(0.05f, 0.05f, 1.0f); - // Top left - - this.matrices.push(); - - this.matrices.scale(0.1f, 0.1f, 1.0f); - - this.drawRoundedCorner(cornerWidth, cornerHeight, radius, color); + this.drawRoundedCorner(cornerWidth, cornerHeight, radius * 3, color); this.matrices.pop(); - // Bottom left - + // Bottom this.matrices.push(); this.matrices.translate(cornerWidth, cornerHeight * 2, 0); @@ -119,41 +110,28 @@ public class RenderScope { this.matrices.scale(0.1f, 0.1f, 1.0f); - this.drawRoundedCorner(cornerHeight, cornerWidth, radius, color); + this.drawRoundedCorner(cornerHeight, cornerWidth, radius * 3, color); this.matrices.pop(); + } - // Bottom right + public void drawRoundedRectangle(int x, int y, int width, int height, int radius, int color) { + int cornerWidth = width / 2; + int cornerHeight = height / 2; this.matrices.push(); - this.matrices.translate(cornerWidth * 2, cornerWidth > cornerHeight ? 0 : cornerHeight, 0); + this.matrices.translate(x, y, 0); + + this.drawRoundedSide(cornerWidth, cornerHeight, radius, color); + + this.matrices.translate(cornerWidth * 2, cornerHeight * 2, 0); this.matrices.multiply(RotationAxis.NEGATIVE_Z.rotationDegrees(180)); - this.matrices.translate(0, -cornerWidth, 0); + this.matrices.translate(0, 0, 0); - this.matrices.scale(0.1f, 0.1f, 1.0f); - - this.drawRoundedCorner(cornerWidth, cornerHeight, radius, color); - - this.matrices.pop(); - - - // top right - this.matrices.push(); - - this.matrices.translate(cornerWidth, 0, 0); - - this.matrices.multiply(RotationAxis.NEGATIVE_Z.rotationDegrees(270)); - - this.matrices.translate(0, -cornerWidth, 0); - - this.matrices.scale(0.1f, 0.1f, 1.0f); - - this.drawRoundedCorner(cornerHeight, cornerWidth, radius, 0xFFFFFFFF); - - this.matrices.pop(); + this.drawRoundedSide(cornerWidth, cornerHeight, radius, color); this.matrices.pop(); } diff --git a/src/main/java/org/saturnclient/ui2/elements/Button.java b/src/main/java/org/saturnclient/ui2/elements/Button.java index 686dfe5..26db6e6 100644 --- a/src/main/java/org/saturnclient/ui2/elements/Button.java +++ b/src/main/java/org/saturnclient/ui2/elements/Button.java @@ -19,12 +19,11 @@ public class Button extends Element { @Override public void render(RenderScope renderScope) { - int w = 100; - int h = 200; + int w = 300; + int h = 100; + renderScope.drawRect(0, h, w, h, color); + renderScope.drawRect(w, 0, w, h, color); renderScope.drawRoundedRectangle(0, 0, w, h, 80, 0xFF000000); - // renderScope.drawRect(0, h, w, h, color); - // renderScope.drawRect(w, 0, w, h, color); - // renderScope.drawText(this.text, this.x, this.y, false, this.color); } }