-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfeedback.go
More file actions
44 lines (37 loc) · 1.31 KB
/
Copy pathfeedback.go
File metadata and controls
44 lines (37 loc) · 1.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package dnd
import "github.com/gogpu/ui/geometry"
// DragVisual describes how to render drag feedback.
//
// Applications can inspect the active Session and its Feedback to render
// custom drag visuals (ghost widgets, drop indicators, etc.). This type
// provides common visual parameters that painters can use.
type DragVisual struct {
// CursorPos is the current cursor position during the drag.
CursorPos geometry.Point
// Offset is the distance from the cursor to the drag ghost's origin.
// Typically set to the offset from the original click point within
// the source widget.
Offset geometry.Point
// Effect is the current drop effect for visual feedback.
Effect DropEffect
// OverTarget is true when the cursor is over a valid drop target.
OverTarget bool
// Label is optional text to display near the cursor.
Label string
}
// NewDragVisual creates a DragVisual from an active Session.
//
// Returns a zero DragVisual if the session is nil or inactive.
func NewDragVisual(session *Session) DragVisual {
if session == nil || !session.active {
return DragVisual{}
}
offset := session.currentPos.Sub(session.startPos)
return DragVisual{
CursorPos: session.currentPos,
Offset: offset,
Effect: session.feedback.Effect,
OverTarget: session.target != nil,
Label: session.feedback.Label,
}
}