forked from AllenDang/imgui-go
-
Notifications
You must be signed in to change notification settings - Fork 1
/
DragDrop.go
61 lines (46 loc) · 1.3 KB
/
DragDrop.go
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package imgui
// #include "DragDropWrapper.h"
import "C"
import (
"unsafe"
)
type Payload uintptr
func (p Payload) handle() C.IggPayload {
return C.IggPayload(p)
}
func (p Payload) Data() int {
raw := C.iggPayloadGetData(p.handle())
return *(*int)((unsafe.Pointer)(raw))
}
func BeginDragDropSource() bool {
return BeginDragDropSourceV(0)
}
func BeginDragDropSourceV(flags int) bool {
return C.iggBeginDragDropSource(C.int(flags)) != 0
}
func SetDragDropPayload(payloadType string, data int) bool {
return SetDragDropPayloadV(payloadType, data, 0)
}
func SetDragDropPayloadV(payloadType string, data int, cond int) bool {
typeArg, typeFn := wrapString(payloadType)
defer typeFn()
return C.iggSetDragDropPayload(typeArg, unsafe.Pointer(&data), C.uint(unsafe.Sizeof(&data)), C.int(cond)) != 0
}
func EndDragDropSource() {
C.iggEndDragDropSource()
}
func BeginDragDropTarget() bool {
return C.iggBeginDragDropTarget() != 0
}
func AcceptDragDropPayload(payloadType string) Payload {
return AcceptDragDropPayloadV(payloadType, 0)
}
func AcceptDragDropPayloadV(payloadType string, flags int) Payload {
typeArg, typeFn := wrapString(payloadType)
defer typeFn()
payload := C.iggAcceptDragDropPayload(typeArg, C.int(flags))
return Payload(payload)
}
func EndDragDropTarget() {
C.iggEndDragDropTarget()
}