system

package
v0.9.3 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2026 License: GPL-3.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BackendLink interface {
	// NewTexture creates a new texture from an image.
	NewTexture(image.Image) canvas.TextureCloser
	// NewSurface creates a new surface with the specified bounds.
	NewSurface(image.Rectangle) (SurfaceLink, error)
}

BackendLink allows the System to call up into the tomo.Backend implementation which contains it in order to do things such as create new textures.

type Hierarchy

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

Hierarchy is coupled to a tomo.Window implementation, and manages a tree of Boxes.

func (*Hierarchy) AfterEvent

func (this *Hierarchy) AfterEvent()

AfterEvent should be called at the end of every event cycle.

func (*Hierarchy) Close

func (this *Hierarchy) Close()

Close closes the Hierarchy. This should be called when the Window that contains it has been closed.

func (*Hierarchy) Empty

func (this *Hierarchy) Empty() bool

Empty returns whether or not the root of the Hierarchy is nil.

func (*Hierarchy) HandleFocusChange

func (this *Hierarchy) HandleFocusChange(focused bool)

HandleFocusChange sets whether or not the window containing this Hierarchy has input focus.

func (*Hierarchy) HandleKeyDown

func (this *Hierarchy) HandleKeyDown(key input.Key, numberPad bool)

HandleKeyDown sends a key down event to the currently focused Box. If the event which triggers this comes with modifier key information, HandleModifiers must be called *before* HandleKeyDown.

func (*Hierarchy) HandleKeyUp

func (this *Hierarchy) HandleKeyUp(key input.Key, numberPad bool)

HandleKeyUp sends a key up event to the currently focused Box. If the event which triggers this comes with modifier key information, HandleModifiers must be called *before* HandleKeyUp.

func (*Hierarchy) HandleModifiers

func (this *Hierarchy) HandleModifiers(modifiers input.Modifiers)

HandleModifiers sets the modifier keys that are currently being pressed.

func (*Hierarchy) HandleMouseDown

func (this *Hierarchy) HandleMouseDown(button input.Button)

HandleMouseDown sends a mouse down event to the Boxes positioned underneath the mouse cursor and marks them as being "dragged" by that mouse button, starting at the first Box to mask events and ending at the first box to catch the event. If the event which triggers this comes with mouse position information, HandleMouseMove must be called *before* HandleMouseDown.

func (*Hierarchy) HandleMouseMove

func (this *Hierarchy) HandleMouseMove(position image.Point)

HandleMouseMove sends a mouse move event to any Boxes currently being "dragged" by a mouse button. If none are, it sends the event to the Boxes which are underneath the mouse pointer, starting at the first Box to mask events and ending at the first box to catch the event.

func (*Hierarchy) HandleMouseUp

func (this *Hierarchy) HandleMouseUp(button input.Button)

HandleMouseUp sends a mouse up event to the Boxes currently being "dragged" by the specified mouse button, and marks them as being "not dragged" by that mouse button. If the event which triggers this comes with mouse position information, HandleMouseMove must be caleld *before* HandleMouseUp

func (*Hierarchy) HandleScroll

func (this *Hierarchy) HandleScroll(x, y float64)

HandleScroll sends a scroll event to the Box currently underneath the mouse cursor. If the event which triggers this comes with mouse position information, HandleMouseMove must be called *before* HandleScroll.

func (*Hierarchy) MinimumSize

func (this *Hierarchy) MinimumSize() image.Point

MinimumSize returns the minimum size of the Hierarchy.

func (*Hierarchy) Modifiers

func (this *Hierarchy) Modifiers() input.Modifiers

Modifiers returns the current modifier keys being held.

func (*Hierarchy) MousePosition

func (this *Hierarchy) MousePosition() image.Point

MousePosition returns the current mouse position.

func (*Hierarchy) SetCanvas

func (this *Hierarchy) SetCanvas(can canvas.Canvas)

SetCanvas sets the held canvas of the Hierarchy that all boxes within it will draw to. The Hierarchy will use the canvas.Canvas's bounds to lay itself out.

func (*Hierarchy) SetRoot

func (this *Hierarchy) SetRoot(root tomo.Box)

SetRoot sets the root Box of the hierarchy.

type SurfaceLink interface {
	io.Closer
	GetSurface() any
	SetSize(image.Rectangle)
}

SurfaceLink wraps a Surface created by the backend implementation, allowing the System a higher level of control over it.

type System

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

System is coupled to a tomo.Backend implementation, and manages Hierarchies and Boxes.

func New

func New(link BackendLink) *System

New creates a new System.

func (*System) NewBox

func (this *System) NewBox() tomo.Box

func (*System) NewCanvasBox

func (this *System) NewCanvasBox() tomo.CanvasBox

func (*System) NewContainerBox

func (this *System) NewContainerBox() tomo.ContainerBox

func (*System) NewHierarchy

func (this *System) NewHierarchy(link WindowLink) *Hierarchy

NewHierarchy creates a new Hierarchy.

func (*System) NewSurfaceBox

func (this *System) NewSurfaceBox() (tomo.SurfaceBox, error)

func (*System) NewTextBox

func (this *System) NewTextBox() tomo.TextBox

func (*System) SetFaceSet

func (this *System) SetFaceSet(faceSet style.FaceSet)

SetFaceSet sets the face set that provides font faces.

func (*System) SetIconSet

func (this *System) SetIconSet(iconSet style.IconSet)

SetIconSet sets the icon set that provides icon textures, and notifies objects that the icons have changed.

func (*System) SetStyle

func (this *System) SetStyle(style *style.Style)

SetStyle sets the style that is applied to objects, and notifies them that the style has changed.

type WindowLink interface {
	// GetWindow returns the tomo.Window containing the Hierarchy.
	GetWindow() tomo.Window
	// PushRegion pushes a region of the held canvas.Canvas to the screen.
	PushRegion(image.Rectangle)
	// PushAll pushes the entire canvas.Canvas to the screen.
	PushAll()
	// NotifyMinimumSizeChange notifies the tomo.Window that the minimum
	// size of the Hierarchy has changed, and if necessary, a resize should
	// be requested.
	NotifyMinimumSizeChange()
}

WindowLink allows the Hierarchy to call up into the tomo.Window implementation which contains it. This should be a separate entity from the tomo.Window.

Source Files

  • attribute.go
  • box.go
  • boxquerier.go
  • canvasbox.go
  • containerbox.go
  • event.go
  • hierarchy.go
  • internal-iface.go
  • style.go
  • surfacebox.go
  • system.go
  • textbox.go

Jump to

Keyboard shortcuts

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