Compare commits

...

6 Commits

5 changed files with 15 additions and 5 deletions

View File

@@ -5,7 +5,7 @@ import "image"
import "errors"
type Backend interface {
NewWindow (image.Rectangle) MainWindow
NewWindow (image.Rectangle) (MainWindow, error)
NewBox () Box
NewTextBox () TextBox
NewCanvasBox () CanvasBox

View File

@@ -1,3 +1,5 @@
// Canvas defines a standard interface for images that support drawing
// primitives.
package canvas
import "image"
@@ -30,8 +32,11 @@ type StrokeAlign int; const (
// have multiple pens associated with it, each maintaining their own drawing
// context.
type Pen interface {
// Draw draws a path
Draw (points ...image.Point)
// Rectangle draws a rectangle
Rectangle (image.Rectangle)
// Path draws a path
Path (points ...image.Point)
Closed (bool) // if the path is closed
Cap (Cap) // line cap stype

View File

@@ -1,3 +1,5 @@
// Package event provides a system for broadcasting events to multiple event
// handlers.
package event
// A cookie is returned when you add an event handler so you can remove it

View File

@@ -93,15 +93,16 @@ type ContainerBox interface {
type Window interface {
SetRoot (Object)
SetTitle (string)
SetIcon (sizes []image.Image)
NewMenu (image.Rectangle) (Window, error)
NewModal (image.Rectangle) (Window, error)
Widget () (Window, error)
Copy (data.Data)
Paste (callback func (data.Data, error), accept ...data.Mime)
Close ()
Show ()
Hide ()
Close ()
OnClose (func ()) event.Cookie
}

View File

@@ -9,6 +9,8 @@ var backend Backend
// event loop in that order. This function blocks until Stop is called, or the
// backend experiences a fatal error.
func Run (callback func ()) error {
loadPlugins()
if backend != nil {
return errors.New("there is already a backend running")
}
@@ -33,7 +35,7 @@ func Stop () {
backend = nil
}
func NewWindow (bounds image.Rectangle) MainWindow {
func NewWindow (bounds image.Rectangle) (MainWindow, error) {
assertBackend()
return backend.NewWindow(bounds)
}