ui

package module
v0.0.0-...-b80102e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 5, 2017 License: BSD-3-Clause Imports: 2 Imported by: 0

README

GoDoc Go Report Card

go-ui/ui

Experimental UI framework for Go

ATTENTION: This framework is not complete and should not be used in anything other than expriments. The API is still in flux and may change at any point.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DriverInitializationError

type DriverInitializationError struct {
	// contains filtered or unexported fields
}

DriverInitializationError is returned when the

func (DriverInitializationError) Error

Error returns a string with the description of the error

type DummyView

type DummyView struct{}

DummyView implements a basic view that does nothing.

func (DummyView) Dirty

func (DummyView) Dirty() bool

Dirty always returns false.

func (DummyView) Event

func (DummyView) Event(_ events.Event)

Event ignores all events.

func (DummyView) Render

func (DummyView) Render(_ drivers.Surface)

Render does not render anything.

type NoMatchingDriverError

type NoMatchingDriverError struct {
	// contains filtered or unexported fields
}

NoMatchingDriverError is returned when New could not find a driver matching the name

func (NoMatchingDriverError) Error

func (n NoMatchingDriverError) Error() string

Error returns a string with the description of the error

type UI

type UI struct {
	// contains filtered or unexported fields
}

UI offers functionality to write UIs in Go.

func New

func New(name string) (*UI, error)

New creates a new UI instance with the driver that implements name

func (*UI) NewWindow

func (ui *UI) NewWindow(cf ...WindowConfig) *Window

NewWindow creates a new window for the UI.

func (*UI) Release

func (ui *UI) Release() error

Release closes all windows that were opened by this instance of UI and releases all resouces allocated by it. This instance can not be used afterwards.

type View

type View interface {
	// Dirty signals the window that this view is dirty and should be repainted.
	Dirty() bool

	// Render renders the view into an image, if the view has not been resized, this will reuse the image.
	Render(drivers.Surface)

	// Event received events from the window, so the view can react to them.
	Event(events.Event)
}

View is the abstraction of a thing(tm) that can render in a window and can reveive events from a window.

type Window

type Window struct {
	OnResize  func()
	OnMove    func()
	OnKeyDown func(events.KeyEvent)
	// contains filtered or unexported fields
}

Window holds the information of a window that is displayed on the screen.

type WindowConfig

type WindowConfig func(*windowConfig)

WindowConfig represents a configuration function that sets specific properties for the window.

func WithParentWindow

func WithParentWindow(w *Window) WindowConfig

WithParentWindow sets a parent window for a new window.

func WithSize

func WithSize(w, h int) WindowConfig

WithSize sets the size for a new window.

func WithTitle

func WithTitle(t string) WindowConfig

WithTitle sets the title for a new window.

func WithType

func WithType(t WindowType) WindowConfig

WithType sets the window type for a new window.

func WithView

func WithView(v View) WindowConfig

WithView sets the initial view for a new window.

type WindowType

type WindowType byte

WindowType indiates the type of the window, this can be used to create borderless windows.

const (
	// NormalWindow indicates that the window has normal window decorations, this is used for most main windows.
	NormalWindow WindowType = iota

	// DialogWindow indicates that the window is a dialog, like a message box.
	DialogWindow

	// SplashWindow indicates a borderless window that is often displayed while the main application is loading.
	SplashWindow

	// MenuWindow indicates that the window is a tooltip or pop-up menu.
	MenuWindow
)

Directories

Path Synopsis
dummy
Package dummy contains the dummy driver.
Package dummy contains the dummy driver.
x11

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL