Skip to content

Commit

Permalink
column widget
Browse files Browse the repository at this point in the history
  • Loading branch information
Hobbyshop committed Mar 30, 2024
1 parent 2dbc66b commit ebf375f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
12 changes: 10 additions & 2 deletions src/main/kotlin/com/neptuneclient/voidui/widgets/widgets.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ package com.neptuneclient.voidui.widgets
*
* @param children An array with all chidren widgets.
*/
internal class Group(protected val children: Array<Widget>) : Widget() {
internal class Group(private val children: Array<Widget>) : Widget() {

override fun init(screen: Screen, parent: Widget?) {
this.screen = screen
Expand Down Expand Up @@ -35,4 +35,12 @@ class Row(private val children: Array<Widget> = arrayOf(), private val gap: Int
return Group(children)
}

}
}

class Column(private val children: Array<Widget> = arrayOf(), private val gap: Int = 0) : Widget() {

override fun build(): Widget {
return Group(children)
}

}
8 changes: 7 additions & 1 deletion src/test/kotlin/com/neptuneclient/voidui/tests/ScreenTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,13 @@ class TestScreen(void: VoidUI) : Screen(void) {

override fun build(): Widget {
return Panel(
child = Text("Hello World!")
child = Column(
gap = 10, // 10 pixels
children = arrayOf(
Text("Hello"),
Text("World")
)
)
)
}

Expand Down

0 comments on commit ebf375f

Please sign in to comment.