gui

package
v0.0.0-...-5202d7a Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

The gui package is currently expiramental. it provides components and drawing functions to build UIs.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ButtonOptions

type ButtonOptions struct {
	ID                  string
	X, Y, Width, Height int
	Label               string
}

type Components

type Components interface {
	Label(options LabelOptions)
	Button(options ButtonOptions) bool
	Slider(options SliderOptions)
	TextBox(options TextBoxOptions)
	Toggle(options ToggleOptions)
}

type Draw

type Draw struct {
	ScreenWidth, ScreenHeight int
	*Theme
	// contains filtered or unexported fields
}

func (*Draw) Button

func (d *Draw) Button(options ButtonOptions) bool

func (*Draw) DrawCircle

func (d *Draw) DrawCircle(x, y, radius int, op *DrawOptions)

func (*Draw) DrawCurve

func (d *Draw) DrawCurve(start, control, end Position, op *DrawOptions)

func (*Draw) DrawLine

func (d *Draw) DrawLine(points []Position, op *DrawOptions)

func (*Draw) DrawRectangle

func (d *Draw) DrawRectangle(x, y, width, height int, op *DrawOptions)

func (*Draw) DrawSegment

func (d *Draw) DrawSegment(x1, y1, x2, y2 int, op *DrawOptions)

func (*Draw) DrawText

func (d *Draw) DrawText(text string, options *banana.TextRenderOptions)

func (*Draw) DrawTriangle

func (d *Draw) DrawTriangle(x1, y1, x2, y2, x3, y3 int, op *DrawOptions)

func (*Draw) DrawWave

func (d *Draw) DrawWave(waveFunc func(x float64) float64, amplitude, frequency, phase float64, startX, endX, y int, op *DrawOptions)

func (*Draw) GetTheme

func (d *Draw) GetTheme() *Theme

func (*Draw) IsActive

func (d *Draw) IsActive(id string) bool

func (*Draw) IsHot

func (d *Draw) IsHot(id string) bool

func (*Draw) IsOwner

func (d *Draw) IsOwner(id string) bool

func (*Draw) Label

func (d *Draw) Label(options LabelOptions)

func (*Draw) SetActive

func (d *Draw) SetActive(id string)

func (*Draw) SetHot

func (d *Draw) SetHot(id string)

func (*Draw) SetOwner

func (d *Draw) SetOwner(id string)

func (*Draw) SetTheme

func (d *Draw) SetTheme(t *Theme)

func (*Draw) Slider

func (d *Draw) Slider(options SliderOptions)

func (*Draw) TextBox

func (d *Draw) TextBox(options TextBoxOptions)

func (*Draw) Toggle

func (d *Draw) Toggle(options ToggleOptions)

type DrawContext

type DrawContext interface {
	State
	Shapes
	Components
	DrawText(text string, options *banana.TextRenderOptions)
	GetTheme() *Theme
	SetTheme(t *Theme)
}

func NewDrawContext

func NewDrawContext(width, height int) DrawContext

type DrawOptions

type DrawOptions struct {
	Style
}

type LabelOptions

type LabelOptions struct {
	ID     string
	X, Y   int
	Text   string
	Color  color.Color
	PtSize int
}

type Position

type Position struct {
	X, Y, Z int
}

type Shapes

type Shapes interface {
	DrawCircle(x int, y int, radius int, op *DrawOptions)
	DrawLine(points []Position, op *DrawOptions)
	DrawCurve(start, control, end Position, op *DrawOptions)
	DrawWave(waveFunc func(x float64) float64, amplitude, frequency, phase float64, startX, endX, y int, op *DrawOptions)
	DrawRectangle(x int, y int, width int, height int, op *DrawOptions)
	DrawSegment(x1 int, y1 int, x2 int, y2 int, op *DrawOptions)
	DrawTriangle(x1, y1, x2, y2, x3, y3 int, op *DrawOptions)
}

type SliderOptions

type SliderOptions struct {
	ID                  string
	X, Y, Width, Height int
	Value               float32
	MinValue            float32
	MaxValue            float32
	OnChange            func(float32)
}

type State

type State interface {
	SetHot(id string)
	SetActive(id string)
	SetOwner(id string)
	IsHot(id string) bool
	IsActive(id string) bool
	IsOwner(id string) bool
}

type Style

type Style struct {
	FillColor    color.Color
	OutlineColor color.Color
	OutlineSize  int
	CornerRadius int
}

type TextBoxOptions

type TextBoxOptions struct {
	ID          string
	X, Y, Width int
	Text        string
	TextColor   color.Color
	BgColor     color.Color
	Padding     int
	PtSize      int
}

type Theme

type Theme struct {
	BackgroundColor color.Color
	PrimaryColor    color.Color
	SecondaryColor  color.Color
	TextColor       color.Color
	HandleColor     color.Color
}

func DefaultTheme

func DefaultTheme() *Theme

type ToggleOptions

type ToggleOptions struct {
	ID                  string
	X, Y, Width, Height int
	IsOn                bool
	OnChange            func(bool)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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