{gesture,widget}: expose Dragging

Knowing whether a widget is being interacted with allows to implement
bi-directional updates without feedbacks.

Signed-off-by: Egon Elbre <egonelbre@gmail.com>
This commit is contained in:
Egon Elbre
2020-12-11 11:54:18 +02:00
committed by Elias Naur
parent b79c2dec79
commit 0b2a2d6c2e
2 changed files with 6 additions and 0 deletions
+3
View File
@@ -368,6 +368,9 @@ func (d *Drag) Events(cfg unit.Metric, q event.Queue, axis Axis) []pointer.Event
return events
}
// Dragging reports whether it's currently in use.
func (d *Drag) Dragging() bool { return d.dragging }
func (a Axis) String() string {
switch a {
case Horizontal:
+3
View File
@@ -21,6 +21,9 @@ type Float struct {
changed bool
}
// Dragging returns whether the value is being interacted with.
func (f *Float) Dragging() bool { return f.drag.Dragging() }
// Layout processes events.
func (f *Float) Layout(gtx layout.Context, pointerMargin int, min, max float32) layout.Dimensions {
size := gtx.Constraints.Min