Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions korge/src/korlibs/korge/ui/UIWindow.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,13 @@ import korlibs.time.*
inline fun Container.uiWindow(
title: String,
size: Size = Size(256, 256),
resizable: Boolean = true,
configure: @ViewDslMarker UIWindow.() -> Unit = {},
block: @ViewDslMarker Container.(UIWindow) -> Unit = {},
): UIWindow = UIWindow(title, size).addTo(this).apply(configure).also { block(it.container.container, it) }
): UIWindow = UIWindow(title, size, resizable).addTo(this).apply(configure).also { block(it.container.container, it) }

@KorgeExperimental
class UIWindow(title: String, size: Size = Size(256, 256)) : UIContainer(size) {
class UIWindow(title: String, size: Size = Size(256, 256), private var resizable: Boolean = true) : UIContainer(size) {
private val titleHeight = 32.0
private val buttonSeparation = 6.0
val isFocused get() = this.index == (parent?.numChildren ?: 0) -1
Expand Down Expand Up @@ -235,7 +236,11 @@ class UIWindow(title: String, size: Size = Size(256, 256)) : UIContainer(size) {
titleContainer.size(width, titleHeight)
container.size(width, height - titleHeight)
closeButton.position(width - titleHeight - buttonSeparation, buttonSeparation)
scaleHandlers.fastForEach { it.resized(width, height) }

if (resizable){
scaleHandlers.fastForEach { it.resized(width, height) }
}

}

fun close() {
Expand Down
Loading