mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-06 18:05:35 +00:00
gesture: add the Pressed method to Drag
Signed-off-by: Pierre Curto <pierre.curto@gmail.com>
This commit is contained in:
@@ -62,6 +62,7 @@ type ClickType uint8
|
|||||||
// Drag detects drag gestures in the form of pointer.Drag events.
|
// Drag detects drag gestures in the form of pointer.Drag events.
|
||||||
type Drag struct {
|
type Drag struct {
|
||||||
dragging bool
|
dragging bool
|
||||||
|
pressed bool
|
||||||
pid pointer.ID
|
pid pointer.ID
|
||||||
start f32.Point
|
start f32.Point
|
||||||
grab bool
|
grab bool
|
||||||
@@ -339,6 +340,7 @@ func (d *Drag) Events(cfg unit.Metric, q event.Queue, axis Axis) []pointer.Event
|
|||||||
if !(e.Buttons == pointer.ButtonPrimary || e.Source == pointer.Touch) {
|
if !(e.Buttons == pointer.ButtonPrimary || e.Source == pointer.Touch) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
d.pressed = true
|
||||||
if d.dragging {
|
if d.dragging {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@@ -365,6 +367,7 @@ func (d *Drag) Events(cfg unit.Metric, q event.Queue, axis Axis) []pointer.Event
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
case pointer.Release, pointer.Cancel:
|
case pointer.Release, pointer.Cancel:
|
||||||
|
d.pressed = false
|
||||||
if !d.dragging || e.PointerID != d.pid {
|
if !d.dragging || e.PointerID != d.pid {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@@ -381,6 +384,9 @@ func (d *Drag) Events(cfg unit.Metric, q event.Queue, axis Axis) []pointer.Event
|
|||||||
// Dragging reports whether it is currently in use.
|
// Dragging reports whether it is currently in use.
|
||||||
func (d *Drag) Dragging() bool { return d.dragging }
|
func (d *Drag) Dragging() bool { return d.dragging }
|
||||||
|
|
||||||
|
// Pressed returns whether a pointer is pressing.
|
||||||
|
func (d *Drag) Pressed() bool { return d.pressed }
|
||||||
|
|
||||||
func (a Axis) String() string {
|
func (a Axis) String() string {
|
||||||
switch a {
|
switch a {
|
||||||
case Horizontal:
|
case Horizontal:
|
||||||
|
|||||||
Reference in New Issue
Block a user