I have some content which is exactly 500x500 pixels which I'd like to show in a window.
If I set the window size via state = WindowState(...)
, it seems to create a window where the size is actually slightly smaller, so the content gets cut off.
Quick test app:
fun main() = application {
Window(onCloseRequest = ::exitApplication, state = WindowState(width = 500.dp, height = 500.dp), resizable = false) {
Surface(color = Color.Black, modifier = Modifier.fillMaxSize()) {
Canvas(modifier = Modifier.fillMaxSize()) {
withTransform(transformBlock = {
scale(500.0f, 500.0f, pivot = Offset.Zero)
}) {
drawLine(color = Color.Blue, start = Offset(0.0f, 0.0f), end = Offset(1.0f, 1.0f))
drawLine(color = Color.Blue, start = Offset(1.0f, 0.0f), end = Offset(0.0f, 1.0f))
}
}
}
}
}
The result is this window of outer size 486 x 493:
How do I do the equivalent of Swing's pack()
to fit the window to the content?