From 8002705c9e851c748f8f50a6def68934c852a81c Mon Sep 17 00:00:00 2001 From: Nikolay Igotti Date: Fri, 22 Oct 2021 11:46:55 +0300 Subject: [PATCH] Update codeviewer example (#1292) --- examples/codeviewer/build.gradle.kts | 2 +- .../jetbrains/codeviewer/platform/Mouse.kt | 27 ++++--------------- 2 files changed, 6 insertions(+), 23 deletions(-) diff --git a/examples/codeviewer/build.gradle.kts b/examples/codeviewer/build.gradle.kts index ca87402368..dd1959d8d2 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-alpha4-build361") + classpath("org.jetbrains.compose:compose-gradle-plugin:0.0.0-master-build423") classpath("com.android.tools.build:gradle:4.0.1") // __KOTLIN_COMPOSE_VERSION__ classpath(kotlin("gradle-plugin", version = "1.5.31")) diff --git a/examples/codeviewer/common/src/desktopMain/kotlin/org/jetbrains/codeviewer/platform/Mouse.kt b/examples/codeviewer/common/src/desktopMain/kotlin/org/jetbrains/codeviewer/platform/Mouse.kt index fbd688bcae..2fb7d7887c 100644 --- a/examples/codeviewer/common/src/desktopMain/kotlin/org/jetbrains/codeviewer/platform/Mouse.kt +++ b/examples/codeviewer/common/src/desktopMain/kotlin/org/jetbrains/codeviewer/platform/Mouse.kt @@ -1,38 +1,21 @@ package org.jetbrains.codeviewer.platform -import androidx.compose.runtime.getValue -import androidx.compose.runtime.mutableStateOf -import androidx.compose.runtime.remember -import androidx.compose.runtime.setValue import androidx.compose.ui.ExperimentalComposeUiApi import androidx.compose.ui.Modifier -import androidx.compose.ui.composed import androidx.compose.ui.geometry.Offset import androidx.compose.ui.input.pointer.PointerIcon -import androidx.compose.ui.input.pointer.pointerIcon +import androidx.compose.ui.input.pointer.pointerHoverIcon import androidx.compose.ui.input.pointer.pointerMoveFilter import java.awt.Cursor +@OptIn(ExperimentalComposeUiApi::class) actual fun Modifier.pointerMoveFilter( onEnter: () -> Boolean, onExit: () -> Boolean, onMove: (Offset) -> Boolean ): Modifier = this.pointerMoveFilter(onEnter = onEnter, onExit = onExit, onMove = onMove) -@OptIn(ExperimentalComposeUiApi::class) -actual fun Modifier.cursorForHorizontalResize(): Modifier = composed { - var isHover by remember { mutableStateOf(false) } - pointerMoveFilter( - onEnter = { isHover = true; true }, - onExit = { isHover = false; true } - ).pointerIcon( - PointerIcon( - if (isHover) { - Cursor(Cursor.E_RESIZE_CURSOR) - } else { - Cursor.getDefaultCursor() - } - ) - ) -} +@OptIn(ExperimentalComposeUiApi::class) +actual fun Modifier.cursorForHorizontalResize(): Modifier = + this.pointerHoverIcon(PointerIcon(Cursor(Cursor.E_RESIZE_CURSOR)))