From f96cdb619a32c5b7ee11e7b46af321ba2a129092 Mon Sep 17 00:00:00 2001 From: Greg Date: Fri, 23 Aug 2019 11:21:35 -0400 Subject: [PATCH] cmd/scroll: update x/y scrolling demo. --- cmd/scroll/main.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/cmd/scroll/main.go b/cmd/scroll/main.go index d0fc964..fbd0752 100644 --- a/cmd/scroll/main.go +++ b/cmd/scroll/main.go @@ -80,7 +80,7 @@ func diffInsets(x, y app.Insets) bool { func eventloop() { w := app.NewWindow( - app.WithWidth(ui.Dp(200)), + app.WithWidth(ui.Dp(400)), app.WithHeight(ui.Dp(400)), app.WithTitle("Tickets")) ctx := gio.NewContext(w) @@ -93,8 +93,14 @@ func eventloop() { bg := gio.NewBackground(gio.Color(gray2)) margin := gio.NewInset(gio.Size(ui.Dp(10))) + f1 := gio.NewFlex(gio.Axis(layout.Horizontal)) + lbar := gio.NewLabel(" ", gio.Face(face)) + f2 := gio.NewFlex(gio.Axis(layout.Vertical)) + topbar := gio.NewLabel("Scroll X and Y. Click to select", gio.Face(face)) + sh := gio.HScroll(gio.NewFlex(gio.Axis(layout.Horizontal))) sv := gio.VScroll(gio.NewFlex(gio.Axis(layout.Vertical))) + numlabs := 50 labs := make([][]gio.Widget, numlabs) sels := make([][]bool, numlabs) @@ -127,7 +133,7 @@ func eventloop() { } sysbg(sysinset(bg(margin( - sh( + f1(lbar,f2(topbar,sh( sv(labs[0]...), sv(labs[1]...), sv(labs[2]...), @@ -144,7 +150,7 @@ func eventloop() { sv(labs[13]...), sv(labs[14]...), sv(labs[15]...), - ))))).Layout(ctx) + ))))))).Layout(ctx) ctx.Update() } }}