DragDrop.go 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. package imgui
  2. // #include "DragDropWrapper.h"
  3. import "C"
  4. import (
  5. "unsafe"
  6. )
  7. type Payload uintptr
  8. func (p Payload) handle() C.IggPayload {
  9. return C.IggPayload(p)
  10. }
  11. func (p Payload) Data() int {
  12. raw := C.iggPayloadGetData(p.handle())
  13. return *(*int)((unsafe.Pointer)(raw))
  14. }
  15. func BeginDragDropSource() bool {
  16. return BeginDragDropSourceV(0)
  17. }
  18. func BeginDragDropSourceV(flags int) bool {
  19. return C.iggBeginDragDropSource(C.int(flags)) != 0
  20. }
  21. func SetDragDropPayload(payloadType string, data int) bool {
  22. return SetDragDropPayloadV(payloadType, data, 0)
  23. }
  24. func SetDragDropPayloadV(payloadType string, data int, cond int) bool {
  25. typeArg, typeFn := wrapString(payloadType)
  26. defer typeFn()
  27. return C.iggSetDragDropPayload(typeArg, unsafe.Pointer(&data), C.uint(unsafe.Sizeof(&data)), C.int(cond)) != 0
  28. }
  29. func EndDragDropSource() {
  30. C.iggEndDragDropSource()
  31. }
  32. func BeginDragDropTarget() bool {
  33. return C.iggBeginDragDropTarget() != 0
  34. }
  35. func AcceptDragDropPayload(payloadType string) Payload {
  36. return AcceptDragDropPayloadV(payloadType, 0)
  37. }
  38. func AcceptDragDropPayloadV(payloadType string, flags int) Payload {
  39. typeArg, typeFn := wrapString(payloadType)
  40. defer typeFn()
  41. payload := C.iggAcceptDragDropPayload(typeArg, C.int(flags))
  42. return Payload(payload)
  43. }
  44. func EndDragDropTarget() {
  45. C.iggEndDragDropTarget()
  46. }