aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/moe/nea/firmament/gui/WSplitPanel.kt
diff options
context:
space:
mode:
authornea <nea@nea.moe>2023-07-31 21:27:07 +0200
committernea <nea@nea.moe>2023-07-31 21:27:07 +0200
commitc3e1bab941f47dfd5ef5c55805015ee5d47da802 (patch)
treeb4db354834ad01260b2c544ae6bfe7e73de00a07 /src/main/kotlin/moe/nea/firmament/gui/WSplitPanel.kt
parentd8ee0c458a31352eefdb2100a53c3af268b2bb53 (diff)
downloadfirmament-c3e1bab941f47dfd5ef5c55805015ee5d47da802.tar.gz
firmament-c3e1bab941f47dfd5ef5c55805015ee5d47da802.tar.bz2
firmament-c3e1bab941f47dfd5ef5c55805015ee5d47da802.zip
Improve config gui handling
Diffstat (limited to 'src/main/kotlin/moe/nea/firmament/gui/WSplitPanel.kt')
-rw-r--r--src/main/kotlin/moe/nea/firmament/gui/WSplitPanel.kt23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/main/kotlin/moe/nea/firmament/gui/WSplitPanel.kt b/src/main/kotlin/moe/nea/firmament/gui/WSplitPanel.kt
new file mode 100644
index 0000000..0d13e42
--- /dev/null
+++ b/src/main/kotlin/moe/nea/firmament/gui/WSplitPanel.kt
@@ -0,0 +1,23 @@
+package moe.nea.firmament.gui
+
+import io.github.cottonmc.cotton.gui.widget.WPanel
+import io.github.cottonmc.cotton.gui.widget.WPanelWithInsets
+import io.github.cottonmc.cotton.gui.widget.WWidget
+
+class WSplitPanel(val left: WWidget, val right: WWidget) : WPanelWithInsets() {
+ init {
+ left.parent = this
+ right.parent = this
+ children.add(left)
+ children.add(right)
+ }
+
+ override fun layout() {
+ expandToFit(left, insets)
+ expandToFit(right, insets)
+ (left as? WPanel)?.layout()
+ (right as? WPanel)?.layout()
+ left.setLocation(insets.left, insets.top)
+ right.setLocation(width - insets.right - right.width, insets.top)
+ }
+}