Skip to content

Widget not rendered on window scoll #47

Description

@t-geindre

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"
)

type Game struct {
	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(i int) {
				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)
					})
				})
			})
		})
		return nil
	})

	return err
}

func (g *Game) Draw(screen *ebiten.Image) {
	g.ui.Draw(screen)
}

func (g *Game) Layout(outsideWidth, outsideHeight int) (screenWidth, screenHeight int) {
	return outsideWidth, outsideHeight
}

func main() {
	err := ebiten.RunGame(&Game{})
	if err != nil {
		panic(err)
	}
}

Image

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions