Allow specifying font face mutex
This commit is contained in:
parent
354a405635
commit
c8545de5b3
6 changed files with 25 additions and 20 deletions
|
@ -23,7 +23,7 @@ func NewButton(label string, onSelected func() error) *Button {
|
|||
textColor = Style.TextColorDark
|
||||
}
|
||||
|
||||
l := messeji.NewTextField(Style.TextFont)
|
||||
l := messeji.NewTextField(Style.TextFont, Style.TextFontMutex)
|
||||
l.SetText(label)
|
||||
l.SetForegroundColor(textColor)
|
||||
l.SetBackgroundColor(transparent)
|
||||
|
|
10
go.mod
10
go.mod
|
@ -3,10 +3,10 @@ module code.rocket9labs.com/tslocum/etk
|
|||
go 1.18
|
||||
|
||||
require (
|
||||
code.rocketnine.space/tslocum/messeji v1.0.5-0.20231102191237-a6fd28a6b52d
|
||||
code.rocketnine.space/tslocum/messeji v1.0.6-0.20231108013522-08fa5fbe2882
|
||||
github.com/hajimehoshi/ebiten/v2 v2.6.2
|
||||
github.com/llgcode/draw2d v0.0.0-20231022063514-1acb54133d2a
|
||||
golang.org/x/image v0.13.0
|
||||
golang.org/x/image v0.14.0
|
||||
)
|
||||
|
||||
require (
|
||||
|
@ -15,7 +15,7 @@ require (
|
|||
github.com/jezek/xgb v1.1.0 // indirect
|
||||
golang.org/x/exp/shiny v0.0.0-20231006140011-7918f672742d // indirect
|
||||
golang.org/x/mobile v0.0.0-20231006135142-2b44d11868fe // indirect
|
||||
golang.org/x/sync v0.4.0 // indirect
|
||||
golang.org/x/sys v0.13.0 // indirect
|
||||
golang.org/x/text v0.13.0 // indirect
|
||||
golang.org/x/sync v0.5.0 // indirect
|
||||
golang.org/x/sys v0.14.0 // indirect
|
||||
golang.org/x/text v0.14.0 // indirect
|
||||
)
|
||||
|
|
22
go.sum
22
go.sum
|
@ -1,5 +1,7 @@
|
|||
code.rocketnine.space/tslocum/messeji v1.0.5-0.20231102191237-a6fd28a6b52d h1:+/yDwjXqp7aKxDEYAKmWJfGNO7uOeo0nraj4aL8zUfQ=
|
||||
code.rocketnine.space/tslocum/messeji v1.0.5-0.20231102191237-a6fd28a6b52d/go.mod h1:xszLyTZtpyjCVaGmznizLSAlnvraPOSoanlzUBeqGco=
|
||||
code.rocketnine.space/tslocum/messeji v1.0.5 h1:aIQ6dYgIzqyv2AFtVHVNNTNZEum+2m8wTBBK/0Vev8g=
|
||||
code.rocketnine.space/tslocum/messeji v1.0.5/go.mod h1:xszLyTZtpyjCVaGmznizLSAlnvraPOSoanlzUBeqGco=
|
||||
code.rocketnine.space/tslocum/messeji v1.0.6-0.20231108013522-08fa5fbe2882 h1:/bHhrKySAQogVQaPph6SAi6PY1WCVzYQuWvEGWFxQXw=
|
||||
code.rocketnine.space/tslocum/messeji v1.0.6-0.20231108013522-08fa5fbe2882/go.mod h1:DVSVJUFs9QkKxnGOhk6RSM1q6XcYsMOHqdsLVA7sotQ=
|
||||
github.com/ebitengine/purego v0.5.0 h1:JrMGKfRIAM4/QVKaesIIT7m/UVjTj5GYhRSQYwfVdpo=
|
||||
github.com/ebitengine/purego v0.5.0/go.mod h1:ah1In8AOtksoNK6yk5z1HTJeUkC1Ez4Wk2idgGslMwQ=
|
||||
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 h1:DACJavvAHhabrF08vX0COfcOBJRhZ8lUbR+ZWIs0Y5g=
|
||||
|
@ -14,13 +16,13 @@ github.com/llgcode/draw2d v0.0.0-20231022063514-1acb54133d2a/go.mod h1:zNlGqkQNL
|
|||
github.com/llgcode/ps v0.0.0-20150911083025-f1443b32eedb h1:61ndUreYSlWFeCY44JxDDkngVoI7/1MVhEl98Nm0KOk=
|
||||
golang.org/x/exp/shiny v0.0.0-20231006140011-7918f672742d h1:grE48C8cjIY0aiHVmFyYgYxxSARQWBABLXKZfQPrBhY=
|
||||
golang.org/x/exp/shiny v0.0.0-20231006140011-7918f672742d/go.mod h1:UH99kUObWAZkDnWqppdQe5ZhPYESUw8I0zVV1uWBR+0=
|
||||
golang.org/x/image v0.13.0 h1:3cge/F/QTkNLauhf2QoE9zp+7sr+ZcL4HnoZmdwg9sg=
|
||||
golang.org/x/image v0.13.0/go.mod h1:6mmbMOeV28HuMTgA6OSRkdXKYw/t5W9Uwn2Yv1r3Yxk=
|
||||
golang.org/x/image v0.14.0 h1:tNgSxAFe3jC4uYqvZdTr84SZoM1KfwdC9SKIFrLjFn4=
|
||||
golang.org/x/image v0.14.0/go.mod h1:HUYqC05R2ZcZ3ejNQsIHQDQiwWM4JBqmm6MKANTp4LE=
|
||||
golang.org/x/mobile v0.0.0-20231006135142-2b44d11868fe h1:lrXv4yHeD9FA8PSJATWowP1QvexpyAPWmPia+Kbzql8=
|
||||
golang.org/x/mobile v0.0.0-20231006135142-2b44d11868fe/go.mod h1:BrnXpEObnFxpaT75Jo9hsCazwOWcp7nVIa8NNuH5cuA=
|
||||
golang.org/x/sync v0.4.0 h1:zxkM55ReGkDlKSM+Fu41A+zmbZuaPVbGMzvvdUPznYQ=
|
||||
golang.org/x/sync v0.4.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y=
|
||||
golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE=
|
||||
golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k=
|
||||
golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
|
||||
golang.org/x/sync v0.5.0 h1:60k92dhOjHxJkrqnwsfl8KuaHbn/5dl0lUPUklKo3qE=
|
||||
golang.org/x/sync v0.5.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
|
||||
golang.org/x/sys v0.14.0 h1:Vz7Qs629MkJkGyHxUlRHizWJRG2j8fbQKjELVSNhy7Q=
|
||||
golang.org/x/sys v0.14.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
|
||||
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
|
||||
|
|
2
input.go
2
input.go
|
@ -23,7 +23,7 @@ func NewInput(prefix string, text string, onSelected func(text string) (handled
|
|||
textColor = Style.InputColor
|
||||
}*/
|
||||
|
||||
i := messeji.NewInputField(Style.TextFont)
|
||||
i := messeji.NewInputField(Style.TextFont, Style.TextFontMutex)
|
||||
i.SetPrefix(prefix)
|
||||
i.SetSuffix("")
|
||||
i.SetText(text)
|
||||
|
|
7
style.go
7
style.go
|
@ -3,6 +3,7 @@ package etk
|
|||
import (
|
||||
"image/color"
|
||||
"log"
|
||||
"sync"
|
||||
|
||||
"github.com/hajimehoshi/ebiten/v2/examples/resources/fonts"
|
||||
"golang.org/x/image/font"
|
||||
|
@ -30,7 +31,8 @@ func defaultFont() font.Face {
|
|||
|
||||
// Attributes represents a default attribute configuration.
|
||||
type Attributes struct {
|
||||
TextFont font.Face
|
||||
TextFont font.Face
|
||||
TextFontMutex *sync.Mutex
|
||||
|
||||
TextColorLight color.RGBA
|
||||
TextColorDark color.RGBA
|
||||
|
@ -51,7 +53,8 @@ type Attributes struct {
|
|||
|
||||
// Style is the current default attribute configuration.
|
||||
var Style = &Attributes{
|
||||
TextFont: defaultFont(),
|
||||
TextFont: defaultFont(),
|
||||
TextFontMutex: &sync.Mutex{},
|
||||
|
||||
TextColorLight: color.RGBA{255, 255, 255, 255},
|
||||
TextColorDark: color.RGBA{0, 0, 0, 255},
|
||||
|
|
2
text.go
2
text.go
|
@ -20,7 +20,7 @@ type Text struct {
|
|||
func NewText(text string) *Text {
|
||||
textColor := Style.TextColorLight
|
||||
|
||||
l := messeji.NewTextField(Style.TextFont)
|
||||
l := messeji.NewTextField(Style.TextFont, Style.TextFontMutex)
|
||||
l.SetText(text)
|
||||
l.SetForegroundColor(textColor)
|
||||
l.SetBackgroundColor(Style.TextBgColor)
|
||||
|
|
Loading…
Reference in a new issue