2021-06-04 15:17:22 +00:00
|
|
|
package ui
|
|
|
|
|
|
|
|
import "opslag.de/schobers/geom"
|
|
|
|
|
|
|
|
type DragDropEventTarget interface {
|
|
|
|
DragEnter(geom.PointF32, []string)
|
|
|
|
DragMove(geom.PointF32)
|
|
|
|
DragLeave()
|
|
|
|
Drop(geom.PointF32, []string)
|
|
|
|
}
|
|
|
|
|
|
|
|
type DragDropProvider interface {
|
|
|
|
Register(windowHandle uintptr, target DragDropEventTarget)
|
|
|
|
}
|
|
|
|
|
|
|
|
var DefaultDragDropProvider DragDropProvider = nil
|
|
|
|
|
|
|
|
type dragDropEventTarget struct {
|
|
|
|
renderer Renderer
|
|
|
|
events []Event
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *dragDropEventTarget) eventBase() EventBase {
|
|
|
|
return EventBase{StampInSeconds: t.renderer.Stamp()}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *dragDropEventTarget) pushEvent(e Event) {
|
|
|
|
t.events = append(t.events, e)
|
|
|
|
t.renderer.Refresh()
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *dragDropEventTarget) DragEnter(pos geom.PointF32, files []string) {
|
|
|
|
t.pushEvent(&DisplayDragEnterEvent{EventBase: t.eventBase(), X: pos.X, Y: pos.Y, Files: files})
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *dragDropEventTarget) DragMove(pos geom.PointF32) {
|
2021-06-07 05:48:24 +00:00
|
|
|
t.pushEvent(&DisplayDragMoveEvent{EventBase: t.eventBase(), X: pos.X, Y: pos.Y})
|
2021-06-04 15:17:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (t *dragDropEventTarget) DragLeave() {
|
|
|
|
t.pushEvent(&DisplayDragLeaveEvent{EventBase: t.eventBase()})
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *dragDropEventTarget) Drop(pos geom.PointF32, files []string) {
|
|
|
|
t.pushEvent(&DisplayDropEvent{EventBase: t.eventBase(), X: pos.X, Y: pos.Y, Files: files})
|
|
|
|
}
|