package client

import (
	"image/color"

	"fyne.io/fyne/v2"
	"fyne.io/fyne/v2/canvas"
	"fyne.io/fyne/v2/theme"
)

type rasterWidgetRender struct {
	canvas   *interactiveRaster
	bg       *canvas.Raster
	onLayout func(fyne.Size)
}

func (r *rasterWidgetRender) Layout(size fyne.Size) {
	r.bg.Resize(size)
	r.canvas.raster.Resize(size)
	if r.onLayout != nil {
		r.onLayout(size)
	}
}

func (r *rasterWidgetRender) MinSize() fyne.Size {
	return r.MinSize()
}

func (r *rasterWidgetRender) Refresh() {
	canvas.Refresh(r.canvas)
}

func (r *rasterWidgetRender) BackgroundColor() color.Color {
	return theme.Color(theme.ColorNameBackground)
}

func (r *rasterWidgetRender) Objects() []fyne.CanvasObject {
	return []fyne.CanvasObject{r.bg, r.canvas.raster}
}

func (r *rasterWidgetRender) Destroy() {
}
