aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/renderables/Renderable.kt32
1 files changed, 28 insertions, 4 deletions
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 92d5a4cf9..b9666fe12 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/renderables/Renderable.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/renderables/Renderable.kt
@@ -511,19 +511,43 @@ interface Renderable {
val renderables = content
override val width = renderables.sumOf { it.width } + spacing * (renderables.size - 1)
- override val height = renderables.maxOf { it.height }
+ override val height = renderables.maxOfOrNull { it.height } ?: 0
override val horizontalAlign = horizontalAlign
override val verticalAlign = verticalAlign
override fun render(posX: Int, posY: Int) {
- var xOffset = 0
+ var xOffset = posX
renderables.forEach {
- it.renderYAligned(xOffset, 0, height)
+ it.renderYAligned(xOffset, posY, height)
xOffset += it.width + spacing
- GlStateManager.translate(it.width.toFloat(), 0f, 0f)
+ GlStateManager.translate((it.width + spacing).toFloat(), 0f, 0f)
}
GlStateManager.translate(-width.toFloat() - spacing.toFloat(), 0f, 0f)
}
}
+
+ fun verticalContainer(
+ content: List<Renderable>,
+ spacing: Int = 0,
+ horizontalAlign: HorizontalAlignment = HorizontalAlignment.LEFT,
+ verticalAlign: VerticalAlignment = VerticalAlignment.TOP,
+ ) = object : Renderable {
+ val renderables = content
+
+ override val width = renderables.maxOfOrNull { it.width } ?: 0
+ override val height = renderables.sumOf { it.height } + spacing * (renderables.size - 1)
+ override val horizontalAlign = horizontalAlign
+ override val verticalAlign = verticalAlign
+
+ override fun render(posX: Int, posY: Int) {
+ var yOffset = posY
+ renderables.forEach {
+ it.renderXAligned(yOffset, posX, width)
+ yOffset += it.height + spacing
+ GlStateManager.translate(0f, (it.height + spacing).toFloat(), 0f)
+ }
+ GlStateManager.translate(0f, -height.toFloat() - spacing.toFloat(), 0f)
+ }
+ }
}
}