~eliasnaur/gio-example

7fe1d1f168387509945db619d73033202f99e65e — Egon Elbre 7 months ago 4431f82
Insets are now automatically added.

Signed-off-by: Egon Elbre <egonelbre@gmail.com>
6 files changed, 21 insertions(+), 40 deletions(-)

M go.mod
M go.sum
M kitchen/kitchen.go
M tabs/tabs.go
M x/component/main.go
M x/notify/hello.go
M go.mod => go.mod +1 -1
@@ 3,7 3,7 @@ module gioui.org/example
go 1.13

require (
	gioui.org v0.0.0-20210225120118-f6fba7388544
	gioui.org v0.0.0-20210228180843-e1248651c871
	gioui.org/x v0.0.0-20210226015410-958111222865
	gioui.org/x/haptic v0.0.0-20210120222453-b55819bc712b
	gioui.org/x/notify v0.0.0-20210120222453-b55819bc712b

M go.sum => go.sum +2 -1
@@ 33,8 33,9 @@ cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
dmitri.shuralyov.com/gpu/mtl v0.0.0-20201218220906-28db891af037/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
gioui.org v0.0.0-20210116085804-99bfa6a33cdf/go.mod h1:Y+uS7hHMvku1Q+ooaoq6fYD5B2LGoT8JtFgvmYmRzTw=
gioui.org v0.0.0-20210225120118-f6fba7388544 h1:xQePGQEyaupU5lfPe3//VUVZLXNsjALGAppEVAEzRh8=
gioui.org v0.0.0-20210225120118-f6fba7388544/go.mod h1:Y+uS7hHMvku1Q+ooaoq6fYD5B2LGoT8JtFgvmYmRzTw=
gioui.org v0.0.0-20210228180843-e1248651c871 h1:LDHDc7aDPdzf9I5MfEnSRCSJj6W0Nf6Dl9cLOGj4/ew=
gioui.org v0.0.0-20210228180843-e1248651c871/go.mod h1:Y+uS7hHMvku1Q+ooaoq6fYD5B2LGoT8JtFgvmYmRzTw=
gioui.org/x v0.0.0-20210226015410-958111222865 h1:+Oqlmqi1rRugWA//OMKrQsdulyQB6j4QRo5Dm13jcqs=
gioui.org/x v0.0.0-20210226015410-958111222865/go.mod h1:y7BpIia0O/1wgqVHlfTBaoOCcR1Xm/psmu/1M9AfX9E=
gioui.org/x/haptic v0.0.0-20210120222453-b55819bc712b h1:3lHNKrTHXJCXhtmCVdTInlNuay3jSQ0SVi9JNQTj5yM=

M kitchen/kitchen.go => kitchen/kitchen.go +1 -9
@@ 132,15 132,7 @@ func loop(w *app.Window) error {
						transformTime = time.Time{}
					}
				}

				layout.Inset{
					Bottom: e.Insets.Bottom,
					Left:   e.Insets.Left,
					Right:  e.Insets.Right,
					Top:    e.Insets.Top,
				}.Layout(gtx, func(gtx C) D {
					return transformedKitchen(gtx, th)
				})
				transformedKitchen(gtx, th)
				e.Frame(gtx.Ops)
			}
		case p := <-progressIncrementer:

M tabs/tabs.go => tabs/tabs.go +1 -9
@@ 45,15 45,7 @@ func loop(w *app.Window) error {
			return e.Err
		case system.FrameEvent:
			gtx := layout.NewContext(&ops, e)
			layout.Inset{
   				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)
		})
		
			drawTabs(gtx, th)
			e.Frame(gtx.Ops)
		}
	}

M x/component/main.go => x/component/main.go +3 -1
@@ 613,7 613,9 @@ func loop(w *app.Window) error {
			case system.DestroyEvent:
				return e.Err
			case system.FrameEvent:
				gtx := layout.NewContext(&ops, e)
				skipInset := e
				skipInset.Insets = system.Insets{}
				gtx := layout.NewContext(&ops, skipInset)
				for _, event := range bar.Events(gtx) {
					switch event := event.(type) {
					case component.AppBarNavigationClicked:

M x/notify/hello.go => x/notify/hello.go +13 -19
@@ 49,26 49,20 @@ func loop(w *app.Window) error {
				notificationRequests <- struct{}{}
			}
			gtx := layout.NewContext(&ops, e)
			layout.Inset{
				Top:    e.Insets.Top,
				Bottom: e.Insets.Bottom,
				Left:   e.Insets.Left,
				Right:  e.Insets.Right,
			}.Layout(gtx, func(gtx layout.Context) layout.Dimensions {

				return layout.Flex{Axis: layout.Vertical}.Layout(gtx,
					layout.Rigid(func(gtx layout.Context) layout.Dimensions {
						text := "notification errors will appear here"
						if err != nil {
							text = err.Error()
						}
						return material.Body1(th, text).Layout(gtx)
					}),
					layout.Flexed(1, func(gtx layout.Context) layout.Dimensions {
						return material.Button(th, &button, "Send Notification").Layout(gtx)
					}),
				)
			})
			layout.Flex{Axis: layout.Vertical}.Layout(gtx,
				layout.Rigid(func(gtx layout.Context) layout.Dimensions {
					text := "notification errors will appear here"
					if err != nil {
						text = err.Error()
					}
					return material.Body1(th, text).Layout(gtx)
				}),
				layout.Flexed(1, func(gtx layout.Context) layout.Dimensions {
					return material.Button(th, &button, "Send Notification").Layout(gtx)
				}),
			)

			e.Frame(gtx.Ops)
			if first {
				first = false