render

package
v0.0.0-...-b5b2f04 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2024 License: Apache-2.0 Imports: 4 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

type Cache[T Renderable] struct {
	// contains filtered or unexported fields
}

Cache define a Renderable wrapper that adds caching to it. At the moment only layout.Layout is cached as terminal screen is cleared on every render.

func NewCache

func NewCache[T Renderable](renderable T) Cache[T]

NewCache returns a new Cache that wraps the given Renderable.

func (*Cache[T]) Draw

func (c *Cache[T]) Draw(surface draw.Surface)

Draw implements draw.Drawer.

func (*Cache[T]) IsDirty

func (c *Cache[T]) IsDirty() bool

IsDirty implements Renderable.

func (*Cache[T]) Layout

func (c *Cache[T]) Layout(co layout.Constraint) geometry.Size

Layout implements layout.Layout. If cache is dirty or constraint differ from constraint of previous layout, Layout call is forwarded to wrapped renderable.

func (*Cache[T]) MarkDirty

func (c *Cache[T]) MarkDirty()

MarkDirty implements Renderable.

func (*Cache[T]) Unwrap

func (c *Cache[T]) Unwrap() T

Unwrap returns the wrapped renderable.

type ComposedRenderable

type ComposedRenderable struct {
	VoidRenderable
	LayoutLayout
	draw.Drawer
}

ComposedRenderable define a Renderable composed of a VoidRenderable, a layout.Layout and a draw.Drawer.

func NewComposedRenderable

func NewComposedRenderable(layout layout.Layout, drawer draw.Drawer) *ComposedRenderable

func (*ComposedRenderable) Draw

func (cr *ComposedRenderable) Draw(surface draw.Surface)

Draw implements Renderable.

func (*ComposedRenderable) Layout

Layout implements Renderable.

func (*ComposedRenderable) Renderable

func (cr *ComposedRenderable) Renderable() Renderable

Renderable implements render.RenderableAccessor.

type LayoutLayout

type LayoutLayout = layout.Layout

type Renderable

type Renderable interface {
	layout.Layout
	draw.Drawer

	// IsDirty return whether renderable needs to be rendered.
	IsDirty() bool

	// MarkDirty marks the renderable as dirty. It a tree of renderable,
	// implementation may also mark all ancestor of a node as dirty.
	MarkDirty()
}

Renderable define any object that can be rendered.

type RenderableAccessor

type RenderableAccessor interface {
	Renderable() Renderable
}

RenderableAccessor define any object owning a Renderable.

type VoidRenderable

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

VoidRenderable define a minimal renderable with a size of zero. It handles efficiently dirty state management and is ideal for embedding into more complex renderable.

func NewVoidRenderable

func NewVoidRenderable(target events.Target) VoidRenderable

NewVoidRenderable returns a new VoidRenderable.

func (*VoidRenderable) Draw

func (vr *VoidRenderable) Draw(draw.Surface)

Draw implements Renderable. VoidRenderable doesn't draw anything but change it's internal state to clean (not dirty).

func (*VoidRenderable) IsDirty

func (vr *VoidRenderable) IsDirty() bool

IsDirty implements Renderable.

func (*VoidRenderable) Layout

Layout implements Renderable. VoidRenderable always return a size of 0.

func (*VoidRenderable) MarkDirty

func (vr *VoidRenderable) MarkDirty()

MarkDirty implements Renderable.

func (*VoidRenderable) Renderable

func (vr *VoidRenderable) Renderable() Renderable

Renderable implements RenderableAccessor.

Jump to

Keyboard shortcuts

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