Skip to content

Commit

Permalink
expand widget
Browse files Browse the repository at this point in the history
  • Loading branch information
Hobbyshop committed May 20, 2024
1 parent b00f2a6 commit 458ae8d
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ abstract class LeafWidget : Widget() {
* @param constraints The constraints of the widget's size.
*/
override fun layout(constraints: BoxConstraints) {
size = Size(constraints.minWidth, constraints.minHeight)
size = constraints.smallest
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/com/neptuneclient/voidui/widgets/Align.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class Align(

override fun layout(constraints: BoxConstraints) {
child.layout(constraints)
size = Size(constraints.maxWidth, constraints.maxHeight)
size = constraints.biggest
}

override fun postLayoutInit(parentOffset: Offset, parent: Widget) {
Expand Down
10 changes: 10 additions & 0 deletions src/main/kotlin/com/neptuneclient/voidui/widgets/Expand.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.neptuneclient.voidui.widgets

import com.neptuneclient.voidui.framework.Widget

/**
* A widget which expands to the maximum constraints of the parent widget.
*
* @param child The child widget.
*/
fun Expand(child: Widget) = FractionallySizedBox(child, 1.0, 1.0)
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import java.awt.Color
class Placeholder : LeafWidget() {

override fun layout(constraints: BoxConstraints) {
size = Size(constraints.maxWidth, constraints.maxHeight)
size = constraints.biggest
}

override fun createRenderObject(): RenderObject? {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class ShaderBox(
}

override fun layout(constraints: BoxConstraints) {
val s = boxSize ?: Size(constraints.maxWidth, constraints.maxHeight)
val s = boxSize ?: constraints.biggest
size = constraints.constrain(s)
}

Expand Down

0 comments on commit 458ae8d

Please sign in to comment.