Browse Source

Update codeviewer example (#1292)

pull/1296/head
Nikolay Igotti 3 years ago committed by GitHub
parent
commit
8002705c9e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      examples/codeviewer/build.gradle.kts
  2. 27
      examples/codeviewer/common/src/desktopMain/kotlin/org/jetbrains/codeviewer/platform/Mouse.kt

2
examples/codeviewer/build.gradle.kts

@ -8,7 +8,7 @@ buildscript {
dependencies { dependencies {
// __LATEST_COMPOSE_RELEASE_VERSION__ // __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") classpath("com.android.tools.build:gradle:4.0.1")
// __KOTLIN_COMPOSE_VERSION__ // __KOTLIN_COMPOSE_VERSION__
classpath(kotlin("gradle-plugin", version = "1.5.31")) classpath(kotlin("gradle-plugin", version = "1.5.31"))

27
examples/codeviewer/common/src/desktopMain/kotlin/org/jetbrains/codeviewer/platform/Mouse.kt

@ -1,38 +1,21 @@
package org.jetbrains.codeviewer.platform 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.ExperimentalComposeUiApi
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.compose.ui.composed
import androidx.compose.ui.geometry.Offset 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.pointerIcon import androidx.compose.ui.input.pointer.pointerHoverIcon
import androidx.compose.ui.input.pointer.pointerMoveFilter import androidx.compose.ui.input.pointer.pointerMoveFilter
import java.awt.Cursor import java.awt.Cursor
@OptIn(ExperimentalComposeUiApi::class)
actual fun Modifier.pointerMoveFilter( actual fun Modifier.pointerMoveFilter(
onEnter: () -> Boolean, onEnter: () -> Boolean,
onExit: () -> Boolean, onExit: () -> Boolean,
onMove: (Offset) -> Boolean onMove: (Offset) -> Boolean
): Modifier = this.pointerMoveFilter(onEnter = onEnter, onExit = onExit, onMove = onMove) ): 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( @OptIn(ExperimentalComposeUiApi::class)
onEnter = { isHover = true; true }, actual fun Modifier.cursorForHorizontalResize(): Modifier =
onExit = { isHover = false; true } this.pointerHoverIcon(PointerIcon(Cursor(Cursor.E_RESIZE_CURSOR)))
).pointerIcon(
PointerIcon(
if (isHover) {
Cursor(Cursor.E_RESIZE_CURSOR)
} else {
Cursor.getDefaultCursor()
}
)
)
}

Loading…
Cancel
Save