~eliasnaur/giouiorg

6f814a1a57e8942eb02c0d09438e8b7d62d543da — Chris Waldon 4 months ago 84212b4
include/files/architecture: simplify button example

The button example was updated to use two overlapping clip.AreaOps
when we converted pointer.AreaOp to be a clip.AreaOp. This wasn't
necessary, since a single clip.AreaOp can now both capture the drawing
and input area.

Signed-off-by: Chris Waldon <christopher.waldon.dev@gmail.com>
1 files changed, 2 insertions(+), 3 deletions(-)

M include/files/architecture/button.go
M include/files/architecture/button.go => include/files/architecture/button.go +2 -3
@@ 32,15 32,14 @@ func doButton(ops *op.Ops, q event.Queue) {
	}

	// Confine the area of interest to a 100x100 rectangle.
	area := clip.Rect(image.Rect(0, 0, 100, 100)).Push(ops)
	defer clip.Rect{Max: image.Pt(100, 100)}.Push(ops).Pop()

	// Declare the tag.
	pointer.InputOp{
		Tag:   tag,
		Types: pointer.Press | pointer.Release,
	}.Add(ops)
	area.Pop()

	defer clip.Rect{Max: image.Pt(100, 100)}.Push(ops).Pop()
	var c color.NRGBA
	if pressed {
		c = color.NRGBA{R: 0xFF, A: 0xFF}