mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-07 18:35:34 +00:00
Revert "gesture: add Active methods to gestures"
This reverts commit d829e56194.
We're not using the activity of gestures to track whether widgets
should behave as disabled or enabled anymore.
This commit is contained in:
+4
-48
@@ -26,8 +26,6 @@ import (
|
|||||||
type Click struct {
|
type Click struct {
|
||||||
// state tracks the gesture state.
|
// state tracks the gesture state.
|
||||||
state ClickState
|
state ClickState
|
||||||
|
|
||||||
activity activity
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type ClickState uint8
|
type ClickState uint8
|
||||||
@@ -56,13 +54,6 @@ type Scroll struct {
|
|||||||
last int
|
last int
|
||||||
// Leftover scroll.
|
// Leftover scroll.
|
||||||
scroll float32
|
scroll float32
|
||||||
activity activity
|
|
||||||
}
|
|
||||||
|
|
||||||
// activity tracks whether events have been processed
|
|
||||||
// since the previous frame.
|
|
||||||
type activity struct {
|
|
||||||
inactive int
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type ScrollState uint8
|
type ScrollState uint8
|
||||||
@@ -107,10 +98,8 @@ var touchSlop = unit.Dp(3)
|
|||||||
|
|
||||||
// Add the handler to the operation list to receive click events.
|
// Add the handler to the operation list to receive click events.
|
||||||
func (c *Click) Add(ops *op.Ops) {
|
func (c *Click) Add(ops *op.Ops) {
|
||||||
c.activity.Frame(ops)
|
op := pointer.InputOp{Key: c}
|
||||||
if c.activity.Active() {
|
op.Add(ops)
|
||||||
pointer.InputOp{Key: c}.Add(ops)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// State reports the click state.
|
// State reports the click state.
|
||||||
@@ -118,15 +107,8 @@ func (c *Click) State() ClickState {
|
|||||||
return c.state
|
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.
|
// Events returns the next click event, if any.
|
||||||
func (c *Click) Events(q event.Queue) []ClickEvent {
|
func (c *Click) Events(q event.Queue) []ClickEvent {
|
||||||
c.activity.Reset()
|
|
||||||
var events []ClickEvent
|
var events []ClickEvent
|
||||||
for _, evt := range q.Events(c) {
|
for _, evt := range q.Events(c) {
|
||||||
e, ok := evt.(pointer.Event)
|
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.
|
// Add the handler to the operation list to receive scroll events.
|
||||||
func (s *Scroll) Add(ops *op.Ops) {
|
func (s *Scroll) Add(ops *op.Ops) {
|
||||||
s.activity.Frame(ops)
|
oph := pointer.InputOp{Key: s, Grab: s.grab}
|
||||||
if !s.activity.Active() {
|
oph.Add(ops)
|
||||||
return
|
|
||||||
}
|
|
||||||
pointer.InputOp{Key: s, Grab: s.grab}.Add(ops)
|
|
||||||
if s.flinger.Active() {
|
if s.flinger.Active() {
|
||||||
op.InvalidateOp{}.Add(ops)
|
op.InvalidateOp{}.Add(ops)
|
||||||
}
|
}
|
||||||
@@ -176,16 +155,9 @@ func (s *Scroll) Stop() {
|
|||||||
s.flinger = fling.Animation{}
|
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
|
// Scroll detects the scrolling distance from the available events and
|
||||||
// ongoing fling gestures.
|
// ongoing fling gestures.
|
||||||
func (s *Scroll) Scroll(cfg unit.Converter, q event.Queue, t time.Time, axis Axis) int {
|
func (s *Scroll) Scroll(cfg unit.Converter, q event.Queue, t time.Time, axis Axis) int {
|
||||||
s.activity.Reset()
|
|
||||||
if s.axis != axis {
|
if s.axis != axis {
|
||||||
s.axis = axis
|
s.axis = axis
|
||||||
return 0
|
return 0
|
||||||
@@ -321,19 +293,3 @@ func (s ScrollState) String() string {
|
|||||||
panic("unreachable")
|
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
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user