2021-07-30 22:29:20 +00:00
|
|
|
package gui
|
|
|
|
|
2021-08-02 19:55:04 +00:00
|
|
|
import (
|
|
|
|
"image"
|
|
|
|
|
|
|
|
"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)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-07-31 16:35:26 +00:00
|
|
|
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
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-08-02 19:55:04 +00:00
|
|
|
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
|
|
|
|
}
|
|
|
|
}
|