zntg/action.go
Sander Schobers cdfb863ab0 Added SDL backend.
Added Action{,s}. List of actions that can be used to defer cleanup code (see NewRenderer implementations).
Added TextInputEvent (replaces the old KeyPressEvent) and added to new events KeyDown & KeyUp.
Added VSync to NewRendererOptions.
Removed IconScale from button.
Added ImageSource interface that replaces the Image/Texture method on the Texture interface. This makes converting back a texture to an image optional (since this is atypical for a hardware texture for instance).
Added new KeyModifier: OSCommand (Windows/Command key).
Added KeyState that can keep the state of keys (pressed or not).
Added KeyEnter, representing the Enter key.
Changed signatures of CreateTexture methods in Renderer.
Changed signatures of icon related method (removed factories).
Basic example now depends on sdlgui.
2020-05-15 09:20:44 +02:00

38 lines
496 B
Go

package zntg
type Action func()
func (a Action) Err() ActionErr {
return func() error {
a()
return nil
}
}
type ActionErr func() error
type Actions []ActionErr
func (a Actions) Add(fn Action) Actions {
return a.AddErr(fn.Err())
}
func (a Actions) AddErr(fn ActionErr) Actions {
return append(a, fn)
}
func (a Actions) Do() {
for _, a := range a {
a()
}
}
func (a Actions) DoErr() error {
for _, a := range a {
if err := a(); err != nil {
return err
}
}
return nil
}