all: replace deprecated pointer.Rect with clip.Rect

Converted with

gofmt -w -r 'pointer.Rect(r) -> clip.Rect(r)' .
gofmt -w -r 'pointer.Ellipse(r) -> clip.Ellipse(layout.FRect(r))' .

combined with 'goimports -w .' to clean up imports.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2021-10-26 12:53:54 +02:00
parent 29cea1db49
commit 3e0b72304a
13 changed files with 41 additions and 39 deletions
+2 -2
View File
@@ -9,8 +9,8 @@ import (
"gioui.org/f32"
"gioui.org/gesture"
"gioui.org/io/key"
"gioui.org/io/pointer"
"gioui.org/layout"
"gioui.org/op/clip"
)
// Clickable represents a clickable area.
@@ -92,7 +92,7 @@ func (b *Clickable) History() []Press {
// Layout and update the button state
func (b *Clickable) Layout(gtx layout.Context) layout.Dimensions {
b.update(gtx)
defer pointer.Rect(image.Rectangle{Max: gtx.Constraints.Min}).Push(gtx.Ops).Pop()
defer clip.Rect(image.Rectangle{Max: gtx.Constraints.Min}).Push(gtx.Ops).Pop()
b.click.Add(gtx.Ops)
for len(b.history) > 0 {
c := b.history[0]
+4 -4
View File
@@ -513,14 +513,14 @@ func (e *Editor) layout(gtx layout.Context) layout.Dimensions {
X: -e.scrollOff.X,
Y: -e.scrollOff.Y,
}
clip := textPadding(e.lines)
clip.Max = clip.Max.Add(e.viewSize)
cl := textPadding(e.lines)
cl.Max = cl.Max.Add(e.viewSize)
startSel, endSel := sortPoints(e.caret.start.lineCol, e.caret.end.lineCol)
it := segmentIterator{
startSel: startSel,
endSel: endSel,
Lines: e.lines,
Clip: clip,
Clip: cl,
Alignment: e.Alignment,
Width: e.viewSize.X,
Offset: off,
@@ -547,7 +547,7 @@ func (e *Editor) layout(gtx layout.Context) layout.Dimensions {
r.Min.Y -= pointerPadding
r.Max.X += pointerPadding
r.Max.X += pointerPadding
defer pointer.Rect(r).Push(gtx.Ops).Pop()
defer clip.Rect(r).Push(gtx.Ops).Pop()
pointer.CursorNameOp{Name: pointer.CursorText}.Add(gtx.Ops)
var scrollRange image.Rectangle
+2 -2
View File
@@ -4,8 +4,8 @@ import (
"image"
"gioui.org/gesture"
"gioui.org/io/pointer"
"gioui.org/layout"
"gioui.org/op/clip"
)
type Enum struct {
@@ -43,7 +43,7 @@ func (e *Enum) Hovered() (string, bool) {
// Layout adds the event handler for key.
func (e *Enum) Layout(gtx layout.Context, key string) layout.Dimensions {
defer pointer.Rect(image.Rectangle{Max: gtx.Constraints.Min}).Push(gtx.Ops).Pop()
defer clip.Rect(image.Rectangle{Max: gtx.Constraints.Min}).Push(gtx.Ops).Pop()
if index(e.values, key) == -1 {
e.values = append(e.values, key)
+2 -1
View File
@@ -8,6 +8,7 @@ import (
"gioui.org/gesture"
"gioui.org/io/pointer"
"gioui.org/layout"
"gioui.org/op/clip"
)
// Float is for selecting a value in a range.
@@ -63,7 +64,7 @@ func (f *Float) Layout(gtx layout.Context, pointerMargin int, min, max float32)
Min: margin.Mul(-1),
Max: size.Add(margin),
}
defer pointer.Rect(rect).Push(gtx.Ops).Pop()
defer clip.Rect(rect).Push(gtx.Ops).Pop()
f.drag.Add(gtx.Ops)
return layout.Dimensions{Size: size}
+2 -2
View File
@@ -9,7 +9,6 @@ import (
"gioui.org/f32"
"gioui.org/internal/f32color"
"gioui.org/io/pointer"
"gioui.org/layout"
"gioui.org/op"
"gioui.org/op/clip"
@@ -178,7 +177,8 @@ func (b IconButtonStyle) Layout(gtx layout.Context) layout.Dimensions {
})
}),
layout.Expanded(func(gtx layout.Context) layout.Dimensions {
defer pointer.Ellipse(image.Rectangle{Max: gtx.Constraints.Min}).Push(gtx.Ops).Pop()
bounds := f32.Rectangle{Max: layout.FPt(gtx.Constraints.Min)}
defer clip.Ellipse(bounds).Push(gtx.Ops).Pop()
return b.Button.Layout(gtx)
}),
)
+2 -2
View File
@@ -5,8 +5,8 @@ package material
import (
"image"
"gioui.org/io/pointer"
"gioui.org/layout"
"gioui.org/op/clip"
"gioui.org/unit"
"gioui.org/widget"
)
@@ -35,7 +35,7 @@ func CheckBox(th *Theme, checkBox *widget.Bool, label string) CheckBoxStyle {
// Layout updates the checkBox and displays it.
func (c CheckBoxStyle) Layout(gtx layout.Context) layout.Dimensions {
dims := c.layout(gtx, c.CheckBox.Value, c.CheckBox.Hovered())
defer pointer.Rect(image.Rectangle{Max: dims.Size}).Push(gtx.Ops).Pop()
defer clip.Rect(image.Rectangle{Max: dims.Size}).Push(gtx.Ops).Pop()
gtx.Constraints.Min = dims.Size
c.CheckBox.Layout(gtx)
return dims
+2 -2
View File
@@ -155,7 +155,7 @@ func (s ScrollbarStyle) layout(gtx layout.Context, axis layout.Axis, viewportSta
area := image.Rectangle{
Max: gtx.Constraints.Min,
}
pointerArea := pointer.Rect(area)
pointerArea := clip.Rect(area)
defer pointerArea.Push(gtx.Ops).Pop()
s.Scrollbar.AddDrag(gtx.Ops)
@@ -205,7 +205,7 @@ func (s ScrollbarStyle) layout(gtx layout.Context, axis layout.Axis, viewportSta
}.Op(gtx.Ops))
// Add the indicator pointer hit area.
area := pointer.Rect(image.Rectangle{Max: indicatorDims})
area := clip.Rect(image.Rectangle{Max: indicatorDims})
defer pointer.PassOp{}.Push(gtx.Ops).Pop()
defer area.Push(gtx.Ops).Pop()
s.Scrollbar.AddIndicator(gtx.Ops)
+2 -2
View File
@@ -5,8 +5,8 @@ package material
import (
"image"
"gioui.org/io/pointer"
"gioui.org/layout"
"gioui.org/op/clip"
"gioui.org/unit"
"gioui.org/widget"
)
@@ -41,7 +41,7 @@ func RadioButton(th *Theme, group *widget.Enum, key, label string) RadioButtonSt
func (r RadioButtonStyle) Layout(gtx layout.Context) layout.Dimensions {
hovered, hovering := r.Group.Hovered()
dims := r.layout(gtx, r.Group.Value == r.Key, hovering && hovered == r.Key)
defer pointer.Rect(image.Rectangle{Max: dims.Size}).Push(gtx.Ops).Pop()
defer clip.Rect(image.Rectangle{Max: dims.Size}).Push(gtx.Ops).Pop()
gtx.Constraints.Min = dims.Size
r.Group.Layout(gtx, r.Key)
return dims
+1 -2
View File
@@ -8,7 +8,6 @@ import (
"gioui.org/f32"
"gioui.org/internal/f32color"
"gioui.org/io/pointer"
"gioui.org/layout"
"gioui.org/op"
"gioui.org/op/clip"
@@ -124,7 +123,7 @@ func (s SwitchStyle) Layout(gtx layout.Context) layout.Dimensions {
}
defer op.Offset(clickOff).Push(gtx.Ops).Pop()
sz := image.Pt(clickSize, clickSize)
defer pointer.Ellipse(image.Rectangle{Max: sz}).Push(gtx.Ops).Pop()
defer clip.Ellipse(f32.Rectangle{Max: layout.FPt(sz)}).Push(gtx.Ops).Pop()
gtx.Constraints.Min = sz
s.Switch.Layout(gtx)