Nikolay Igotti
3 years ago
committed by
GitHub
2 changed files with 6 additions and 23 deletions
@ -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))) |
||||
|
Loading…
Reference in new issue