~jakebowkett


#187 List horizontal scrolling doesn't work 26 days ago

Ticket created by ~jakebowkett on ~eliasnaur/gio

Hi, vertical scrolling works fine but horizontal scrolling doesn't when using layout.List.

I'm on a Windows machine and using the mousewheel to scroll.

Reproduction (you just need to change Axis: layout.Vertical to Axis: layout.Horizontal to compare the two):

package main

import (
	"image"
	"image/color"
	"os"

	"gioui.org/app"
	"gioui.org/f32"
	"gioui.org/io/system"
	"gioui.org/layout"
	"gioui.org/op"
	"gioui.org/op/paint"
)

func main() {
	go func() {
		w := app.NewWindow()
		for e := range w.Events() {
			switch e := e.(type) {
			case system.DestroyEvent:
				os.Exit(0)
			case system.FrameEvent:
				ops := new(op.Ops)
				draw(layout.NewContext(ops, e))
				e.Frame(ops)
			}
		}
	}()
	app.Main()
}

var list = layout.List{Axis: layout.Vertical}

func draw(gtx layout.Context) {
	// Make the list's inner contents larger than list container.
	pt := image.Pt(gtx.Constraints.Max.X*2, gtx.Constraints.Max.Y*2)
	list.Layout(gtx, 1, func(gtx layout.Context, i int) layout.Dimensions {
		paint.LinearGradientOp{
			Stop1:  f32.Point{},
			Color1: color.NRGBA{160, 0, 0, 255},
			Stop2:  layout.FPt(pt),
			Color2: color.NRGBA{80, 160, 0, 255},
		}.Add(gtx.Ops)
		paint.PaintOp{}.Add(gtx.Ops)
		return layout.Dimensions{Size: pt}
	})
}