Nasin has its own registry system that is way more flexible than what was in this module, that ought to be used instead.
75 lines
2.0 KiB
Go
75 lines
2.0 KiB
Go
package tomo
|
|
|
|
import "image"
|
|
import "git.tebibyte.media/tomo/tomo/canvas"
|
|
|
|
// Stop stops the backend, unblocking run. Run may be called again after calling
|
|
// Stop.
|
|
func Stop () {
|
|
assertBackend()
|
|
backend.Stop()
|
|
|
|
backendLock.Lock()
|
|
backend = nil
|
|
backendLock.Unlock()
|
|
}
|
|
|
|
// Do performs a callback function in the event loop thread as soon as possible.
|
|
func Do (callback func ()) {
|
|
backendLock.Lock()
|
|
if backend != nil { backend.Do(callback) }
|
|
backendLock.Unlock()
|
|
}
|
|
|
|
// NewWindow creates and returns a window within the specified bounds on screen.
|
|
func NewWindow (bounds image.Rectangle) (Window, error) {
|
|
assertBackend()
|
|
return backend.NewWindow(bounds)
|
|
}
|
|
|
|
// NewPlainWindow is like NewWindow, but it creates an undecorated window that
|
|
// does not appear in window lists. It is intended for creating things like
|
|
// docks, panels, etc.
|
|
func NewPlainWindow (bounds image.Rectangle) (Window, error) {
|
|
assertBackend()
|
|
return backend.NewPlainWindow(bounds)
|
|
}
|
|
|
|
// NewBox creates and returns a basic Box.
|
|
func NewBox () Box {
|
|
assertBackend()
|
|
return backend.NewBox()
|
|
}
|
|
|
|
// NewTextBox creates and returns a Box that can display text.
|
|
func NewTextBox () TextBox {
|
|
assertBackend()
|
|
return backend.NewTextBox()
|
|
}
|
|
|
|
// NewCanvasBox creates and returns a Box that can display custom graphics.
|
|
func NewCanvasBox () CanvasBox {
|
|
assertBackend()
|
|
return backend.NewCanvasBox()
|
|
}
|
|
|
|
// NewContainerBox creates and returns a Box that can contain other boxes.
|
|
func NewContainerBox () ContainerBox {
|
|
assertBackend()
|
|
return backend.NewContainerBox()
|
|
}
|
|
|
|
// NewTexture creates a new texture from an image. When no longer in use, it
|
|
// must be freed using Close().
|
|
func NewTexture (source image.Image) canvas.TextureCloser {
|
|
assertBackend()
|
|
return backend.NewTexture(source)
|
|
}
|
|
|
|
// NewCanvas creates a new canvas with the specified bounds. When no longer in
|
|
// use, it must be freed using Close().
|
|
func NewCanvas (bounds image.Rectangle) canvas.CanvasCloser {
|
|
assertBackend()
|
|
return backend.NewCanvas(bounds)
|
|
}
|