package gui

import (
	"image"
	"image/color"

	"github.com/hajimehoshi/ebiten/text"
	"golang.org/x/image/font"
)

type AppContext interface {
	Font() *Font
	FontSize() int
	Foreground() color.Color
	Background() color.Color

	MeasureString(str string, f font.Face) image.Rectangle
}

type appCtx struct {
	font     *Font
	fontSize int
	fg, bg   color.Color
}

var _ AppContext = &appCtx{}

func (c *appCtx) Font() *Font {
	return c.font
}

func (c *appCtx) FontSize() int {
	return c.fontSize
}

func (c *appCtx) Foreground() color.Color {
	return c.fg
}

func (c *appCtx) Background() color.Color {
	return c.bg
}

func (c *appCtx) MeasureString(str string, f font.Face) image.Rectangle {
	return text.BoundString(f, str)
}
