From 161ec2ae95b770ad7aa5571ff44dadcab9202790 Mon Sep 17 00:00:00 2001 From: Thunderblade73 <85900443+Thunderblade73@users.noreply.github.com> Date: Tue, 9 Apr 2024 21:10:31 +0200 Subject: Backend: Renderable.renderInsideRoundedRect (#890) Co-authored-by: VixidDev <52578495+VixidDev@users.noreply.github.com> Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com> --- .../skyhanni/utils/renderables/Renderable.kt | 23 ++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'src/main/java/at') diff --git a/src/main/java/at/hannibal2/skyhanni/utils/renderables/Renderable.kt b/src/main/java/at/hannibal2/skyhanni/utils/renderables/Renderable.kt index 9c7116e07..f3961660d 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/renderables/Renderable.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/renderables/Renderable.kt @@ -12,6 +12,7 @@ import at.hannibal2.skyhanni.utils.LorenzColor import at.hannibal2.skyhanni.utils.LorenzLogger import at.hannibal2.skyhanni.utils.NEUItems import at.hannibal2.skyhanni.utils.NEUItems.renderOnScreen +import at.hannibal2.skyhanni.utils.RenderUtils import at.hannibal2.skyhanni.utils.RenderUtils.HorizontalAlignment import at.hannibal2.skyhanni.utils.RenderUtils.VerticalAlignment import at.hannibal2.skyhanni.utils.renderables.RenderableUtils.calculateTableXOffsets @@ -545,5 +546,27 @@ interface Renderable { GlStateManager.translate(0f, -height.toFloat() - spacing.toFloat(), 0f) } } + + fun drawInsideRoundedRect( + input: Renderable, + color: Color, + padding: Int = 2, + radius: Int = 10, + smoothness: Int = 2, + horizontalAlign: HorizontalAlignment = HorizontalAlignment.LEFT, + verticalAlign: VerticalAlignment = VerticalAlignment.TOP, + ) = object : Renderable { + override val width = input.width + padding * 2 + override val height = input.height + padding * 2 + override val horizontalAlign = horizontalAlign + override val verticalAlign = verticalAlign + + override fun render(posX: Int, posY: Int) { + RenderUtils.drawRoundRect(0, 0, width, height, color.rgb, radius, smoothness) + GlStateManager.translate(padding.toFloat(), padding.toFloat(), 0f) + input.render(posX + padding, posY + padding) + GlStateManager.translate(-padding.toFloat(), -padding.toFloat(), 0f) + } + } } } -- cgit