-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
107 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package com.neptuneclient.voidui.widgets | ||
|
||
import com.neptuneclient.voidui.framework.BoxConstraints | ||
import com.neptuneclient.voidui.framework.GroupWidget | ||
import com.neptuneclient.voidui.framework.Size | ||
import com.neptuneclient.voidui.framework.Widget | ||
import kotlin.math.max | ||
|
||
/** | ||
* A widget which layers multiple widgets on top of each other. | ||
* | ||
* @param children The array of children in the stack. | ||
*/ | ||
class Stack(private val children: Array<Widget>) : GroupWidget() { | ||
|
||
override fun layout(constraints: BoxConstraints) { | ||
var childWidth = 0f | ||
var childHeight = 0f | ||
|
||
children.forEach { | ||
it.layout(constraints) | ||
childWidth = max(childWidth, it.size.width) | ||
childHeight = max(childHeight, it.size.height) | ||
} | ||
size = constraints.constrain(Size(childWidth, childHeight)) | ||
} | ||
|
||
override fun buildGroup(): Array<Widget> { | ||
return children | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters