tins2020/drageable.go

25 lines
437 B
Go
Raw Normal View History

2020-05-11 01:09:01 +00:00
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
}