Open Inego opened 3 years ago
Judging by the code, it seems an AppWindow cannot be shown after it was closed.
internal fun setContent(
parentComposition: CompositionContext? = null,
content: @Composable () -> Unit
) {
check(!isDisposed)
check(this.content == null) { "Cannot set content twice" }
...
Thanks!
We plan to gradually replace AppWindow API by Composable Window API (prototype).
So the current example probably will be:
fun main() = Application {
val checkBoxState = remember { mutableStateOf(false) }
Window {
if (checkBoxState) {
Window("Child") {
Text("Content")
}
}
Checkbox(checkBoxState.value, {
checkBoxState.value = it
})
}
}
(it is not a final API, don't know yet how we will support child non-modal windows).
Regarding the current API - don't know if it is good or bad to provide ability to reshow AppWindow 🤔 (we can make AppWindow nullable and just create a new AppWindow). We would intevestigate use-cases, if we aren't implementing a new API.
We plan to gradually replace AppWindow API by Composable Window API (prototype).
So the current example probably will be: ...
This API looks great! I wonder how fine-tuning of such windows will work (like, to specify window keyboard shortcuts).
how fine-tuning of such windows will work
Probably something like this:
val state = rememberWindowState(width = 100.dp)
Window(title = "Title", state = state) {
Button(onClick = { state.resize(height= 200.dp) })
}
We will also provide the ability to manually tune underlying JFrame:
Window(title = "Title", configure = { jframe : JFrame ->
// do something with jframe
})
specify window keyboard shortcuts
We don't know yet about window shortcuts, but we will try to keep all the current functionality in the new API. If we remove some functionality we will provide an alternative.
Maybe something like https://github.com/JetBrains/compose-jb/tree/master/tutorials/Swing_Integration#adding-a-swing-component-to-cfd-composition-using-swingpanel which returns JPanel would make sense.
Compose Desktop 0.3.2.