~eliasnaur/gio-patches

giouiorg: include/files/architecture: bump gio v1 PROPOSED

~egonelbre
~egonelbre: 1
 include/files/architecture: bump gio

 7 files changed, 59 insertions(+), 39 deletions(-)
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~eliasnaur/gio-patches/patches/15330/mbox | git am -3
Learn more about email & git
View this thread in the archives

[PATCH giouiorg] include/files/architecture: bump gio Export this patch

~egonelbre
From: Egon Elbre <egonelbre@gmail.com>

There have been significant changes to the API, update to the latest version.

Signed-off-by: Egon Elbre <egonelbre@gmail.com>
---
 go.mod                                     |  2 +-
 go.sum                                     |  2 +
 include/files/architecture/button.go       | 29 ++++++++-------
 include/files/architecture/colorbox.go     | 18 +++++----
 include/files/architecture/draw.go         | 43 +++++++++++++++-------
 include/files/architecture/layout.go       |  2 +-
 include/files/architecture/split-visual.go |  2 +-
 7 files changed, 59 insertions(+), 39 deletions(-)

diff --git a/go.mod b/go.mod
index f70b974..d98b624 100644
--- a/go.mod
+++ b/go.mod
@@ -3,7 +3,7 @@ module gioui.org/website
go 1.14

require (
	gioui.org v0.0.0-20200809161702-a063febed977
	gioui.org v0.0.0-20201126101740-9b54892cc4e3
	gioui.org/cmd v0.0.0-20200622185735-5bd0ecea5e43
	gioui.org/example v0.0.0-20200809161702-a063febed977
	github.com/gomarkdown/markdown v0.0.0-20190912180731-281270bc6d83
diff --git a/go.sum b/go.sum
index 079ccec..fa3400b 100644
--- a/go.sum
+++ b/go.sum
@@ -4,6 +4,8 @@ gioui.org v0.0.0-20200622101735-5368743478e0/go.mod h1:jiUwifN9cRl/zmco43aAqh0aV
gioui.org v0.0.0-20200726090130-3b95e2918359/go.mod h1:jiUwifN9cRl/zmco43aAqh0aV+s9GbhG13KcD+gEpkU=
gioui.org v0.0.0-20200809161702-a063febed977 h1:uE7dUtCS7ig7ny1gaZPz8Y7S6q4x4HjjTnvvKE5AEI8=
gioui.org v0.0.0-20200809161702-a063febed977/go.mod h1:jiUwifN9cRl/zmco43aAqh0aV+s9GbhG13KcD+gEpkU=
gioui.org v0.0.0-20201126101740-9b54892cc4e3 h1:il7mOn2cEYfnu0oV+mgqZCtNAB3PTtpuohx14ZA2bM8=
gioui.org v0.0.0-20201126101740-9b54892cc4e3/go.mod h1:Y+uS7hHMvku1Q+ooaoq6fYD5B2LGoT8JtFgvmYmRzTw=
gioui.org/cmd v0.0.0-20200622185735-5bd0ecea5e43 h1:Wj8OoCIw06dNSSSPAAipnmcG7dbFn+7Et9IY37e1HBU=
gioui.org/cmd v0.0.0-20200622185735-5bd0ecea5e43/go.mod h1:KrsGUGWoPetiRyuDmOd/GTNCBFi2u4UbESTFXZ5YqXY=
gioui.org/example v0.0.0-20200809161702-a063febed977 h1:89Tr+NjHVQXQOXMipo2p25AROFyAg/Icscg6v3+ByMY=
diff --git a/include/files/architecture/button.go b/include/files/architecture/button.go
index b9b5a40..41abe54 100644
--- a/include/files/architecture/button.go
+++ b/include/files/architecture/button.go
@@ -6,11 +6,11 @@ import (
	"image"
	"image/color"

	"gioui.org/f32"
	"gioui.org/io/event"
	"gioui.org/io/pointer"
	"gioui.org/layout"
	"gioui.org/op"
	"gioui.org/op/clip"
	"gioui.org/op/paint"
)

@@ -20,8 +20,7 @@ var pressed = false

func doButton(ops *op.Ops, q event.Queue) {
	// Make sure we don���t pollute the graphics context.
	stack := op.Push(ops)
	defer stack.Pop()
	defer op.Push(ops).Pop()

	// Process events that arrived between the last frame and this one.
	for _, ev := range q.Events(tag) {
@@ -43,14 +42,15 @@ func doButton(ops *op.Ops, q event.Queue) {
		Types: pointer.Press | pointer.Release,
	}.Add(ops)

	var c color.RGBA
	clip.Rect{Max: image.Pt(100, 100)}.Add(ops)
	var c color.NRGBA
	if pressed {
		c = color.RGBA{R: 0xFF, A: 0xFF}
		c = color.NRGBA{R: 0xFF, A: 0xFF}
	} else {
		c = color.RGBA{G: 0xFF, A: 0xFF}
		c = color.NRGBA{G: 0xFF, A: 0xFF}
	}
	paint.ColorOp{Color: c}.Add(ops)
	paint.PaintOp{Rect: f32.Rect(0, 0, 100, 100)}.Add(ops)
	paint.PaintOp{}.Add(ops)
}

// END LOWLEVEL OMIT
@@ -67,17 +67,18 @@ type ButtonVisual struct {
}

func (b *ButtonVisual) Layout(gtx layout.Context) layout.Dimensions {
	col := color.RGBA{R: 0x80, A: 0xFF}
	col := color.NRGBA{R: 0x80, A: 0xFF}
	if b.pressed {
		col = color.RGBA{G: 0x80, A: 0xFF}
		col = color.NRGBA{G: 0x80, A: 0xFF}
	}
	return drawSquare(gtx.Ops, col)
}

func drawSquare(ops *op.Ops, color color.RGBA) layout.Dimensions {
	square := f32.Rect(0, 0, 100, 100)
func drawSquare(ops *op.Ops, color color.NRGBA) layout.Dimensions {
	defer op.Push(ops).Pop()
	clip.Rect{Max: image.Pt(100, 100)}.Add(ops)
	paint.ColorOp{Color: color}.Add(ops)
	paint.PaintOp{Rect: square}.Add(ops)
	paint.PaintOp{}.Add(ops)
	return layout.Dimensions{Size: image.Pt(100, 100)}
}

@@ -118,9 +119,9 @@ func (b *Button) Layout(gtx layout.Context) layout.Dimensions {
	}.Add(gtx.Ops)

	// Draw the button.
	col := color.RGBA{R: 0x80, A: 0xFF}
	col := color.NRGBA{R: 0x80, A: 0xFF}
	if b.pressed {
		col = color.RGBA{G: 0x80, A: 0xFF}
		col = color.NRGBA{G: 0x80, A: 0xFF}
	}
	return drawSquare(gtx.Ops, col)
}
diff --git a/include/files/architecture/colorbox.go b/include/files/architecture/colorbox.go
index 8111c7e..5f3de36 100644
--- a/include/files/architecture/colorbox.go
+++ b/include/files/architecture/colorbox.go
@@ -6,8 +6,9 @@ import (
	"image"
	"image/color"

	"gioui.org/f32"
	"gioui.org/layout"
	"gioui.org/op"
	"gioui.org/op/clip"
	"gioui.org/op/paint"
)

@@ -15,17 +16,18 @@ import (

// Test colors.
var (
	background = color.RGBA{R: 0xC0, G: 0xC0, B: 0xC0, A: 0xFF}
	red        = color.RGBA{R: 0xC0, G: 0x40, B: 0x40, A: 0xFF}
	green      = color.RGBA{R: 0x40, G: 0xC0, B: 0x40, A: 0xFF}
	blue       = color.RGBA{R: 0x40, G: 0x40, B: 0xC0, A: 0xFF}
	background = color.NRGBA{R: 0xC0, G: 0xC0, B: 0xC0, A: 0xFF}
	red        = color.NRGBA{R: 0xC0, G: 0x40, B: 0x40, A: 0xFF}
	green      = color.NRGBA{R: 0x40, G: 0xC0, B: 0x40, A: 0xFF}
	blue       = color.NRGBA{R: 0x40, G: 0x40, B: 0xC0, A: 0xFF}
)

// ColorBox creates a widget with the specified dimensions and color.
func ColorBox(gtx layout.Context, size image.Point, color color.RGBA) layout.Dimensions {
	bounds := f32.Rect(0, 0, float32(size.X), float32(size.Y))
func ColorBox(gtx layout.Context, size image.Point, color color.NRGBA) layout.Dimensions {
	defer op.Push(gtx.Ops).Pop()
	clip.Rect{Max: size}.Add(gtx.Ops)
	paint.ColorOp{Color: color}.Add(gtx.Ops)
	paint.PaintOp{Rect: bounds}.Add(gtx.Ops)
	paint.PaintOp{}.Add(gtx.Ops)
	return layout.Dimensions{Size: size}
}

diff --git a/include/files/architecture/draw.go b/include/files/architecture/draw.go
index d7c0ce6..a724073 100644
--- a/include/files/architecture/draw.go
+++ b/include/files/architecture/draw.go
@@ -18,7 +18,7 @@ import (

// START OPERATIONS OMIT
func addColorOperation(ops *op.Ops) {
	red := color.RGBA{R: 0xFF, A: 0xFF}
	red := color.NRGBA{R: 0xFF, A: 0xFF}
	paint.ColorOp{Color: red}.Add(ops)
}

@@ -26,8 +26,9 @@ func addColorOperation(ops *op.Ops) {

// START DRAWING OMIT
func drawRedRect(ops *op.Ops) {
	paint.ColorOp{Color: color.RGBA{R: 0x80, A: 0xFF}}.Add(ops)
	paint.PaintOp{Rect: f32.Rect(0, 0, 100, 100)}.Add(ops)
	clip.Rect{Max: image.Pt(100, 100)}.Add(ops)
	paint.ColorOp{Color: color.NRGBA{R: 0x80, A: 0xFF}}.Add(ops)
	paint.PaintOp{}.Add(ops)
}

// END DRAWING OMIT
@@ -58,7 +59,7 @@ func redTriangle(ops *op.Ops) {
	path.Quad(f32.Pt(0, 90), f32.Pt(50, 100))
	path.Line(f32.Pt(-100, 0))
	path.Line(f32.Pt(50, -100))
	path.End().Add(ops)
	path.Outline().Add(ops)
	drawRedRect(ops)
}

@@ -79,12 +80,18 @@ func redButtonBackgroundStack(ops *op.Ops) {
// START DRAWORDER OMIT
func drawOverlappingRectangles(ops *op.Ops) {
	// Draw a red rectangle.
	paint.ColorOp{Color: color.RGBA{R: 0x80, A: 0xFF}}.Add(ops)
	paint.PaintOp{Rect: f32.Rect(0, 0, 100, 50)}.Add(ops)
	stack := op.Push(ops)
	clip.Rect{Max: image.Pt(100, 50)}.Add(ops)
	paint.ColorOp{Color: color.NRGBA{R: 0x80, A: 0xFF}}.Add(ops)
	paint.PaintOp{}.Add(ops)
	stack.Pop()

	// Draw a green rectangle.
	paint.ColorOp{Color: color.RGBA{G: 0x80, A: 0xFF}}.Add(ops)
	paint.PaintOp{Rect: f32.Rect(0, 0, 50, 100)}.Add(ops)
	stack = op.Push(ops)
	clip.Rect{Max: image.Pt(50, 100)}.Add(ops)
	paint.ColorOp{Color: color.NRGBA{G: 0x80, A: 0xFF}}.Add(ops)
	paint.PaintOp{}.Add(ops)
	stack.Pop()
}

// END DRAWORDER OMIT
@@ -126,9 +133,12 @@ func drawProgressBar(ops *op.Ops, now time.Time) {
		progress = 1
	}

	paint.ColorOp{Color: color.RGBA{G: 0x80, A: 0xFF}}.Add(ops)
	defer op.Push(ops).Pop()
	width := 200 * float32(progress)
	paint.PaintOp{Rect: f32.Rect(0, 0, width, 20)}.Add(ops)
	clip.Rect{Max: image.Pt(int(width), 20)}.Add(ops)
	paint.ColorOp{Color: color.NRGBA{R: 0x80, A: 0xFF}}.Add(ops)
	paint.ColorOp{Color: color.NRGBA{G: 0x80, A: 0xFF}}.Add(ops)
	paint.PaintOp{}.Add(ops)
}

// END ANIMATION OMIT
@@ -138,8 +148,12 @@ func drawWithCache(ops *op.Ops) {
	// Save the operations in an independent ops value (the cache).
	cache := new(op.Ops)
	macro := op.Record(cache)
	paint.ColorOp{Color: color.RGBA{G: 0x80, A: 0xFF}}.Add(cache)
	paint.PaintOp{Rect: f32.Rect(0, 0, 100, 100)}.Add(cache)

	stack := op.Push(cache)
	clip.Rect{Max: image.Pt(100, 100)}.Add(cache)
	paint.ColorOp{Color: color.NRGBA{G: 0x80, A: 0xFF}}.Add(cache)
	paint.PaintOp{}.Add(cache)
	stack.Pop()
	call := macro.Stop()

	// Draw the operations from the cache.
@@ -166,7 +180,7 @@ func drawImageInternal(ops *op.Ops) {
		var err error
		exampleImage, err = createExampleImage()
		if err != nil {
			exampleImage = image.NewUniform(color.RGBA{R: 0xFF, A: 0xFF})
			exampleImage = image.NewUniform(color.NRGBA{R: 0xFF, A: 0xFF})
		}
	}
	drawImage(ops, exampleImage)
@@ -176,7 +190,8 @@ func drawImageInternal(ops *op.Ops) {
func drawImage(ops *op.Ops, img image.Image) {
	imageOp := paint.NewImageOp(img)
	imageOp.Add(ops)
	paint.PaintOp{Rect: f32.Rect(0, 0, 100, 100)}.Add(ops)
	op.Affine(f32.Affine2D{}.Scale(f32.Pt(0, 0), f32.Pt(4, 4)))
	paint.PaintOp{}.Add(ops)
}

// END IMAGE OMIT
diff --git a/include/files/architecture/layout.go b/include/files/architecture/layout.go
index ef3424a..0a27a32 100644
--- a/include/files/architecture/layout.go
+++ b/include/files/architecture/layout.go
@@ -44,7 +44,7 @@ var list = layout.List{}

func listing(gtx layout.Context) layout.Dimensions {
	return list.Layout(gtx, 100, func(gtx layout.Context, i int) layout.Dimensions {
		col := color.RGBA{R: byte(i * 20), G: 0x20, B: 0x20, A: 0xFF}
		col := color.NRGBA{R: byte(i * 20), G: 0x20, B: 0x20, A: 0xFF}
		return ColorBox(gtx, image.Pt(20, 100), col)
	})
}
diff --git a/include/files/architecture/split-visual.go b/include/files/architecture/split-visual.go
index b7f88e9..4ca7086 100644
--- a/include/files/architecture/split-visual.go
+++ b/include/files/architecture/split-visual.go
@@ -19,7 +19,7 @@ func exampleSplitVisual(gtx layout.Context, th *material.Theme) layout.Dimension
	})
}

func FillWithLabel(gtx layout.Context, th *material.Theme, text string, backgroundColor color.RGBA) layout.Dimensions {
func FillWithLabel(gtx layout.Context, th *material.Theme, text string, backgroundColor color.NRGBA) layout.Dimensions {
	ColorBox(gtx, gtx.Constraints.Max, backgroundColor)
	return layout.Center.Layout(gtx, material.H3(th, text).Layout)
}
-- 
2.26.2
Thank you, applied. I bumped gioui.org/example to fix kitchen build,
and gioui.org/cmd while I was at it.