io/system: add ActionInputOp to register window move gesture areas

The app.Window.Perform(ActionMove) is the wrong abstraction for
initiating a move gesture: Windows needs to know the move gesture
area at pointer move, and macOS needs to know the pointer button
down event that triggers the move gesture. This change replaces
Perform(ActionMove) with a new system.ActionInputOp that marks an
area movable.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2022-06-25 19:03:50 +02:00
parent b53cdfef8d
commit 3f38e67ce0
10 changed files with 85 additions and 35 deletions
+2 -8
View File
@@ -12,7 +12,6 @@ import (
// Decorations handles the states of window decorations.
type Decorations struct {
move gesture.Drag
clicks []Clickable
resize [8]struct {
gesture.Hover
@@ -25,13 +24,8 @@ type Decorations struct {
// LayoutMove lays out the widget that makes a window movable.
func (d *Decorations) LayoutMove(gtx layout.Context, w layout.Widget) layout.Dimensions {
dims := w(gtx)
d.move.Events(gtx.Metric, gtx, gesture.Both)
st := clip.Rect{Max: dims.Size}.Push(gtx.Ops)
d.move.Add(gtx.Ops)
if d.move.Pressed() {
d.actions |= system.ActionMove
}
st.Pop()
defer clip.Rect{Max: dims.Size}.Push(gtx.Ops).Pop()
system.ActionInputOp(system.ActionMove).Add(gtx.Ops)
return dims
}