User interface toolkit for Go with support for SDL2 and HTML Canvas render targets.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

51 lines
1.4 KiB

package ui_test
import (
// Example of using the Supervisor Window Manager.
func ExampleWindow() {
mw, err := ui.NewMainWindow("Window Manager Example", 800, 600)
if err != nil {
// Create a window as normal.
window := ui.NewWindow("Hello world!")
Width: 320,
Height: 240,
// Configure its title bar colors (optional; these are the defaults)
window.ActiveTitleBackground = render.Blue
window.ActiveTitleForeground = render.White
window.InactiveTitleBackground = render.DarkGrey
window.InactiveTitleForeground = render.Grey
// Configure its window buttons (optional); default has no window buttons.
// Window buttons are only functional in managed windows.
window.SetButtons(ui.CloseButton | ui.MaximizeButton | ui.MinimizeButton)
// Add some widgets to the window.
btn := ui.NewButton("My Button", ui.NewLabel(ui.Label{
Text: "Hello world!",
window.Place(btn, ui.Place{
Center: true,
Middle: true,
// To enable the window manager controls, the key step is to give it
// the Supervisor so it can be managed:
// Each loop you must then:
// - Call Supervisor.Loop() as normal to handle events.
// - Call Supervisor.Present() to draw the managed windows.
// MainLoop() of the MainWindow does this for you.