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