From 2a9361db65c08c7c1421d7c0dd56115350ec679e Mon Sep 17 00:00:00 2001 From: Elias Naur Date: Sat, 2 Nov 2019 12:30:49 +0100 Subject: [PATCH] Revert "gesture: add Active methods to gestures" This reverts commit d829e56194a95427aedc4c6d2c89b0f3fe131aca. We're not using the activity of gestures to track whether widgets should behave as disabled or enabled anymore. --- gesture/gesture.go | 54 +++++----------------------------------------- 1 file changed, 5 insertions(+), 49 deletions(-) diff --git a/gesture/gesture.go b/gesture/gesture.go index 2427ac5b..9449825d 100644 --- a/gesture/gesture.go +++ b/gesture/gesture.go @@ -26,8 +26,6 @@ import ( type Click struct { // state tracks the gesture state. state ClickState - - activity activity } type ClickState uint8 @@ -55,14 +53,7 @@ type Scroll struct { grab bool last int // Leftover scroll. - scroll float32 - activity activity -} - -// activity tracks whether events have been processed -// since the previous frame. -type activity struct { - inactive int + scroll float32 } type ScrollState uint8 @@ -107,10 +98,8 @@ var touchSlop = unit.Dp(3) // Add the handler to the operation list to receive click events. func (c *Click) Add(ops *op.Ops) { - c.activity.Frame(ops) - if c.activity.Active() { - pointer.InputOp{Key: c}.Add(ops) - } + op := pointer.InputOp{Key: c} + op.Add(ops) } // State reports the click state. @@ -118,15 +107,8 @@ func (c *Click) State() ClickState { return c.state } -// Active reports whether Events has been called since the previous -// Add. -func (c *Click) Active() bool { - return c.activity.Active() -} - // Events returns the next click event, if any. func (c *Click) Events(q event.Queue) []ClickEvent { - c.activity.Reset() var events []ClickEvent for _, evt := range q.Events(c) { e, ok := evt.(pointer.Event) @@ -161,11 +143,8 @@ func (c *Click) Events(q event.Queue) []ClickEvent { // Add the handler to the operation list to receive scroll events. func (s *Scroll) Add(ops *op.Ops) { - s.activity.Frame(ops) - if !s.activity.Active() { - return - } - pointer.InputOp{Key: s, Grab: s.grab}.Add(ops) + oph := pointer.InputOp{Key: s, Grab: s.grab} + oph.Add(ops) if s.flinger.Active() { op.InvalidateOp{}.Add(ops) } @@ -176,16 +155,9 @@ func (s *Scroll) Stop() { s.flinger = fling.Animation{} } -// Active reports whether Events has been called since the previous -// Add. -func (s *Scroll) Active() bool { - return s.activity.Active() -} - // Scroll detects the scrolling distance from the available events and // ongoing fling gestures. func (s *Scroll) Scroll(cfg unit.Converter, q event.Queue, t time.Time, axis Axis) int { - s.activity.Reset() if s.axis != axis { s.axis = axis return 0 @@ -321,19 +293,3 @@ func (s ScrollState) String() string { panic("unreachable") } } - -func (a *activity) Frame(ops *op.Ops) { - wasActive := a.Active() - a.inactive++ - if a.Active() != wasActive { - op.InvalidateOp{}.Add(ops) - } -} - -func (a *activity) Active() bool { - return a.inactive <= 1 -} - -func (a *activity) Reset() { - a.inactive = 0 -}