layout

package
v0.0.0-...-17e2f5f Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2025 License: Apache-2.0 Imports: 11 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseComponent

type BaseComponent struct {
	Type string
	// contains filtered or unexported fields
}

func (*BaseComponent) Align

func (c *BaseComponent) Align(s string)

func (*BaseComponent) Bounds

func (c *BaseComponent) Bounds() image.Rectangle

func (*BaseComponent) Draw

func (c *BaseComponent) Draw(ctx draw2d.GraphicContext)

func (*BaseComponent) Fill

func (c *BaseComponent) Fill(col color.Color)

func (*BaseComponent) Font

func (c *BaseComponent) Font(font string)

func (*BaseComponent) GetInsets

func (c *BaseComponent) GetInsets() (int, int, int, int)

func (*BaseComponent) GetType

func (c *BaseComponent) GetType() string

func (*BaseComponent) Height

func (c *BaseComponent) Height() int

func (*BaseComponent) Inset

func (c *BaseComponent) Inset(inset int)

func (*BaseComponent) InsetBounds

func (c *BaseComponent) InsetBounds() image.Rectangle

func (*BaseComponent) IsUpdateRequired

func (c *BaseComponent) IsUpdateRequired() bool

func (*BaseComponent) Layout

func (c *BaseComponent) Layout(_ draw2d.GraphicContext) bool

Layout the component. returns true if it has changed something

func (*BaseComponent) LineWidth

func (c *BaseComponent) LineWidth(f float64)

func (*BaseComponent) SetBounds

func (c *BaseComponent) SetBounds(b image.Rectangle)

func (*BaseComponent) SetPainter

func (c *BaseComponent) SetPainter(painter Painter)

func (*BaseComponent) SetType

func (c *BaseComponent) SetType(t string)

func (*BaseComponent) Stroke

func (c *BaseComponent) Stroke(col color.Color)

func (*BaseComponent) StrokeFill

func (c *BaseComponent) StrokeFill(col color.Color)

func (*BaseComponent) Width

func (c *BaseComponent) Width() int

type Component

type Component interface {
	GetType() string
	Bounds() image.Rectangle
	SetBounds(image.Rectangle)
	Draw(draw2d.GraphicContext)
	Layout(draw2d.GraphicContext) bool
	IsUpdateRequired() bool
	Width() int
	Height() int
	Inset(int)
	Align(string)
	Font(string)
	SetType(string)
	Fill(color.Color)
	Stroke(color.Color)
	StrokeFill(color.Color)
	LineWidth(float64)
}

Component is an entity within a frame

type Container

type Container interface {
	Component
	Add(Component) Container
	IsEmpty() bool
}

func ColScaleContainer

func ColScaleContainer(scales ...float64) Container

ColScaleContainer lays out it's components based on specific scaling horizontally

func FixedContainer

func FixedContainer(rect image.Rectangle) Container

func RowContainer

func RowContainer() Container

RowContainer contains components vertically.

func TitledContainer

func TitledContainer(title string) Container

type Image

type Image struct {
	BaseComponent
	// contains filtered or unexported fields
}

func NewImage

func NewImage() *Image

func (*Image) Image

func (i *Image) Image() image.Image

func (*Image) Layout

func (i *Image) Layout(ctx draw2d.GraphicContext) bool

func (*Image) SetImage

func (i *Image) SetImage(img image.Image)

type Painter

type Painter func(*draw2dimg.GraphicContext)

type Text

type Text struct {
	BaseComponent
	// contains filtered or unexported fields
}

Text is a simple Component which renders a formatted string.

func NewText

func NewText(format string, args ...any) *Text

NewText creates a new Text component using the provided string. The string is passed to fmt.Sprintf() so it uses the same formatting.

func (*Text) Args

func (t *Text) Args(args ...any) *Text

Args allows the args passed to NewText to be replaced, causing the component's output to change

func (*Text) Layout

func (t *Text) Layout(ctx draw2d.GraphicContext) bool

func (*Text) Pos

func (t *Text) Pos(x, y float64) *Text

func (*Text) String

func (t *Text) String() string

type Value

type Value struct {
	BaseComponent
	// contains filtered or unexported fields
}

Value is similar to Text except it consists of a Label as well as the text output. The label is rendered on the left of the component, whilst the value on the right

func NewValue

func NewValue(label, format string, args ...any) *Value

func (*Value) Args

func (t *Value) Args(args ...any) *Value

func (*Value) Layout

func (t *Value) Layout(ctx draw2d.GraphicContext) bool

func (*Value) Pos

func (t *Value) Pos(x, y float64) *Value

func (*Value) String

func (t *Value) String() string

Jump to

Keyboard shortcuts

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