tomo

package module
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2023 License: GPL-3.0 Imports: 13 Imported by: 14

README

tomo

WIP rewrite of tomo.

This module will serve as a wafer-thin collection of interfaces and glue code so that plugins will be an actual viable concept.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Register

func Register(priority int, factory Factory)

Register registers a backend factory with the given priority number.

func Run

func Run(callback func()) error

Run initializes a backend, runs the specified callback function, and runs the event loop in that order. This function blocks until Stop is called, or the backend experiences a fatal error.

func Stop

func Stop()

Stop stops the backend, unblocking run. Run may be called again after calling Stop.

Types

type Align

type Align int
const (
	AlignStart  Align = iota // similar to left-aligned text
	AlignMiddle              // similar to center-aligned text
	AlignEnd                 // similar to right-aligned text
	AlignEven                // similar to justified text
)

type Backend

type Backend interface {
	NewWindow(image.Rectangle) (MainWindow, error)
	NewBox() Box
	NewTextBox() TextBox
	NewCanvasBox() CanvasBox
	NewContainerBox() ContainerBox

	// Stop must unblock run.
	Run() error
	Stop()

	// Do performs a callback function in the main thread as soon as
	// possible. This method must be safe to call concurrently.
	Do(func())
}

func Initialize

func Initialize() (Backend, error)

Initialize instantiates a backend. The first backend (sorted by priority) that does not throw an error when initialized is used. If no backend could be instantiated, this function returns an error. This function should be called only once.

type Border

type Border struct {
	Width Inset
	Color [4]color.Color
}

type Box

type Box interface {
	Object
	Bounds() image.Rectangle
	InnerBounds() image.Rectangle
	SetBounds(image.Rectangle)
	SetColor(color.Color)
	SetBorder(...Border)
	SetMinimumSize(int, int)
	SetPadding(Inset)

	SetDNDData(data.Data)
	SetDNDAccept(...data.Mime)
	SetFocused(bool)
	SetFocusable(bool)

	Focused() bool
	Modifiers(func()) input.Modifiers
	MousePosition(func()) image.Point

	OnFocusEnter(func()) event.Cookie
	OnFocusLeave(func()) event.Cookie
	OnDNDEnter(func()) event.Cookie
	OnDNDLeave(func()) event.Cookie
	OnDNDDrop(func(data.Data)) event.Cookie
	OnMouseEnter(func()) event.Cookie
	OnMouseLeave(func()) event.Cookie
	OnMouseMove(func()) event.Cookie
	OnMouseDown(func(input.Button)) event.Cookie
	OnMouseUp(func(input.Button)) event.Cookie
	OnScroll(func(deltaX, deltaY float64)) event.Cookie
	OnKeyDown(func(key input.Key, numberPad bool)) event.Cookie
	OnKeyUp(func(key input.Key, numberPad bool)) event.Cookie

	ContentBounds() image.Rectangle
	ScrollTo(image.Point)
	OnContentBoundsChange(func()) event.Cookie
}

func NewBox

func NewBox() Box

type CanvasBox

type CanvasBox interface {
	Box
	SetDrawer(canvas.Drawer)
	Invalidate()
}

func NewCanvasBox

func NewCanvasBox() CanvasBox

type ContainerBox

type ContainerBox interface {
	Box
	SetGap(Gap)
	Add(Object)
	Delete(Object)
	Insert(child Object, before Object)
	Clear()
	Length() int
	At(int) Object
	SetLayout(Layout)
}

func NewContainerBox

func NewContainerBox() ContainerBox

type Factory

type Factory func() (Backend, error)

Factory is a function that attempts to instatiate a backend. If the instantiation process fails at any point, it must clean up all resources and return nil and an error explaining what happened.

type Gap

type Gap image.Point

type Inset

type Inset [4]int

type Layout

type Layout interface {
	Arrange(image.Rectangle, Gap, []Box)
}

type MainWindow

type MainWindow interface {
	Window
	NewChild(image.Rectangle) (Window, error)
}

func NewWindow

func NewWindow(bounds image.Rectangle) MainWindow

type Object

type Object interface {
	Box() Box
}

type TextBox

type TextBox interface {
	Box
	SetTextColor(color.Color)
	SetFace(font.Face)
	SetHAlign(Align)
	SetVAlign(Align)
}

func NewTextBox

func NewTextBox() TextBox

type Window

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)
	Show()
	Hide()
	Close()
	OnClose(func()) event.Cookie
}

Directories

Path Synopsis
Canvas defines a standard interface for images that support drawing primitives.
Canvas defines a standard interface for images that support drawing primitives.
Package data provides operations to deal with arbitrary data and MIME types.
Package data provides operations to deal with arbitrary data and MIME types.
Package event provides a system for broadcasting events to multiple event handlers.
Package event provides a system for broadcasting events to multiple event handlers.
Package input defines keyboard and mouse code constants.
Package input defines keyboard and mouse code constants.

Jump to

Keyboard shortcuts

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