Add more doc comments
This commit is contained in:
parent
9f4e8a539a
commit
14fc0ba372
12
backend.go
12
backend.go
|
@ -4,18 +4,26 @@ import "sort"
|
|||
import "image"
|
||||
import "errors"
|
||||
|
||||
// Backend is any Tomo implementation. Backends handle window creation, layout,
|
||||
// rendering, and events so that there can be as many platform-specific
|
||||
// optimizations as possible.
|
||||
type Backend interface {
|
||||
// These methods create new objects. The backend must reject any object
|
||||
// that was not made by it.
|
||||
NewWindow (image.Rectangle) (MainWindow, error)
|
||||
NewBox () Box
|
||||
NewTextBox () TextBox
|
||||
NewCanvasBox () CanvasBox
|
||||
NewContainerBox () ContainerBox
|
||||
|
||||
// Run runs the event loop until Stop() is called, or the backend
|
||||
// experiences a fatal error.
|
||||
Run () error
|
||||
|
||||
// Stop must unblock run.
|
||||
Run () error
|
||||
Stop ()
|
||||
|
||||
// Do performs a callback function in the main thread as soon as
|
||||
// Do performs a callback function in the event loop thread as soon as
|
||||
// possible. This method must be safe to call concurrently.
|
||||
Do (func ())
|
||||
}
|
||||
|
|
|
@ -16,6 +16,8 @@ type Side int; const (
|
|||
SideLeft
|
||||
)
|
||||
|
||||
// Inset represents a rectangle inset that can have a different value for each
|
||||
// side.
|
||||
type Inset [4]int
|
||||
|
||||
// I allows you to create an inset in a CSS-ish way:
|
||||
|
@ -84,11 +86,13 @@ func (inset Inset) Vertical () int {
|
|||
return inset[SideTop] + inset[SideBottom]
|
||||
}
|
||||
|
||||
// Border represents a single border of a box.
|
||||
type Border struct {
|
||||
Width Inset
|
||||
Color [4]color.Color
|
||||
}
|
||||
|
||||
// Align lists basic alignment types.
|
||||
type Align int; const (
|
||||
AlignStart Align = iota // similar to left-aligned text
|
||||
AlignMiddle // similar to center-aligned text
|
||||
|
|
6
tomo.go
6
tomo.go
|
@ -43,32 +43,38 @@ func Stop () {
|
|||
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) (MainWindow, error) {
|
||||
assertBackend()
|
||||
return backend.NewWindow(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()
|
||||
|
|
Loading…
Reference in New Issue