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 |
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…
Reference in new issue