okay giant ux refactor to hopefully make it cleaner
This commit is contained in:
@@ -1,32 +1,50 @@
|
||||
package buttons
|
||||
|
||||
import (
|
||||
"image/color"
|
||||
|
||||
"git.vezzani.net/ben/games/common/elements/v1/blocks"
|
||||
"git.vezzani.net/ben/games/common/elements/v1/mouse"
|
||||
)
|
||||
|
||||
type Option func(button *Button)
|
||||
type OptFunc func(button *Button)
|
||||
|
||||
func OnClick(f func(ms mouse.State)) Option {
|
||||
type Option interface {
|
||||
OptFunc | blocks.OptFunc
|
||||
}
|
||||
|
||||
func OnClick(f func(ms mouse.State)) OptFunc {
|
||||
return func(button *Button) {
|
||||
button.onClick = f
|
||||
}
|
||||
}
|
||||
|
||||
func OnMouseDown(f func(ms mouse.State)) Option {
|
||||
func OnMouseDown(f func(ms mouse.State)) OptFunc {
|
||||
return func(button *Button) {
|
||||
button.onMouseDown = f
|
||||
}
|
||||
}
|
||||
|
||||
func OnMouseUp(f func(ms mouse.State)) Option {
|
||||
func OnMouseUp(f func(ms mouse.State)) OptFunc {
|
||||
return func(button *Button) {
|
||||
button.onMouseUp = f
|
||||
}
|
||||
}
|
||||
|
||||
func BlockOpt(o blocks.Option) Option {
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user