25 lines
437 B
Go
25 lines
437 B
Go
|
package tins2020
|
||
|
|
||
|
type Drageable struct {
|
||
|
start *Point
|
||
|
dragged bool
|
||
|
}
|
||
|
|
||
|
func (d *Drageable) Cancel() { d.start = nil }
|
||
|
|
||
|
func (d *Drageable) IsDragging() bool { return d.start != nil }
|
||
|
|
||
|
func (d *Drageable) HasDragged() bool { return d.dragged }
|
||
|
|
||
|
func (d *Drageable) Move(p Point) Point {
|
||
|
delta := p.Sub(*d.start)
|
||
|
d.start = &p
|
||
|
d.dragged = true
|
||
|
return delta
|
||
|
}
|
||
|
|
||
|
func (d *Drageable) Start(p Point) {
|
||
|
d.start = &p
|
||
|
d.dragged = false
|
||
|
}
|