54 lines
928 B
Go
54 lines
928 B
Go
package buttons
|
|
|
|
import (
|
|
"image/color"
|
|
|
|
"git.vezzani.net/ben/games/common/elements/v1"
|
|
"git.vezzani.net/ben/games/common/elements/v1/blocks"
|
|
"git.vezzani.net/ben/games/common/elements/v1/mouse"
|
|
)
|
|
|
|
type OptFunc func(button *Button)
|
|
|
|
func Core(f elements.OptFunc) OptFunc {
|
|
return func(b *Button) {
|
|
f(&b.Core)
|
|
}
|
|
}
|
|
|
|
func OnClick(f func(ms mouse.State)) OptFunc {
|
|
return func(button *Button) {
|
|
button.onClick = f
|
|
}
|
|
}
|
|
|
|
func OnMouseDown(f func(ms mouse.State)) OptFunc {
|
|
return func(button *Button) {
|
|
button.onMouseDown = f
|
|
}
|
|
}
|
|
|
|
func OnMouseUp(f func(ms mouse.State)) OptFunc {
|
|
return func(button *Button) {
|
|
button.onMouseUp = f
|
|
}
|
|
}
|
|
|
|
func BlockOpt(o blocks.OptFunc) OptFunc {
|
|
return func(s *Button) {
|
|
o(&s.Block)
|
|
}
|
|
}
|
|
|
|
func Label(s string) OptFunc {
|
|
return func(button *Button) {
|
|
button.label = s
|
|
}
|
|
}
|
|
|
|
func LabelColor(color color.Color) OptFunc {
|
|
return func(button *Button) {
|
|
button.color = color
|
|
}
|
|
}
|