~eliasnaur/gio-patches

This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch
2 2

[PATCH gio-example] app: change clear color to transparent

Paulo Melo
Details
Message ID
<20210215175140.63106-1-paulo.durrer.melo@gmail.com>
DKIM signature
missing
Download raw message
Patch: +87 -26
on wasm canvas the background can be transparent.
this change is to permit the usage of black transparent instead
of white opaque.

Signed-off-by: Paulo Melo <paulo.durrer.melo@gmail.com>
---
 7gui/counter/main.go     | 16 ++++++++++------
 7gui/temperature/main.go | 15 +++++++++------
 7gui/timer/main.go       | 16 ++++++++++------
 gophers/main.go          |  4 ++++
 hello/hello.go           |  4 ++++
 kitchen/kitchen.go       |  3 +++
 life/main.go             |  6 +++++-
 multiwindow/windows.go   |  4 ++++
 tabs/tabs.go             | 17 ++++++++++-------
 x/colorpicker/main.go    |  3 +++
 x/component/main.go      |  2 ++
 x/haptic/example.go      |  4 ++++
 x/notify/hello.go        |  5 +++++
 x/outlay/fan/main.go     |  4 ++++
 x/outlay/grid/main.go    |  3 +++
 x/outlay/table/main.go   |  2 ++
 x/scroll/main.go         |  5 +++++
 17 files changed, 87 insertions(+), 26 deletions(-)

diff --git a/7gui/counter/main.go b/7gui/counter/main.go
index da2a0ee..4beb693 100644
--- a/7gui/counter/main.go
+++ b/7gui/counter/main.go
@@ -1,16 +1,18 @@
package main

import (
	"image/color"
	"log"
	"os"
	"strconv"

	"gioui.org/app"             // app contains Window handling.
	"gioui.org/font/gofont"     // gofont is used for loading the default font.
	"gioui.org/io/key"          // key is used for keyboard events.
	"gioui.org/io/system"       // system is used for system events (e.g. closing the window).
	"gioui.org/layout"          // layout is used for layouting widgets.
	"gioui.org/op"              // op is used for recording different operations.
	"gioui.org/app"         // app contains Window handling.
	"gioui.org/font/gofont" // gofont is used for loading the default font.
	"gioui.org/io/key"      // key is used for keyboard events.
	"gioui.org/io/system"   // system is used for system events (e.g. closing the window).
	"gioui.org/layout"      // layout is used for layouting widgets.
	"gioui.org/op"          // op is used for recording different operations.
	"gioui.org/op/paint"
	"gioui.org/unit"            // unit is used to define pixel-independent sizes
	"gioui.org/widget"          // widget contains state handling for widgets.
	"gioui.org/widget/material" // material contains material design widgets.
@@ -70,6 +72,8 @@ func (ui *UI) Run(w *app.Window) error {
		case system.FrameEvent:
			// gtx is used to pass around rendering and event information.
			gtx := layout.NewContext(&ops, e)
			// set window background to white.
			paint.Fill(gtx.Ops, color.NRGBA{A: 0xFF, R: 0xFF, G: 0xFF, B: 0xFF})
			// render and handle UI.
			ui.Layout(gtx)
			// render and handle the operations from the UI.
diff --git a/7gui/temperature/main.go b/7gui/temperature/main.go
index c708da4..8da051e 100644
--- a/7gui/temperature/main.go
+++ b/7gui/temperature/main.go
@@ -6,12 +6,13 @@ import (
	"os"
	"strconv"

	"gioui.org/app"             // app contains Window handling.
	"gioui.org/font/gofont"     // gofont is used for loading the default font.
	"gioui.org/io/key"          // key is used for keyboard events.
	"gioui.org/io/system"       // system is used for system events (e.g. closing the window).
	"gioui.org/layout"          // layout is used for layouting widgets.
	"gioui.org/op"              // op is used for recording different operations.
	"gioui.org/app"         // app contains Window handling.
	"gioui.org/font/gofont" // gofont is used for loading the default font.
	"gioui.org/io/key"      // key is used for keyboard events.
	"gioui.org/io/system"   // system is used for system events (e.g. closing the window).
	"gioui.org/layout"      // layout is used for layouting widgets.
	"gioui.org/op"          // op is used for recording different operations.
	"gioui.org/op/paint"
	"gioui.org/unit"            // unit is used to define pixel-independent sizes
	"gioui.org/widget"          // widget contains state handling for widgets.
	"gioui.org/widget/material" // material contains material design widgets.
@@ -73,6 +74,8 @@ func (ui *UI) Run(w *app.Window) error {
		case system.FrameEvent:
			// gtx is used to pass around rendering and event information.
			gtx := layout.NewContext(&ops, e)
			// set window background to white.
			paint.Fill(gtx.Ops, color.NRGBA{A: 0xFF, R: 0xFF, G: 0xFF, B: 0xFF})
			// render and handle UI.
			ui.Layout(gtx)
			// render and handle the operations from the UI.
diff --git a/7gui/timer/main.go b/7gui/timer/main.go
index 8be0eb9..b4d2e23 100644
--- a/7gui/timer/main.go
+++ b/7gui/timer/main.go
@@ -1,16 +1,18 @@
package main

import (
	"image/color"
	"log"
	"os"
	"time"

	"gioui.org/app"             // app contains Window handling.
	"gioui.org/font/gofont"     // gofont is used for loading the default font.
	"gioui.org/io/key"          // key is used for keyboard events.
	"gioui.org/io/system"       // system is used for system events (e.g. closing the window).
	"gioui.org/layout"          // layout is used for layouting widgets.
	"gioui.org/op"              // op is used for recording different operations.
	"gioui.org/app"         // app contains Window handling.
	"gioui.org/font/gofont" // gofont is used for loading the default font.
	"gioui.org/io/key"      // key is used for keyboard events.
	"gioui.org/io/system"   // system is used for system events (e.g. closing the window).
	"gioui.org/layout"      // layout is used for layouting widgets.
	"gioui.org/op"          // op is used for recording different operations.
	"gioui.org/op/paint"
	"gioui.org/unit"            // unit is used to define pixel-independent sizes
	"gioui.org/widget"          // widget contains state handling for widgets.
	"gioui.org/widget/material" // material contains material design widgets.
@@ -87,6 +89,8 @@ func (ui *UI) Run(w *app.Window) error {
			case system.FrameEvent:
				// gtx is used to pass around rendering and event information.
				gtx := layout.NewContext(&ops, e)
				// set window background to white.
				paint.Fill(gtx.Ops, color.NRGBA{A: 0xFF, R: 0xFF, G: 0xFF, B: 0xFF})
				// render and handle UI.
				ui.Layout(gtx)
				// render and handle the operations from the UI.
diff --git a/gophers/main.go b/gophers/main.go
index 8cd3c9f..be2d03b 100644
--- a/gophers/main.go
+++ b/gophers/main.go
@@ -21,10 +21,12 @@ import (
	"gioui.org/io/system"
	"gioui.org/layout"
	"gioui.org/op"
	"gioui.org/op/paint"
	"gioui.org/unit"

	"github.com/google/go-github/v24/github"

	"image/color"
	_ "image/jpeg"
	_ "image/png"

@@ -128,6 +130,8 @@ func (a *App) run() error {
				}
			case system.FrameEvent:
				gtx := layout.NewContext(&ops, e)
				// set window background to white.
				paint.Fill(gtx.Ops, color.NRGBA{A: 0xFF, R: 0xFF, G: 0xFF, B: 0xFF})
				a.ui.Layout(gtx)
				e.Frame(gtx.Ops)
			}
diff --git a/hello/hello.go b/hello/hello.go
index 7a328e7..cf53cfc 100644
--- a/hello/hello.go
+++ b/hello/hello.go
@@ -13,6 +13,7 @@ import (
	"gioui.org/io/system"
	"gioui.org/layout"
	"gioui.org/op"
	"gioui.org/op/paint"
	"gioui.org/text"
	"gioui.org/widget/material"

@@ -40,6 +41,9 @@ func loop(w *app.Window) error {
			return e.Err
		case system.FrameEvent:
			gtx := layout.NewContext(&ops, e)
			// set window background to white.
			paint.Fill(gtx.Ops, color.NRGBA{A: 0xFF, R: 0xFF, G: 0xFF, B: 0xFF})

			l := material.H1(th, "Hello, Gio")
			maroon := color.NRGBA{R: 127, G: 0, B: 0, A: 255}
			l.Color = maroon
diff --git a/kitchen/kitchen.go b/kitchen/kitchen.go
index 4c3d3c4..0f61c67 100644
--- a/kitchen/kitchen.go
+++ b/kitchen/kitchen.go
@@ -122,6 +122,9 @@ func loop(w *app.Window) error {
				return e.Err
			case system.FrameEvent:
				gtx := layout.NewContext(&ops, e)
				// set window background to white.
				paint.Fill(gtx.Ops, color.NRGBA{A: 0xFF, R: 0xFF, G: 0xFF, B: 0xFF})

				if *disable {
					gtx = gtx.Disabled()
				}
diff --git a/life/main.go b/life/main.go
index cfb8037..b228c45 100644
--- a/life/main.go
+++ b/life/main.go
@@ -4,6 +4,7 @@ package main

import (
	"image"
	"image/color"
	"log"
	"os"
	"time"
@@ -13,7 +14,8 @@ import (
	"gioui.org/io/system" // system is used for system events (e.g. closing the window).
	"gioui.org/layout"    // layout is used for layouting widgets.
	"gioui.org/op"        // op is used for recording different operations.
	"gioui.org/unit"      // unit is used to define pixel-independent sizes
	"gioui.org/op/paint"
	"gioui.org/unit" // unit is used to define pixel-independent sizes
)

var (
@@ -82,6 +84,8 @@ func (ui *UI) Run(w *app.Window) error {
			case system.FrameEvent:
				// gtx is used to pass around rendering and event information.
				gtx := layout.NewContext(&ops, e)
				// set window background to white.
				paint.Fill(gtx.Ops, color.NRGBA{A: 0xFF, R: 0xFF, G: 0xFF, B: 0xFF})
				// render and handle UI.
				ui.Layout(gtx)
				// render and handle the operations from the UI.
diff --git a/multiwindow/windows.go b/multiwindow/windows.go
index 116441f..ea6efe4 100644
--- a/multiwindow/windows.go
+++ b/multiwindow/windows.go
@@ -5,6 +5,7 @@ package main
// Multiple windows in Gio.

import (
	"image/color"
	"log"
	"os"
	"sync/atomic"
@@ -14,6 +15,7 @@ import (
	"gioui.org/io/system"
	"gioui.org/layout"
	"gioui.org/op"
	"gioui.org/op/paint"
	"gioui.org/unit"
	"gioui.org/widget"
	"gioui.org/widget/material"
@@ -65,6 +67,8 @@ func (w *window) loop(events <-chan event.Event) error {
				w.Close()
			}
			gtx := layout.NewContext(&ops, e)
			// set window background to white.
			paint.Fill(gtx.Ops, color.NRGBA{A: 0xFF, R: 0xFF, G: 0xFF, B: 0xFF})

			layout.Center.Layout(gtx, func(gtx layout.Context) layout.Dimensions {
				return layout.Flex{
diff --git a/tabs/tabs.go b/tabs/tabs.go
index f8bc172..a53afdd 100644
--- a/tabs/tabs.go
+++ b/tabs/tabs.go
@@ -45,15 +45,18 @@ func loop(w *app.Window) error {
			return e.Err
		case system.FrameEvent:
			gtx := layout.NewContext(&ops, e)
			// set window background to white.
			paint.Fill(gtx.Ops, color.NRGBA{A: 0xFF, R: 0xFF, G: 0xFF, B: 0xFF})

			layout.Inset{
   				Bottom: e.Insets.Bottom,
   				Left:   e.Insets.Left,
    				Right:  e.Insets.Right,
    				Top:    e.Insets.Top,
				Bottom: e.Insets.Bottom,
				Left:   e.Insets.Left,
				Right:  e.Insets.Right,
				Top:    e.Insets.Top,
			}.Layout(gtx, func(gtx C) D {
   		 		return drawTabs(gtx, th)
		})
		
				return drawTabs(gtx, th)
			})

			e.Frame(gtx.Ops)
		}
	}
diff --git a/x/colorpicker/main.go b/x/colorpicker/main.go
index 76e3f97..1f000ed 100644
--- a/x/colorpicker/main.go
+++ b/x/colorpicker/main.go
@@ -66,6 +66,9 @@ func loop(w *app.Window) error {
			return e.Err
		case system.FrameEvent:
			gtx := layout.NewContext(&ops, e)
			// set window background to white.
			paint.Fill(gtx.Ops, color.NRGBA{A: 0xFF, R: 0xFF, G: 0xFF, B: 0xFF})

			if muxState.Changed() {
				background = *muxState.Color()
				log.Printf("mux changed")
diff --git a/x/component/main.go b/x/component/main.go
index 213b650..2906275 100644
--- a/x/component/main.go
+++ b/x/component/main.go
@@ -614,6 +614,8 @@ func loop(w *app.Window) error {
				return e.Err
			case system.FrameEvent:
				gtx := layout.NewContext(&ops, e)
				// set window background to white.
				paint.Fill(gtx.Ops, color.NRGBA{A: 0xFF, R: 0xFF, G: 0xFF, B: 0xFF})
				for _, event := range bar.Events(gtx) {
					switch event := event.(type) {
					case component.AppBarNavigationClicked:
diff --git a/x/haptic/example.go b/x/haptic/example.go
index e2cb407..e9bf7cf 100644
--- a/x/haptic/example.go
+++ b/x/haptic/example.go
@@ -5,12 +5,14 @@ package main
// A simple Gio program. See https://gioui.org for more information.

import (
	"image/color"
	"log"

	"gioui.org/app"
	"gioui.org/io/system"
	"gioui.org/layout"
	"gioui.org/op"
	"gioui.org/op/paint"
	"gioui.org/widget"
	"gioui.org/widget/material"

@@ -46,6 +48,8 @@ func loop(w *app.Window) error {
					buzzer.Buzz()
				}
				gtx := layout.NewContext(&ops, e)
				// set window background to white.
				paint.Fill(gtx.Ops, color.NRGBA{A: 0xFF, R: 0xFF, G: 0xFF, B: 0xFF})
				layout.Center.Layout(gtx, material.Button(th, &btn, "buzz").Layout)
				e.Frame(gtx.Ops)
			default:
diff --git a/x/notify/hello.go b/x/notify/hello.go
index 744fbbf..88098a2 100644
--- a/x/notify/hello.go
+++ b/x/notify/hello.go
@@ -6,6 +6,7 @@ package main

import (
	//	"image/color"
	"image/color"
	"log"
	"time"

@@ -13,6 +14,7 @@ import (
	"gioui.org/io/system"
	"gioui.org/layout"
	"gioui.org/op"
	"gioui.org/op/paint"

	//	"gioui.org/text"
	"gioui.org/widget"
@@ -49,6 +51,9 @@ func loop(w *app.Window) error {
				notificationRequests <- struct{}{}
			}
			gtx := layout.NewContext(&ops, e)
			// set window background to white.
			paint.Fill(gtx.Ops, color.NRGBA{A: 0xFF, R: 0xFF, G: 0xFF, B: 0xFF})

			layout.Inset{
				Top:    e.Insets.Top,
				Bottom: e.Insets.Bottom,
diff --git a/x/outlay/fan/main.go b/x/outlay/fan/main.go
index a03a7e0..f476d67 100644
--- a/x/outlay/fan/main.go
+++ b/x/outlay/fan/main.go
@@ -1,6 +1,7 @@
package main

import (
	"image/color"
	"log"
	"math"
	"math/rand"
@@ -15,6 +16,7 @@ import (
	"gioui.org/io/system"
	"gioui.org/layout"
	"gioui.org/op"
	"gioui.org/op/paint"
	"gioui.org/unit"
	"gioui.org/widget"
	"gioui.org/widget/material"
@@ -83,6 +85,8 @@ func loop(w *app.Window) error {
			return e.Err
		case system.FrameEvent:
			gtx := layout.NewContext(&ops, e)
			// set window background to white.
			paint.Fill(gtx.Ops, color.NRGBA{A: 0xFF, R: 0xFF, G: 0xFF, B: 0xFF})
			for i := range cards {
				cardChildren[i].Elevate = cards[i].Hovering(gtx)
			}
diff --git a/x/outlay/grid/main.go b/x/outlay/grid/main.go
index a688de3..27f8c9d 100644
--- a/x/outlay/grid/main.go
+++ b/x/outlay/grid/main.go
@@ -48,6 +48,9 @@ func loop(w *app.Window) error {

		case system.FrameEvent:
			gtx := layout.NewContext(&ops, e)
			// set window background to white.
			paint.Fill(gtx.Ops, color.NRGBA{A: 0xFF, R: 0xFF, G: 0xFF, B: 0xFF})

			ui.Layout(gtx)
			e.Frame(gtx.Ops)
		}
diff --git a/x/outlay/table/main.go b/x/outlay/table/main.go
index 550ce0f..fe6cc03 100644
--- a/x/outlay/table/main.go
+++ b/x/outlay/table/main.go
@@ -53,6 +53,8 @@ func loop(w *app.Window) error {

		case system.FrameEvent:
			gtx := layout.NewContext(&ops, e)
			// set window background to white.
			paint.Fill(gtx.Ops, color.NRGBA{A: 0xFF, R: 0xFF, G: 0xFF, B: 0xFF})
			table.Layout(gtx)
			e.Frame(gtx.Ops)
		}
diff --git a/x/scroll/main.go b/x/scroll/main.go
index 861a110..2542418 100644
--- a/x/scroll/main.go
+++ b/x/scroll/main.go
@@ -4,6 +4,7 @@ package main
// A simple Gio program. See https://gioui.org for more information.

import (
	"image/color"
	"log"
	"os"
	"strconv"
@@ -12,6 +13,7 @@ import (
	"gioui.org/io/system"
	"gioui.org/layout"
	"gioui.org/op"
	"gioui.org/op/paint"
	"gioui.org/unit"
	"gioui.org/widget"
	"gioui.org/widget/material"
@@ -58,6 +60,9 @@ func loop(w *app.Window) error {
			return e.Err
		case system.FrameEvent:
			gtx := layout.NewContext(&ops, e)
			// set window background to white.
			paint.Fill(gtx.Ops, color.NRGBA{A: 0xFF, R: 0xFF, G: 0xFF, B: 0xFF})

			if increaseBtn.Clicked() {
				length *= 2
			}
-- 
2.26.2

[gio-example/patches/linux.yml] build success

builds.sr.ht
Details
Message ID
<C9AAQQBRP46X.292OUJVMFRZID@cirno>
In-Reply-To
<20210215175140.63106-1-paulo.durrer.melo@gmail.com> (view parent)
DKIM signature
missing
Download raw message
gio-example/patches/linux.yml: SUCCESS in 2m30s

[app: change clear color to transparent][0] from [Paulo Melo][1]

[0]: https://lists.sr.ht/~eliasnaur/gio-patches/patches/20287
[1]: mailto:paulo.durrer.melo@gmail.com

✓ #427005 SUCCESS gio-example/patches/linux.yml https://builds.sr.ht/~eliasnaur/job/427005
Details
Message ID
<CANtNKfruGR=+5whMCbRO3pA29knGS8qWY0Z51C-MnESQtoo4Xw@mail.gmail.com>
In-Reply-To
<20210215175140.63106-1-paulo.durrer.melo@gmail.com> (view parent)
DKIM signature
pass
Download raw message
On Mon, Feb 15, 2021 at 8:09 PM Paulo Melo <paulo.durrer.melo@gmail.com> wrote:
>
> on wasm canvas the background can be transparent.
> this change is to permit the usage of black transparent instead
> of white opaque.
>
> Signed-off-by: Paulo Melo <paulo.durrer.melo@gmail.com>
> ---
>  7gui/counter/main.go     | 16 ++++++++++------
>  7gui/temperature/main.go | 15 +++++++++------
>  7gui/timer/main.go       | 16 ++++++++++------
>  gophers/main.go          |  4 ++++
>  hello/hello.go           |  4 ++++
>  kitchen/kitchen.go       |  3 +++
>  life/main.go             |  6 +++++-
>  multiwindow/windows.go   |  4 ++++
>  tabs/tabs.go             | 17 ++++++++++-------
>  x/colorpicker/main.go    |  3 +++
>  x/component/main.go      |  2 ++
>  x/haptic/example.go      |  4 ++++
>  x/notify/hello.go        |  5 +++++
>  x/outlay/fan/main.go     |  4 ++++
>  x/outlay/grid/main.go    |  3 +++
>  x/outlay/table/main.go   |  2 ++
>  x/scroll/main.go         |  5 +++++
>  17 files changed, 87 insertions(+), 26 deletions(-)
>
> diff --git a/7gui/counter/main.go b/7gui/counter/main.go
> index da2a0ee..4beb693 100644
> --- a/7gui/counter/main.go
> +++ b/7gui/counter/main.go
> @@ -1,16 +1,18 @@
>  package main
>
>  import (
> +       "image/color"
>         "log"
>         "os"
>         "strconv"
>
> -       "gioui.org/app"             // app contains Window handling.
> -       "gioui.org/font/gofont"     // gofont is used for loading the default font.
> -       "gioui.org/io/key"          // key is used for keyboard events.
> -       "gioui.org/io/system"       // system is used for system events (e.g. closing the window).
> -       "gioui.org/layout"          // layout is used for layouting widgets.
> -       "gioui.org/op"              // op is used for recording different operations.
> +       "gioui.org/app"         // app contains Window handling.
> +       "gioui.org/font/gofont" // gofont is used for loading the default font.
> +       "gioui.org/io/key"      // key is used for keyboard events.
> +       "gioui.org/io/system"   // system is used for system events (e.g. closing the window).
> +       "gioui.org/layout"      // layout is used for layouting widgets.
> +       "gioui.org/op"          // op is used for recording different operations.
> +       "gioui.org/op/paint"

Document all the imports in 7gui examples to be really explicit.

>         "gioui.org/unit"            // unit is used to define pixel-independent sizes
>         "gioui.org/widget"          // widget contains state handling for widgets.
>         "gioui.org/widget/material" // material contains material design widgets.
> @@ -70,6 +72,8 @@ func (ui *UI) Run(w *app.Window) error {
>                 case system.FrameEvent:
>                         // gtx is used to pass around rendering and event information.
>                         gtx := layout.NewContext(&ops, e)
> +                       // set window background to white.
> +                       paint.Fill(gtx.Ops, color.NRGBA{A: 0xFF, R: 0xFF, G: 0xFF, B: 0xFF})
>                         // render and handle UI.
>                         ui.Layout(gtx)
>                         // render and handle the operations from the UI.
> diff --git a/7gui/temperature/main.go b/7gui/temperature/main.go
> index c708da4..8da051e 100644
> --- a/7gui/temperature/main.go
> +++ b/7gui/temperature/main.go
> @@ -6,12 +6,13 @@ import (
>         "os"
>         "strconv"
>
> -       "gioui.org/app"             // app contains Window handling.
> -       "gioui.org/font/gofont"     // gofont is used for loading the default font.
> -       "gioui.org/io/key"          // key is used for keyboard events.
> -       "gioui.org/io/system"       // system is used for system events (e.g. closing the window).
> -       "gioui.org/layout"          // layout is used for layouting widgets.
> -       "gioui.org/op"              // op is used for recording different operations.
> +       "gioui.org/app"         // app contains Window handling.
> +       "gioui.org/font/gofont" // gofont is used for loading the default font.
> +       "gioui.org/io/key"      // key is used for keyboard events.
> +       "gioui.org/io/system"   // system is used for system events (e.g. closing the window).
> +       "gioui.org/layout"      // layout is used for layouting widgets.
> +       "gioui.org/op"          // op is used for recording different operations.
> +       "gioui.org/op/paint"
>         "gioui.org/unit"            // unit is used to define pixel-independent sizes
>         "gioui.org/widget"          // widget contains state handling for widgets.
>         "gioui.org/widget/material" // material contains material design widgets.
> @@ -73,6 +74,8 @@ func (ui *UI) Run(w *app.Window) error {
>                 case system.FrameEvent:
>                         // gtx is used to pass around rendering and event information.
>                         gtx := layout.NewContext(&ops, e)
> +                       // set window background to white.
> +                       paint.Fill(gtx.Ops, color.NRGBA{A: 0xFF, R: 0xFF, G: 0xFF, B: 0xFF})
>                         // render and handle UI.
>                         ui.Layout(gtx)
>                         // render and handle the operations from the UI.
> diff --git a/7gui/timer/main.go b/7gui/timer/main.go
> index 8be0eb9..b4d2e23 100644
> --- a/7gui/timer/main.go
> +++ b/7gui/timer/main.go
> @@ -1,16 +1,18 @@
>  package main
>
>  import (
> +       "image/color"
>         "log"
>         "os"
>         "time"
>
> -       "gioui.org/app"             // app contains Window handling.
> -       "gioui.org/font/gofont"     // gofont is used for loading the default font.
> -       "gioui.org/io/key"          // key is used for keyboard events.
> -       "gioui.org/io/system"       // system is used for system events (e.g. closing the window).
> -       "gioui.org/layout"          // layout is used for layouting widgets.
> -       "gioui.org/op"              // op is used for recording different operations.
> +       "gioui.org/app"         // app contains Window handling.
> +       "gioui.org/font/gofont" // gofont is used for loading the default font.
> +       "gioui.org/io/key"      // key is used for keyboard events.
> +       "gioui.org/io/system"   // system is used for system events (e.g. closing the window).
> +       "gioui.org/layout"      // layout is used for layouting widgets.
> +       "gioui.org/op"          // op is used for recording different operations.
> +       "gioui.org/op/paint"
>         "gioui.org/unit"            // unit is used to define pixel-independent sizes
>         "gioui.org/widget"          // widget contains state handling for widgets.
>         "gioui.org/widget/material" // material contains material design widgets.
> @@ -87,6 +89,8 @@ func (ui *UI) Run(w *app.Window) error {
>                         case system.FrameEvent:
>                                 // gtx is used to pass around rendering and event information.
>                                 gtx := layout.NewContext(&ops, e)
> +                               // set window background to white.
> +                               paint.Fill(gtx.Ops, color.NRGBA{A: 0xFF, R: 0xFF, G: 0xFF, B: 0xFF})
>                                 // render and handle UI.
>                                 ui.Layout(gtx)
>                                 // render and handle the operations from the UI.
> diff --git a/gophers/main.go b/gophers/main.go
> index 8cd3c9f..be2d03b 100644
> --- a/gophers/main.go
> +++ b/gophers/main.go
> @@ -21,10 +21,12 @@ import (
>         "gioui.org/io/system"
>         "gioui.org/layout"
>         "gioui.org/op"
> +       "gioui.org/op/paint"
>         "gioui.org/unit"
>
>         "github.com/google/go-github/v24/github"
>
> +       "image/color"
>         _ "image/jpeg"
>         _ "image/png"
>
> @@ -128,6 +130,8 @@ func (a *App) run() error {
>                                 }
>                         case system.FrameEvent:
>                                 gtx := layout.NewContext(&ops, e)
> +                               // set window background to white.
> +                               paint.Fill(gtx.Ops, color.NRGBA{A: 0xFF, R: 0xFF, G: 0xFF, B: 0xFF})
>                                 a.ui.Layout(gtx)
>                                 e.Frame(gtx.Ops)
>                         }
> diff --git a/hello/hello.go b/hello/hello.go
> index 7a328e7..cf53cfc 100644
> --- a/hello/hello.go
> +++ b/hello/hello.go
> @@ -13,6 +13,7 @@ import (
>         "gioui.org/io/system"
>         "gioui.org/layout"
>         "gioui.org/op"
> +       "gioui.org/op/paint"
>         "gioui.org/text"
>         "gioui.org/widget/material"
>
> @@ -40,6 +41,9 @@ func loop(w *app.Window) error {
>                         return e.Err
>                 case system.FrameEvent:
>                         gtx := layout.NewContext(&ops, e)
> +                       // set window background to white.
> +                       paint.Fill(gtx.Ops, color.NRGBA{A: 0xFF, R: 0xFF, G: 0xFF, B: 0xFF})
> +
>                         l := material.H1(th, "Hello, Gio")
>                         maroon := color.NRGBA{R: 127, G: 0, B: 0, A: 255}
>                         l.Color = maroon
> diff --git a/kitchen/kitchen.go b/kitchen/kitchen.go
> index 4c3d3c4..0f61c67 100644
> --- a/kitchen/kitchen.go
> +++ b/kitchen/kitchen.go
> @@ -122,6 +122,9 @@ func loop(w *app.Window) error {
>                                 return e.Err
>                         case system.FrameEvent:
>                                 gtx := layout.NewContext(&ops, e)
> +                               // set window background to white.
> +                               paint.Fill(gtx.Ops, color.NRGBA{A: 0xFF, R: 0xFF, G: 0xFF, B: 0xFF})
> +
>                                 if *disable {
>                                         gtx = gtx.Disabled()
>                                 }
> diff --git a/life/main.go b/life/main.go
> index cfb8037..b228c45 100644
> --- a/life/main.go
> +++ b/life/main.go
> @@ -4,6 +4,7 @@ package main
>
>  import (
>         "image"
> +       "image/color"
>         "log"
>         "os"
>         "time"
> @@ -13,7 +14,8 @@ import (
>         "gioui.org/io/system" // system is used for system events (e.g. closing the window).
>         "gioui.org/layout"    // layout is used for layouting widgets.
>         "gioui.org/op"        // op is used for recording different operations.
> -       "gioui.org/unit"      // unit is used to define pixel-independent sizes
> +       "gioui.org/op/paint"
> +       "gioui.org/unit" // unit is used to define pixel-independent sizes
>  )
>
>  var (
> @@ -82,6 +84,8 @@ func (ui *UI) Run(w *app.Window) error {
>                         case system.FrameEvent:
>                                 // gtx is used to pass around rendering and event information.
>                                 gtx := layout.NewContext(&ops, e)
> +                               // set window background to white.
> +                               paint.Fill(gtx.Ops, color.NRGBA{A: 0xFF, R: 0xFF, G: 0xFF, B: 0xFF})
>                                 // render and handle UI.
>                                 ui.Layout(gtx)
>                                 // render and handle the operations from the UI.
> diff --git a/multiwindow/windows.go b/multiwindow/windows.go
> index 116441f..ea6efe4 100644
> --- a/multiwindow/windows.go
> +++ b/multiwindow/windows.go
> @@ -5,6 +5,7 @@ package main
>  // Multiple windows in Gio.
>
>  import (
> +       "image/color"
>         "log"
>         "os"
>         "sync/atomic"
> @@ -14,6 +15,7 @@ import (
>         "gioui.org/io/system"
>         "gioui.org/layout"
>         "gioui.org/op"
> +       "gioui.org/op/paint"
>         "gioui.org/unit"
>         "gioui.org/widget"
>         "gioui.org/widget/material"
> @@ -65,6 +67,8 @@ func (w *window) loop(events <-chan event.Event) error {
>                                 w.Close()
>                         }
>                         gtx := layout.NewContext(&ops, e)
> +                       // set window background to white.
> +                       paint.Fill(gtx.Ops, color.NRGBA{A: 0xFF, R: 0xFF, G: 0xFF, B: 0xFF})
>
>                         layout.Center.Layout(gtx, func(gtx layout.Context) layout.Dimensions {
>                                 return layout.Flex{
> diff --git a/tabs/tabs.go b/tabs/tabs.go
> index f8bc172..a53afdd 100644
> --- a/tabs/tabs.go
> +++ b/tabs/tabs.go
> @@ -45,15 +45,18 @@ func loop(w *app.Window) error {
>                         return e.Err
>                 case system.FrameEvent:
>                         gtx := layout.NewContext(&ops, e)
> +                       // set window background to white.
> +                       paint.Fill(gtx.Ops, color.NRGBA{A: 0xFF, R: 0xFF, G: 0xFF, B: 0xFF})
> +
>                         layout.Inset{
> -                               Bottom: e.Insets.Bottom,
> -                               Left:   e.Insets.Left,
> -                               Right:  e.Insets.Right,
> -                               Top:    e.Insets.Top,
> +                               Bottom: e.Insets.Bottom,
> +                               Left:   e.Insets.Left,
> +                               Right:  e.Insets.Right,
> +                               Top:    e.Insets.Top,
>                         }.Layout(gtx, func(gtx C) D {
> -                               return drawTabs(gtx, th)
> -               })
> -
> +                               return drawTabs(gtx, th)
> +                       })
> +
>                         e.Frame(gtx.Ops)
>                 }
>         }
> diff --git a/x/colorpicker/main.go b/x/colorpicker/main.go
> index 76e3f97..1f000ed 100644
> --- a/x/colorpicker/main.go
> +++ b/x/colorpicker/main.go
> @@ -66,6 +66,9 @@ func loop(w *app.Window) error {
>                         return e.Err
>                 case system.FrameEvent:
>                         gtx := layout.NewContext(&ops, e)
> +                       // set window background to white.
> +                       paint.Fill(gtx.Ops, color.NRGBA{A: 0xFF, R: 0xFF, G: 0xFF, B: 0xFF})
> +
>                         if muxState.Changed() {
>                                 background = *muxState.Color()
>                                 log.Printf("mux changed")
> diff --git a/x/component/main.go b/x/component/main.go
> index 213b650..2906275 100644
> --- a/x/component/main.go
> +++ b/x/component/main.go
> @@ -614,6 +614,8 @@ func loop(w *app.Window) error {
>                                 return e.Err
>                         case system.FrameEvent:
>                                 gtx := layout.NewContext(&ops, e)
> +                               // set window background to white.
> +                               paint.Fill(gtx.Ops, color.NRGBA{A: 0xFF, R: 0xFF, G: 0xFF, B: 0xFF})
>                                 for _, event := range bar.Events(gtx) {
>                                         switch event := event.(type) {
>                                         case component.AppBarNavigationClicked:
> diff --git a/x/haptic/example.go b/x/haptic/example.go
> index e2cb407..e9bf7cf 100644
> --- a/x/haptic/example.go
> +++ b/x/haptic/example.go
> @@ -5,12 +5,14 @@ package main
>  // A simple Gio program. See https://gioui.org for more information.
>
>  import (
> +       "image/color"
>         "log"
>
>         "gioui.org/app"
>         "gioui.org/io/system"
>         "gioui.org/layout"
>         "gioui.org/op"
> +       "gioui.org/op/paint"
>         "gioui.org/widget"
>         "gioui.org/widget/material"
>
> @@ -46,6 +48,8 @@ func loop(w *app.Window) error {
>                                         buzzer.Buzz()
>                                 }
>                                 gtx := layout.NewContext(&ops, e)
> +                               // set window background to white.
> +                               paint.Fill(gtx.Ops, color.NRGBA{A: 0xFF, R: 0xFF, G: 0xFF, B: 0xFF})
>                                 layout.Center.Layout(gtx, material.Button(th, &btn, "buzz").Layout)
>                                 e.Frame(gtx.Ops)
>                         default:
> diff --git a/x/notify/hello.go b/x/notify/hello.go
> index 744fbbf..88098a2 100644
> --- a/x/notify/hello.go
> +++ b/x/notify/hello.go
> @@ -6,6 +6,7 @@ package main
>
>  import (
>         //      "image/color"
> +       "image/color"
>         "log"
>         "time"
>
> @@ -13,6 +14,7 @@ import (
>         "gioui.org/io/system"
>         "gioui.org/layout"
>         "gioui.org/op"
> +       "gioui.org/op/paint"
>
>         //      "gioui.org/text"
>         "gioui.org/widget"
> @@ -49,6 +51,9 @@ func loop(w *app.Window) error {
>                                 notificationRequests <- struct{}{}
>                         }
>                         gtx := layout.NewContext(&ops, e)
> +                       // set window background to white.
> +                       paint.Fill(gtx.Ops, color.NRGBA{A: 0xFF, R: 0xFF, G: 0xFF, B: 0xFF})
> +
>                         layout.Inset{
>                                 Top:    e.Insets.Top,
>                                 Bottom: e.Insets.Bottom,
> diff --git a/x/outlay/fan/main.go b/x/outlay/fan/main.go
> index a03a7e0..f476d67 100644
> --- a/x/outlay/fan/main.go
> +++ b/x/outlay/fan/main.go
> @@ -1,6 +1,7 @@
>  package main
>
>  import (
> +       "image/color"
>         "log"
>         "math"
>         "math/rand"
> @@ -15,6 +16,7 @@ import (
>         "gioui.org/io/system"
>         "gioui.org/layout"
>         "gioui.org/op"
> +       "gioui.org/op/paint"
>         "gioui.org/unit"
>         "gioui.org/widget"
>         "gioui.org/widget/material"
> @@ -83,6 +85,8 @@ func loop(w *app.Window) error {
>                         return e.Err
>                 case system.FrameEvent:
>                         gtx := layout.NewContext(&ops, e)
> +                       // set window background to white.
> +                       paint.Fill(gtx.Ops, color.NRGBA{A: 0xFF, R: 0xFF, G: 0xFF, B: 0xFF})
>                         for i := range cards {
>                                 cardChildren[i].Elevate = cards[i].Hovering(gtx)
>                         }
> diff --git a/x/outlay/grid/main.go b/x/outlay/grid/main.go
> index a688de3..27f8c9d 100644
> --- a/x/outlay/grid/main.go
> +++ b/x/outlay/grid/main.go
> @@ -48,6 +48,9 @@ func loop(w *app.Window) error {
>
>                 case system.FrameEvent:
>                         gtx := layout.NewContext(&ops, e)
> +                       // set window background to white.
> +                       paint.Fill(gtx.Ops, color.NRGBA{A: 0xFF, R: 0xFF, G: 0xFF, B: 0xFF})
> +
>                         ui.Layout(gtx)
>                         e.Frame(gtx.Ops)
>                 }
> diff --git a/x/outlay/table/main.go b/x/outlay/table/main.go
> index 550ce0f..fe6cc03 100644
> --- a/x/outlay/table/main.go
> +++ b/x/outlay/table/main.go
> @@ -53,6 +53,8 @@ func loop(w *app.Window) error {
>
>                 case system.FrameEvent:
>                         gtx := layout.NewContext(&ops, e)
> +                       // set window background to white.
> +                       paint.Fill(gtx.Ops, color.NRGBA{A: 0xFF, R: 0xFF, G: 0xFF, B: 0xFF})
>                         table.Layout(gtx)
>                         e.Frame(gtx.Ops)
>                 }
> diff --git a/x/scroll/main.go b/x/scroll/main.go
> index 861a110..2542418 100644
> --- a/x/scroll/main.go
> +++ b/x/scroll/main.go
> @@ -4,6 +4,7 @@ package main
>  // A simple Gio program. See https://gioui.org for more information.
>
>  import (
> +       "image/color"
>         "log"
>         "os"
>         "strconv"
> @@ -12,6 +13,7 @@ import (
>         "gioui.org/io/system"
>         "gioui.org/layout"
>         "gioui.org/op"
> +       "gioui.org/op/paint"
>         "gioui.org/unit"
>         "gioui.org/widget"
>         "gioui.org/widget/material"
> @@ -58,6 +60,9 @@ func loop(w *app.Window) error {
>                         return e.Err
>                 case system.FrameEvent:
>                         gtx := layout.NewContext(&ops, e)
> +                       // set window background to white.
> +                       paint.Fill(gtx.Ops, color.NRGBA{A: 0xFF, R: 0xFF, G: 0xFF, B: 0xFF})
> +
>                         if increaseBtn.Clicked() {
>                                 length *= 2
>                         }
> --
> 2.26.2
>
Reply to thread Export thread (mbox)