Scoop API

scoop:scoop.ui.component:0.1.0

src/tree/drop_values.scoop

Selected production source · src/tree/drop_values.scoop

1package scoop.ui.component
3import scoop.ui.*
4import scoop.window.*
5import scoop.time.Duration
7public enum TreeDropPosition {
8 Before, Inside, After
9}
11/** A current logical insertion point. None for before means append, including unknown children. */
12public class TreeDrop<T> internal constructor(
13 public val source: TreeNode<T>,
14 public val target: TreeNode<T>,
15 public val position: TreeDropPosition,
16 public val parent: ViewKey?,
17 public val before: ViewKey?
20/** Tree resolves moves; the application commits data or performs its own IO in onDrop. */
21public class TreeDrag<T> public constructor(
22 public val onDrop: (TreeDrop<T>) -> Boolean,
23 public val allowDrop: (TreeDrop<T>) -> Boolean = { _ -> true },
24 public val enabled: Boolean = true,
25 public val expandDelay: Duration = Duration.milliseconds(650L),
26 public val content: (TreeNode<T>) -> DragContent = { node -> DragContent.Text(node.label) },
27 public val onStart: (TreeNode<T>, DragSourceStart) -> Unit = { _, _ -> },
28 public val onEnter: (TreeDrop<T>) -> Unit = { _ -> },
29 public val onOver: (TreeDrop<T>) -> Unit = { _ -> },
30 public val onLeave: (TreeDrop<T>) -> Unit = { _ -> },
31 public val onEnd: (TreeNode<T>, DragResult) -> Unit = { _, _ -> }
32) {
33 init {
34 requireComponent(expandDelay >= Duration.ZERO, "negative tree hover delay")
35 }
38internal class TreeDragPayload<T>(val state: TreeState<T>, val node: TreeNode<T>)