Noah Petherbridge
a316bafb12
Move all Doodle source code into the src/ subpackage and move the publicly shareable stuff into lib/, for example lib/ui and lib/render. This cleans up the git root and helps make the Doodle UI library more easily publishable as a separate open source project. Currently both lib/ui and lib/render import one or two things from doodle/src that need to be broken apart.
29 lines
617 B
Go
29 lines
617 B
Go
package ui
|
|
|
|
// DragDrop is a state machine to manage draggable UI components.
|
|
type DragDrop struct {
|
|
isDragging bool
|
|
}
|
|
|
|
// NewDragDrop initializes the DragDrop struct. Normally your Supervisor
|
|
// will manage the drag/drop object, but you can use your own if you don't
|
|
// use a Supervisor.
|
|
func NewDragDrop() *DragDrop {
|
|
return &DragDrop{}
|
|
}
|
|
|
|
// IsDragging returns whether the drag state is active.
|
|
func (dd *DragDrop) IsDragging() bool {
|
|
return dd.isDragging
|
|
}
|
|
|
|
// Start the drag state.
|
|
func (dd *DragDrop) Start() {
|
|
dd.isDragging = true
|
|
}
|
|
|
|
// Stop dragging.
|
|
func (dd *DragDrop) Stop() {
|
|
dd.isDragging = false
|
|
}
|