erm/app/darktile/gui/options.go

64 lines
1.2 KiB
Go
Raw Permalink Normal View History

2021-07-30 22:29:20 +00:00
package gui
import (
"image"
2023-01-16 02:18:08 +00:00
"github.com/hajimehoshi/ebiten/v2"
)
2021-07-30 22:29:20 +00:00
type Option func(g *GUI) error
func WithFontFamily(family string) func(g *GUI) error {
return func(g *GUI) error {
return g.fontManager.SetFontByFamilyName(family)
}
}
2023-01-16 06:03:38 +00:00
func WithFontStyle(style string) func(g *GUI) error {
return func(g *GUI) error {
return g.fontManager.SetFontStyle(style)
}
}
func WithOpacity(opacity float64) func(g *GUI) error {
return func(g *GUI) error {
g.opacity = opacity
return nil
}
}
2021-07-30 22:29:20 +00:00
func WithFontSize(size float64) func(g *GUI) error {
return func(g *GUI) error {
g.fontManager.SetSize(size)
return nil
}
}
func WithFontDPI(dpi float64) func(g *GUI) error {
return func(g *GUI) error {
g.fontManager.SetSize(dpi)
return nil
}
}
func WithLigatures(enable bool) func(g *GUI) error {
return func(g *GUI) error {
g.enableLigatures = enable
return nil
}
}
func WithCursorImage(img image.Image) func(g *GUI) error {
return func(g *GUI) error {
g.cursorImage = ebiten.NewImageFromImage(img)
return nil
}
}
2021-07-30 22:29:20 +00:00
func WithStartupFunc(f func(g *GUI)) Option {
return func(g *GUI) error {
g.startupFuncs = append(g.startupFuncs, f)
return nil
}
}