Added useful run methods to ParentHooks
This commit is contained in:
parent
7c6b9317fc
commit
c94329e273
23
tomo.go
23
tomo.go
@ -43,6 +43,29 @@ type ParentHooks struct {
|
||||
SelectionRequest func ()
|
||||
}
|
||||
|
||||
// RunDraw runs the Draw hook if it is not nil. If it is nil, it does nothing.
|
||||
func (hooks ParentHooks) RunDraw (region Image) {
|
||||
if hooks.Draw != nil {
|
||||
hooks.Draw(region)
|
||||
}
|
||||
}
|
||||
|
||||
// RunMinimumSizeChange runs the MinimumSizeChange hook if it is not nil. If it
|
||||
// is nil, it does nothing.
|
||||
func (hooks ParentHooks) RunMinimumSizeChange (width, height int) {
|
||||
if hooks.MinimumSizeChange != nil {
|
||||
hooks.MinimumSizeChange(width, height)
|
||||
}
|
||||
}
|
||||
|
||||
// RunSelectionRequest runs the SelectionRequest hook if it is not nil. If it is
|
||||
// nil, it does nothing.
|
||||
func (hooks ParentHooks) RunSelectionRequest () {
|
||||
if hooks.SelectionRequest != nil {
|
||||
hooks.SelectionRequest()
|
||||
}
|
||||
}
|
||||
|
||||
// Element represents a basic on-screen object.
|
||||
type Element interface {
|
||||
// Element must implement the Image interface. Elements should start out
|
||||
|
Reference in New Issue
Block a user