|
|
|
@ -1,14 +1,13 @@
|
|
|
|
|
package org.jetbrains.compose.demo.widgets.platform |
|
|
|
|
|
|
|
|
|
import androidx.compose.runtime.* |
|
|
|
|
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.pointerMoveFilter |
|
|
|
|
import androidx.compose.ui.window.FrameWindowScope |
|
|
|
|
import java.awt.Cursor |
|
|
|
|
|
|
|
|
|
val AppFrame = staticCompositionLocalOf<FrameWindowScope> { error("Undefined repository") } |
|
|
|
|
|
|
|
|
|
actual fun Modifier.pointerMoveFilter( |
|
|
|
|
onEnter: () -> Boolean, |
|
|
|
@ -16,18 +15,11 @@ actual fun Modifier.pointerMoveFilter(
|
|
|
|
|
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) } |
|
|
|
|
|
|
|
|
|
val window = AppFrame.current.window |
|
|
|
|
window.cursor = if (isHover) { |
|
|
|
|
Cursor(Cursor.E_RESIZE_CURSOR) |
|
|
|
|
} else { |
|
|
|
|
Cursor.getDefaultCursor() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
pointerMoveFilter( |
|
|
|
|
onEnter = { isHover = true; true }, |
|
|
|
|
onExit = { isHover = false; true } |
|
|
|
|
) |
|
|
|
|
).pointerIcon(if (isHover) PointerIcon.Crosshair else PointerIcon.Default) |
|
|
|
|
} |