diff --git a/README.md b/README.md index 1fc7bd40..946517ce 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ Preview functionality (check your application UI without building/running it) fo * [widgets gallery](examples/widgets-gallery) - Gallery of standard widgets * [IDEA plugin](examples/intellij-plugin) - Plugin for IDEA using Compose for Desktop * [gradle-plugins](gradle-plugins) - a plugin, simplifying usage of Compose Multiplatform with Gradle - * [templates](templates) - new application templates (see `desktop-template/build_and_run_from_cli_example.sh` for using without Gradle) + * [templates](templates) - new application templates * [tutorials](tutorials) - tutorials on using Compose Multiplatform * [Getting started](tutorials/Getting_Started) * [Image and icon manipulations](tutorials/Image_And_Icons_Manipulations) @@ -49,6 +49,7 @@ Preview functionality (check your application UI without building/running it) fo * [cef](experimental/cef) - CEF integration in Jetpack Compose (somewhat outdated) * [Video Player](experimental/components/VideoPlayer) * [LWJGL integration](experimental/lwjgl-integration) - An example showing how to integrate Compose with [LWJGL](https://www.lwjgl.org) + * [CLI example](build_from_cli) - An example showing how to build Compose without Gradle ## Getting latest version of Compose Multiplatform ## diff --git a/ci/compose-uber-jar/gradle.properties b/ci/compose-uber-jar/gradle.properties index 587b7801..8d2f5402 100644 --- a/ci/compose-uber-jar/gradle.properties +++ b/ci/compose-uber-jar/gradle.properties @@ -1,3 +1,3 @@ # __LATEST_COMPOSE_RELEASE_VERSION__ -compose.version=1.0.0-alpha1 +compose.version=1.0.0-rc12 kotlin.code.style=official diff --git a/components/gradle.properties b/components/gradle.properties index c9da67d1..d39bb40a 100644 --- a/components/gradle.properties +++ b/components/gradle.properties @@ -4,4 +4,4 @@ android.enableJetifier=true kotlin.code.style=official # __LATEST_COMPOSE_RELEASE_VERSION__ -compose.version=1.0.0-beta1 +compose.version=1.0.0-rc12 diff --git a/examples/codeviewer/build.gradle.kts b/examples/codeviewer/build.gradle.kts index 4102772a..e0fcff20 100644 --- a/examples/codeviewer/build.gradle.kts +++ b/examples/codeviewer/build.gradle.kts @@ -8,7 +8,7 @@ buildscript { dependencies { // __LATEST_COMPOSE_RELEASE_VERSION__ - classpath("org.jetbrains.compose:compose-gradle-plugin:1.0.0-beta5") + classpath("org.jetbrains.compose:compose-gradle-plugin:1.0.0-rc12") classpath("com.android.tools.build:gradle:4.2.2") // __KOTLIN_COMPOSE_VERSION__ classpath(kotlin("gradle-plugin", version = "1.5.31")) diff --git a/examples/falling-balls/build.gradle.kts b/examples/falling-balls/build.gradle.kts index afd2e0f3..1f50b3c8 100644 --- a/examples/falling-balls/build.gradle.kts +++ b/examples/falling-balls/build.gradle.kts @@ -6,7 +6,7 @@ plugins { // __KOTLIN_COMPOSE_VERSION__ kotlin("jvm") version "1.5.31" // __LATEST_COMPOSE_RELEASE_VERSION__ - id("org.jetbrains.compose") version "1.0.0-beta5" + id("org.jetbrains.compose") version "1.0.0-rc12" } group = "me.user" diff --git a/examples/imageviewer/build.gradle.kts b/examples/imageviewer/build.gradle.kts index 2f4668c2..c586374f 100755 --- a/examples/imageviewer/build.gradle.kts +++ b/examples/imageviewer/build.gradle.kts @@ -7,7 +7,7 @@ buildscript { dependencies { // __LATEST_COMPOSE_RELEASE_VERSION__ - classpath("org.jetbrains.compose:compose-gradle-plugin:1.0.0-beta5") + classpath("org.jetbrains.compose:compose-gradle-plugin:1.0.0-rc12") classpath("com.android.tools.build:gradle:4.1.0") classpath(kotlin("gradle-plugin", version = "1.5.31")) } diff --git a/examples/intellij-plugin/build.gradle.kts b/examples/intellij-plugin/build.gradle.kts index ab41df98..fd603f0b 100644 --- a/examples/intellij-plugin/build.gradle.kts +++ b/examples/intellij-plugin/build.gradle.kts @@ -5,7 +5,7 @@ plugins { java kotlin("jvm") version "1.5.31" // __LATEST_COMPOSE_RELEASE_VERSION__ - id("org.jetbrains.compose") version "1.0.0-beta1" + id("org.jetbrains.compose") version "1.0.0-rc12" id("idea") } diff --git a/examples/issues/build.gradle.kts b/examples/issues/build.gradle.kts index ac860964..c38f95b6 100644 --- a/examples/issues/build.gradle.kts +++ b/examples/issues/build.gradle.kts @@ -8,7 +8,7 @@ buildscript { dependencies { // __LATEST_COMPOSE_RELEASE_VERSION__ - classpath("org.jetbrains.compose:compose-gradle-plugin:1.0.0-beta5") + classpath("org.jetbrains.compose:compose-gradle-plugin:1.0.0-rc12") classpath("com.android.tools.build:gradle:4.1.3") // __KOTLIN_COMPOSE_VERSION__ classpath(kotlin("gradle-plugin", version = "1.5.31")) diff --git a/examples/notepad/build.gradle.kts b/examples/notepad/build.gradle.kts index e2ad2832..ffda206d 100644 --- a/examples/notepad/build.gradle.kts +++ b/examples/notepad/build.gradle.kts @@ -5,7 +5,7 @@ plugins { // __KOTLIN_COMPOSE_VERSION__ kotlin("jvm") version "1.5.31" // __LATEST_COMPOSE_RELEASE_VERSION__ - id("org.jetbrains.compose") version ("1.0.0-beta5") + id("org.jetbrains.compose") version ("1.0.0-rc12") } repositories { diff --git a/examples/todoapp-lite/build.gradle.kts b/examples/todoapp-lite/build.gradle.kts index 2f4668c2..c586374f 100755 --- a/examples/todoapp-lite/build.gradle.kts +++ b/examples/todoapp-lite/build.gradle.kts @@ -7,7 +7,7 @@ buildscript { dependencies { // __LATEST_COMPOSE_RELEASE_VERSION__ - classpath("org.jetbrains.compose:compose-gradle-plugin:1.0.0-beta5") + classpath("org.jetbrains.compose:compose-gradle-plugin:1.0.0-rc12") classpath("com.android.tools.build:gradle:4.1.0") classpath(kotlin("gradle-plugin", version = "1.5.31")) } diff --git a/examples/widgets-gallery/build.gradle.kts b/examples/widgets-gallery/build.gradle.kts index a74f2d88..0058f003 100644 --- a/examples/widgets-gallery/build.gradle.kts +++ b/examples/widgets-gallery/build.gradle.kts @@ -8,7 +8,7 @@ buildscript { dependencies { // __LATEST_COMPOSE_RELEASE_VERSION__ - classpath("org.jetbrains.compose:compose-gradle-plugin:1.0.0-beta5") + classpath("org.jetbrains.compose:compose-gradle-plugin:1.0.0-rc12") classpath("com.android.tools.build:gradle:4.2.0") // __KOTLIN_COMPOSE_VERSION__ classpath(kotlin("gradle-plugin", version = "1.5.31")) diff --git a/templates/desktop-template/build_and_run_from_cli_example.sh b/experimental/build_from_cli/build_and_run_from_cli_example.sh similarity index 93% rename from templates/desktop-template/build_and_run_from_cli_example.sh rename to experimental/build_from_cli/build_and_run_from_cli_example.sh index de5f4fdf..534b4d39 100644 --- a/templates/desktop-template/build_and_run_from_cli_example.sh +++ b/experimental/build_from_cli/build_and_run_from_cli_example.sh @@ -28,12 +28,11 @@ COROUTINES_VERSION=1.3.6 COLLECTIONS_VERSION=0.3 SPACE_REPO="https://public.jetbrains.space/p/compose/packages/maven/" MAVEN_CENTRAL="https://repo1.maven.org/maven2" -BINTRAY_KOTLINX="https://dl.bintray.com/kotlin/kotlinx" mavenDep "$SPACE_REPO" "org/jetbrains/skiko" "skiko-jvm-runtime-$PLATFORM" "$SKIKO_VERSION" mavenDep "$SPACE_REPO" "org/jetbrains/compose" "compose-full" "$COMPOSE_VERSION" mavenDep "$SPACE_REPO" "org/jetbrains/compose" "compose-compiler-hosted" "$COMPOSE_VERSION" -mavenDep "$BINTRAY_KOTLINX" "org/jetbrains/kotlinx" "kotlinx-collections-immutable-jvm" "$COLLECTIONS_VERSION" +mavenDep "$MAVEN_CENTRAL" "org/jetbrains/kotlinx" "kotlinx-collections-immutable-jvm" "$COLLECTIONS_VERSION" mavenDep "$MAVEN_CENTRAL" "org/jetbrains/kotlinx" "kotlinx-coroutines-core" "$COROUTINES_VERSION" mavenDep "$MAVEN_CENTRAL" "org/jetbrains/kotlin" "kotlin-stdlib" "$KOTLIN_VERSION" if [ ! -f "deps/kotlin-compiler-$KOTLIN_VERSION.zip" ]; then diff --git a/experimental/build_from_cli/src/main/kotlin/main.kt b/experimental/build_from_cli/src/main/kotlin/main.kt new file mode 100644 index 00000000..fed3f24a --- /dev/null +++ b/experimental/build_from_cli/src/main/kotlin/main.kt @@ -0,0 +1,31 @@ +import androidx.compose.desktop.ui.tooling.preview.Preview +import androidx.compose.material.Button +import androidx.compose.material.MaterialTheme +import androidx.compose.material.Text +import androidx.compose.runtime.Composable +import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember +import androidx.compose.runtime.setValue +import androidx.compose.ui.window.Window +import androidx.compose.ui.window.application + +@Composable +@Preview +fun App() { + var text by remember { mutableStateOf("Hello, World!") } + + MaterialTheme { + Button(onClick = { + text = "Hello, Desktop!" + }) { + Text(text) + } + } +} + +fun main() = application { + Window(onCloseRequest = ::exitApplication) { + App() + } +} diff --git a/experimental/components/gradle.properties b/experimental/components/gradle.properties index 74d745f3..d39bb40a 100644 --- a/experimental/components/gradle.properties +++ b/experimental/components/gradle.properties @@ -4,4 +4,4 @@ android.enableJetifier=true kotlin.code.style=official # __LATEST_COMPOSE_RELEASE_VERSION__ -compose.version=0.0.0-sync-2010-10-01-build393 +compose.version=1.0.0-rc12 diff --git a/experimental/lwjgl-integration/README.md b/experimental/lwjgl-integration/README.md index ed43c2f7..3e9ea3eb 100644 --- a/experimental/lwjgl-integration/README.md +++ b/experimental/lwjgl-integration/README.md @@ -4,4 +4,5 @@ Note that: - the integration is very experimental and can be unstable - not all features are implemented - not all features are currently supported (Accessibility, Input Methods) -- to pass some event information it is needed to pass it via AWT events (java.awt.KeyEvent and java.awt.MouseEvent). In the future versions of Compose we plan to get rid of the need of AWT events. \ No newline at end of file +- to pass some event information it is needed to pass it via AWT events (java.awt.KeyEvent and java.awt.MouseEvent). In the future versions of Compose we plan to get rid of the need of AWT events. +- it has bugs (it doesn't show cursor in TextField) \ No newline at end of file diff --git a/experimental/lwjgl-integration/build.gradle.kts b/experimental/lwjgl-integration/build.gradle.kts index a70eedf5..ef48a3c7 100644 --- a/experimental/lwjgl-integration/build.gradle.kts +++ b/experimental/lwjgl-integration/build.gradle.kts @@ -5,7 +5,7 @@ plugins { // __KOTLIN_COMPOSE_VERSION__ kotlin("jvm") version "1.5.31" // __LATEST_COMPOSE_RELEASE_VERSION__ - id("org.jetbrains.compose") version (System.getenv("COMPOSE_TEMPLATE_COMPOSE_VERSION") ?: "1.0.0-alpha4-build411") + id("org.jetbrains.compose") version (System.getenv("COMPOSE_TEMPLATE_COMPOSE_VERSION") ?: "1.0.0-rc12") } repositories { diff --git a/experimental/lwjgl-integration/src/main/kotlin/GlfwEvents.kt b/experimental/lwjgl-integration/src/main/kotlin/GlfwEvents.kt index 92cbd776..1615614a 100644 --- a/experimental/lwjgl-integration/src/main/kotlin/GlfwEvents.kt +++ b/experimental/lwjgl-integration/src/main/kotlin/GlfwEvents.kt @@ -2,15 +2,14 @@ import androidx.compose.ui.ComposeScene import androidx.compose.ui.ExperimentalComposeUiApi import androidx.compose.ui.geometry.Offset import androidx.compose.ui.input.key.KeyEvent -import androidx.compose.ui.input.key.NativeKeyEvent -import androidx.compose.ui.input.mouse.MouseScrollOrientation -import androidx.compose.ui.input.mouse.MouseScrollUnit import androidx.compose.ui.input.pointer.PointerEventType import androidx.compose.ui.unit.Density import org.lwjgl.glfw.GLFW.* import java.awt.Component import java.awt.event.InputEvent import java.awt.event.MouseEvent +import java.awt.event.MouseWheelEvent +import java.awt.event.KeyEvent as AwtKeyEvent @OptIn(ExperimentalComposeUiApi::class) fun ComposeScene.subscribeToGLFWEvents(windowHandle: Long) { @@ -22,7 +21,7 @@ fun ComposeScene.subscribeToGLFWEvents(windowHandle: Long) { GLFW_RELEASE -> PointerEventType.Release else -> PointerEventType.Unknown }, - mouseEvent = MouseEvent(getAwtMods(windowHandle)) + nativeEvent = MouseEvent(getAwtMods(windowHandle)) ) } @@ -30,7 +29,7 @@ fun ComposeScene.subscribeToGLFWEvents(windowHandle: Long) { sendPointerEvent( position = Offset(xpos.toFloat(), ypos.toFloat()), eventType = PointerEventType.Move, - mouseEvent = MouseEvent(getAwtMods(windowHandle)) + nativeEvent = MouseEvent(getAwtMods(windowHandle)) ) } @@ -38,25 +37,24 @@ fun ComposeScene.subscribeToGLFWEvents(windowHandle: Long) { sendPointerEvent( position = glfwGetCursorPos(windowHandle), eventType = if (entered) PointerEventType.Enter else PointerEventType.Exit, - mouseEvent = MouseEvent(getAwtMods(windowHandle)) + nativeEvent = MouseEvent(getAwtMods(windowHandle)) ) } glfwSetScrollCallback(windowHandle) { _, xoffset, yoffset -> - sendPointerScrollEvent( + sendPointerEvent( + eventType = PointerEventType.Scroll, position = glfwGetCursorPos(windowHandle), - delta = MouseScrollUnit.Line( - if (yoffset != 0.0) -3 * yoffset.toFloat() else -3 * xoffset.toFloat() - ), - orientation = if (yoffset != 0.0) MouseScrollOrientation.Vertical else MouseScrollOrientation.Horizontal + scrollDelta = Offset(xoffset.toFloat(), -yoffset.toFloat()), + nativeEvent = MouseWheelEvent(getAwtMods(windowHandle)) ) } glfwSetKeyCallback(windowHandle) { _, key, _, action, _ -> val awtId = when (action) { - GLFW_PRESS -> NativeKeyEvent.KEY_PRESSED - GLFW_REPEAT -> NativeKeyEvent.KEY_PRESSED - GLFW_RELEASE -> NativeKeyEvent.KEY_RELEASED + GLFW_PRESS -> AwtKeyEvent.KEY_PRESSED + GLFW_REPEAT -> AwtKeyEvent.KEY_PRESSED + GLFW_RELEASE -> AwtKeyEvent.KEY_RELEASED else -> error("Unknown type") } val awtKey = glfwToAwtKeyCode(key) @@ -64,13 +62,13 @@ fun ComposeScene.subscribeToGLFWEvents(windowHandle: Long) { // Note that we don't distinguish between Left/Right Shift, Del from numpad or not, etc. // To distinguish we should change `location` parameter - sendKeyEvent(KeyEvent(awtId, time, getAwtMods(windowHandle), awtKey, 0.toChar(), NativeKeyEvent.KEY_LOCATION_STANDARD)) + sendKeyEvent(KeyEvent(awtId, time, getAwtMods(windowHandle), awtKey, 0.toChar(), AwtKeyEvent.KEY_LOCATION_STANDARD)) } glfwSetCharCallback(windowHandle) { _, codepoint -> for (char in Character.toChars(codepoint)) { val time = System.nanoTime() / 1_000_000 - sendKeyEvent(KeyEvent(NativeKeyEvent.KEY_TYPED, time, getAwtMods(windowHandle), 0, char, NativeKeyEvent.KEY_LOCATION_UNKNOWN)) + sendKeyEvent(KeyEvent(AwtKeyEvent.KEY_TYPED, time, getAwtMods(windowHandle), 0, char, AwtKeyEvent.KEY_LOCATION_UNKNOWN)) } } @@ -90,13 +88,17 @@ private fun glfwGetCursorPos(window: Long): Offset { val awtComponent = object : Component() {} private fun KeyEvent(awtId: Int, time: Long, awtMods: Int, key: Int, char: Char, location: Int) = KeyEvent( - NativeKeyEvent(awtComponent, awtId, time, awtMods, key, char, location) + AwtKeyEvent(awtComponent, awtId, time, awtMods, key, char, location) ) private fun MouseEvent(awtMods: Int) = MouseEvent( awtComponent, 0, 0, awtMods, 0, 0, 1, false ) +private fun MouseWheelEvent(awtMods: Int) = MouseWheelEvent( + awtComponent, 0, 0, awtMods, 0, 0, 1, false, MouseWheelEvent.WHEEL_UNIT_SCROLL, 3, 1 +) + private fun getAwtMods(windowHandle: Long): Int { var awtMods = 0 if (glfwGetMouseButton(windowHandle, GLFW_MOUSE_BUTTON_1) == GLFW_PRESS) diff --git a/experimental/lwjgl-integration/src/main/kotlin/main.kt b/experimental/lwjgl-integration/src/main/kotlin/main.kt index c6810936..feb92e63 100644 --- a/experimental/lwjgl-integration/src/main/kotlin/main.kt +++ b/experimental/lwjgl-integration/src/main/kotlin/main.kt @@ -65,7 +65,7 @@ fun main() { glfwDispatcher.runLoop() - composeScene.dispose() + composeScene.close() glfwDestroyWindow(windowHandle) exitProcess(0) diff --git a/gradle-plugins/gradle.properties b/gradle-plugins/gradle.properties index e2ddf72b..7b8b51e1 100644 --- a/gradle-plugins/gradle.properties +++ b/gradle-plugins/gradle.properties @@ -6,7 +6,7 @@ kotlin.code.style=official # unless overridden by COMPOSE_GRADLE_PLUGIN_COMPOSE_VERSION env var. # # __LATEST_COMPOSE_RELEASE_VERSION__ -compose.version=1.0.0-beta1 +compose.version=1.0.0-rc12 compose.with.web=false # A version of Gradle plugin, that will be published, diff --git a/templates/desktop-template/build.gradle.kts b/templates/desktop-template/build.gradle.kts index fb62876f..872e8f05 100644 --- a/templates/desktop-template/build.gradle.kts +++ b/templates/desktop-template/build.gradle.kts @@ -5,7 +5,7 @@ plugins { // __KOTLIN_COMPOSE_VERSION__ kotlin("jvm") version "1.5.31" // __LATEST_COMPOSE_RELEASE_VERSION__ - id("org.jetbrains.compose") version (System.getenv("COMPOSE_TEMPLATE_COMPOSE_VERSION") ?: "1.0.0-beta5") + id("org.jetbrains.compose") version (System.getenv("COMPOSE_TEMPLATE_COMPOSE_VERSION") ?: "1.0.0-rc12") } repositories { diff --git a/templates/multiplatform-template/build.gradle.kts b/templates/multiplatform-template/build.gradle.kts index b894386c..4b83915f 100644 --- a/templates/multiplatform-template/build.gradle.kts +++ b/templates/multiplatform-template/build.gradle.kts @@ -1,6 +1,6 @@ buildscript { // __LATEST_COMPOSE_RELEASE_VERSION__ - val composeVersion = System.getenv("COMPOSE_TEMPLATE_COMPOSE_VERSION") ?: "1.0.0-beta5" + val composeVersion = System.getenv("COMPOSE_TEMPLATE_COMPOSE_VERSION") ?: "1.0.0-rc12" repositories { mavenCentral() diff --git a/templates/web-template/build.gradle.kts b/templates/web-template/build.gradle.kts index ae1ee334..af2ecc12 100644 --- a/templates/web-template/build.gradle.kts +++ b/templates/web-template/build.gradle.kts @@ -6,7 +6,7 @@ plugins { // __KOTLIN_COMPOSE_VERSION__ kotlin("multiplatform") version "1.5.31" // __LATEST_COMPOSE_RELEASE_VERSION__ - id("org.jetbrains.compose") version ("1.0.0-beta5") + id("org.jetbrains.compose") version ("1.0.0-rc12") } repositories { diff --git a/tutorials/Getting_Started/README.md b/tutorials/Getting_Started/README.md index f8259670..7bd8eb68 100644 --- a/tutorials/Getting_Started/README.md +++ b/tutorials/Getting_Started/README.md @@ -40,11 +40,11 @@ just search for "Compose Multiplatform". ### Update the wizard plugin -The Compose plugin version used in the wizard above may be not the last. Update the version of the plugin to the latest available by editing the `build.gradle.kts` file, finding and updating the version information as shown below. In this example the latest version of the plugin was 1.0.0-alpha4-build362 and a compatible version of kotlin was 1.5.31. For the latest versions, see the [latest versions](https://github.com/JetBrains/compose-jb/releases) site and the [Kotlin](https://kotlinlang.org/) site. +The Compose plugin version used in the wizard above may be not the last. Update the version of the plugin to the latest available by editing the `build.gradle.kts` file, finding and updating the version information as shown below. In this example the latest version of the plugin was 1.0.0-rc12 and a compatible version of kotlin was 1.5.31. For the latest versions, see the [latest versions](https://github.com/JetBrains/compose-jb/releases) site and the [Kotlin](https://kotlinlang.org/) site. ``` plugins { kotlin("jvm") version "1.5.31" - id("org.jetbrains.compose") version "1.0.0-alpha4-build362" + id("org.jetbrains.compose") version "1.0.0-rc12" } ``` @@ -80,7 +80,7 @@ import org.jetbrains.compose.compose plugins { kotlin("jvm") version "1.5.31" - id("org.jetbrains.compose") version "1.0.0-alpha4-build362" + id("org.jetbrains.compose") version "1.0.0-rc12" } repositories { diff --git a/tutorials/Web/Getting_Started/README.md b/tutorials/Web/Getting_Started/README.md index f2ebe3d9..5b7c5f1b 100644 --- a/tutorials/Web/Getting_Started/README.md +++ b/tutorials/Web/Getting_Started/README.md @@ -43,7 +43,7 @@ pluginManagement { // Add compose gradle plugin plugins { kotlin("multiplatform") version "1.5.31" - id("org.jetbrains.compose") version "1.0.0-alpha4-build362" + id("org.jetbrains.compose") version "1.0.0-rc12" } // Add maven repositories