scoop:scoop.ui:0.1.0
src/interaction/drag_source_values.scoop
Selected production source · src/interaction/drag_source_values.scoop
1
package scoop.ui3
import scoop.graphics.Point4
import scoop.math.abs5
import scoop.window.*7
public class DragSourceOptions public constructor(8
public val threshold: Double = 4.0,9
public val enabled: Boolean = true,10
public val mouse: Boolean = true,11
public val contacts: Boolean = true12
) {13
init {14
requireUi(15
threshold.isFinite() && threshold >= 0.0,16
"drag threshold must be finite and nonnegative"17
)18
}19
}21
/** Local points share the accepted geometry; input snapshots retain window coordinates. */22
public struct DragSourceStart(23
val start: Point,24
val position: Point,25
val press: PointerState,26
val pointer: PointerState,27
val input: DragInput28
)30
/** The completion belongs to this prepared source, even when later renders replace prepare. */31
public struct DragSourceData(32
val content: DragContent,33
val effects: DragEffects = DragEffects(true, false, false),34
val localData: Any? = None,35
val preview: DragPreview? = None,36
val onCompleted: (DragResult) -> Unit = {}37
)39
internal fun dragSourceThreshold(40
press: PointerState,41
pointer: PointerState,42
threshold: Double43
): Boolean {44
val dx = pointer.logicalPosition.x - press.logicalPosition.x45
val dy = pointer.logicalPosition.y - press.logicalPosition.y46
return dx.isFinite() && dy.isFinite() && (abs(dx) >= threshold || abs(dy) >= threshold)47
}