-
-
Notifications
You must be signed in to change notification settings - Fork 369
Home
Maxence Charriere edited this page Nov 26, 2016
·
37 revisions
Package to build multiplatform apps with Go, HTML and CSS.
A component is a struct that represents a graphic element. It implements the app.Componer interface.
type Componer interface {
Render() string
}
The Render method returns an HTML markup that describes the graphic interface. Components can be encapsulated to make complex UIs. They are displayed by being mounted into contexts.
A context is an application element which display a graphical user interface. It can be a window, a menu, a dock, etc...
It implements the interface app.Contexter which defines their available interactions.
type Contexter interface {
// Mounts the component and renders it in the context.
Mount(c Componer)
// If applicable, returns the position of the context.
Position() (x float64, y float64)
// If applicable, moves the context.
Move(x float64, y float64)
// If applicable, returns the size of the context.
Size() (width float64, height float64)
// If applicable, resizes the context.
Resize(width float64, height float64)
// If applicable, set the icon targeted by path.
SetIcon(path string)
// If applicable, set the badge with v.
SetBadge(v interface{})
// If applicable, closes the context.
Close()
// ...
}
// Component.
type Hello struct {
Placeholder interface{}
}
func (h *Hello) Render() string {
return `<div>Hello World</div>`
}
// Create a window and mounts the Hello Component.
func main() {
app.OnLaunch = func() {
win := app.NewWindow(app.Window{
Title: "Hello World",
Width: 1280,
Height: 720,
})
hello := &Hello{}
win.Mount(hello)
}
app.Run()
}