While scrolling on a window, widgets may disappear too early.
A simple example with a colored rectangle:
package main
import (
"image""image/color""github.com/ebitengine/debugui""github.com/hajimehoshi/ebiten/v2""github.com/hajimehoshi/ebiten/v2/vector"
)
typeGamestruct {
ui debugui.DebugUI
}
func (g*Game) Update() error {
_, err:=g.ui.Update(func(ctx*debugui.Context) error {
ctx.Window("test", image.Rect(0, 0, 300, 300), func(layout debugui.ContainerLayout) {
ctx.Text("test")
ctx.SetGridLayout(nil, []int{150})
ctx.Loop(5, func(iint) {
ctx.GridCell(func(bounds image.Rectangle) {
ctx.DrawOnlyWidget(func(screen*ebiten.Image) {
col:= color.RGBA{R: 255}
vector.FillRect(screen, float32(bounds.Min.X), float32(bounds.Min.Y), float32(bounds.Dx()), float32(bounds.Dy()), col, true)
})
})
})
})
returnnil
})
returnerr
}
func (g*Game) Draw(screen*ebiten.Image) {
g.ui.Draw(screen)
}
func (g*Game) Layout(outsideWidth, outsideHeightint) (screenWidth, screenHeightint) {
returnoutsideWidth, outsideHeight
}
funcmain() {
err:=ebiten.RunGame(&Game{})
iferr!=nil {
panic(err)
}
}
While scrolling on a window, widgets may disappear too early.
A simple example with a colored rectangle: