Skip to content

Commit

Permalink
padding widget
Browse files Browse the repository at this point in the history
  • Loading branch information
Hobbyshop committed Mar 30, 2024
1 parent ebf375f commit 07a4519
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.neptuneclient.voidui.units
package com.neptuneclient.voidui.widgets.objects

data class EdgeInsets(
val left: Float,
Expand Down
10 changes: 10 additions & 0 deletions src/main/kotlin/com/neptuneclient/voidui/widgets/widgets.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.neptuneclient.voidui.widgets

import com.neptuneclient.voidui.widgets.objects.EdgeInsets

/**
* An internal widget which is used to bundle other widgets.
*
Expand Down Expand Up @@ -44,3 +46,11 @@ class Column(private val children: Array<Widget> = arrayOf(), private val gap: I
}

}

class Padding(private val child: Widget, private val padding: EdgeInsets = EdgeInsets.zero) : Widget() {

override fun build(): Widget {
return child
}

}
14 changes: 9 additions & 5 deletions src/test/kotlin/com/neptuneclient/voidui/tests/ScreenTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ package com.neptuneclient.voidui.tests

import com.neptuneclient.voidui.VoidUI
import com.neptuneclient.voidui.widgets.*
import com.neptuneclient.voidui.widgets.objects.EdgeInsets
import org.junit.jupiter.api.condition.DisabledIfEnvironmentVariable
import org.lwjgl.glfw.GLFW

Expand All @@ -13,11 +14,14 @@ class TestScreen(void: VoidUI) : Screen(void) {

override fun build(): Widget {
return Panel(
child = Column(
gap = 10, // 10 pixels
children = arrayOf(
Text("Hello"),
Text("World")
child = Padding(
padding = EdgeInsets.all(10F),
child = Column(
gap = 10, // 10 pixels
children = arrayOf(
Text("Hello"),
Text("World")
)
)
)
)
Expand Down

0 comments on commit 07a4519

Please sign in to comment.