Browse Source

Replace AppWindow by Window (#52)

pull/68/head
Igor Demin 4 years ago committed by GitHub
parent
commit
e9c45ecd69
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 9
      cef/src/main/kotlin/org/jetbrains/compose/desktop/App.kt
  2. 14
      tutorials/Window_API/README.md

9
cef/src/main/kotlin/org/jetbrains/compose/desktop/App.kt

@ -1,9 +1,7 @@
package org.jetbrains.compose.desktop
import androidx.compose.runtime.Composable
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.MutableState
import androidx.compose.desktop.AppWindow
import androidx.compose.desktop.Window
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
@ -11,7 +9,6 @@ import androidx.compose.foundation.layout.width
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.preferredHeight
import androidx.compose.foundation.layout.preferredSize
import androidx.compose.foundation.layout.padding
import androidx.compose.material.Surface
import androidx.compose.ui.Modifier
@ -19,7 +16,6 @@ import androidx.compose.ui.graphics.Color
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.IntSize
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.material.CircularProgressIndicator
import androidx.compose.material.TextField
import androidx.compose.material.Button
import androidx.compose.foundation.Text
@ -27,8 +23,7 @@ import org.jetbrains.compose.desktop.browser.BrowserState
import org.jetbrains.compose.desktop.browser.CefView
fun main() {
AppWindow("CEF-compose", IntSize(800, 800)).show {
Window("CEF-compose", IntSize(800, 800)) {
Surface(
modifier = Modifier.fillMaxSize(),
color = Color.DarkGray

14
tutorials/Window_API/README.md

@ -10,14 +10,26 @@ The main class for creating windows is AppWindow. The easiest way to create and
```kotlin
import androidx.compose.desktop.AppWindow
import javax.swing.SwingUtilities.invokeLater
fun main() {
fun main() = invokeLater {
AppWindow().show {
// content
}
}
```
Note that AppWindow should be created in AWT Event Thread. Instead of calling invokeLater explicitly you can use Window DSL:
```kotlin
import androidx.compose.desktop.Window
fun main() {
Window {
// content
}
}
```
There are two types of window – modal and regular. Below are the functions for creating each type of window:
1. Window – regular window type.

Loading…
Cancel
Save