ui

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2023 License: MIT Imports: 11 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MouseInBounds added in v0.1.2

func MouseInBounds(window *glfw.Window, area Area) bool

Types

type Alignment

type Alignment byte

Alignment

const (
	AlignmentCenter      Alignment = 0
	AlignmentTop         Alignment = 1
	AlignmentBottom      Alignment = 2
	AlignmentLeft        Alignment = 3
	AlignmentRight       Alignment = 4
	AlignmentTopLeft     Alignment = 5
	AlignmentTopRight    Alignment = 6
	AlignmentBottomLeft  Alignment = 7
	AlignmentBottomRight Alignment = 8
)

type Area added in v0.1.2

type Area struct {
	Top      float64
	Right    float64
	Bottom   float64
	Left     float64
	Function func()
}

func Draw

func Draw(img *image.RGBA, window *glfw.Window, element UIElement) Area

func (Area) ToString added in v0.1.2

func (a Area) ToString() string

type Button

type Button struct {
	Properties Properties
	Style      Style
	Child      UIElement
	Function   func()
	Image      string
	HoverImage string
}

func (Button) Draw

func (button Button) Draw(img *image.RGBA, window *glfw.Window) []Area

func (Button) GetProperties

func (button Button) GetProperties() Properties

func (Button) Initialize

func (button Button) Initialize(skip SkipAlignment) UIElement

func (Button) SetParent

func (button Button) SetParent(parent *Properties) UIElement

func (Button) SetProperties

func (button Button) SetProperties(size Size, center Point) UIElement

func (Button) ToString added in v0.1.2

func (button Button) ToString() string

type Column

type Column struct {
	Properties Properties
	Style      Style
	Children   []UIElement
	Image      string
}

func (Column) Draw

func (column Column) Draw(img *image.RGBA, window *glfw.Window) []Area

func (Column) GetProperties

func (column Column) GetProperties() Properties

func (Column) Initialize

func (column Column) Initialize(skip SkipAlignment) UIElement

func (Column) SetParent

func (column Column) SetParent(parent *Properties) UIElement

func (Column) SetProperties

func (column Column) SetProperties(size Size, center Point) UIElement

func (Column) ToString added in v0.1.2

func (column Column) ToString() string

type Container added in v0.1.2

type Container struct {
	Properties Properties
	Style      Style
	Child      UIElement
	Image      string
}

func (Container) Draw added in v0.1.2

func (container Container) Draw(img *image.RGBA, window *glfw.Window) []Area

func (Container) GetProperties added in v0.1.2

func (container Container) GetProperties() Properties

func (Container) Initialize added in v0.1.2

func (container Container) Initialize(skip SkipAlignment) UIElement

func (Container) SetParent added in v0.1.2

func (container Container) SetParent(parent *Properties) UIElement

func (Container) SetProperties added in v0.1.2

func (container Container) SetProperties(size Size, center Point) UIElement

func (Container) ToString added in v0.1.2

func (container Container) ToString() string

type Padding

type Padding struct {
	Scale  ScaleType
	Top    int
	Right  int
	Bottom int
	Left   int
}

Padding

func PaddingEqual

func PaddingEqual(scale ScaleType, padding int) Padding

func PaddingSideBySide

func PaddingSideBySide(scale ScaleType, top, right, bottom, left int) Padding

func PaddingSymmetric

func PaddingSymmetric(scale ScaleType, vertical, horizontal int) Padding

type Point

type Point struct {
	X int
	Y int
}

func (Point) ToString added in v0.1.2

func (p Point) ToString() string

type Properties

type Properties struct {
	Center      Point
	Size        Size
	Alignment   Alignment
	Padding     Padding
	Parent      *Properties
	Initialized bool
	Skip        SkipAlignment
	Type        UIType
}

func DefaultProperties

func DefaultProperties(props Properties, skip SkipAlignment, uitype UIType) Properties

func (Properties) ToString added in v0.1.2

func (p Properties) ToString() string

type Row

type Row struct {
	Properties Properties
	Style      Style
	Children   []UIElement
	Image      string
}

func (Row) Draw

func (row Row) Draw(img *image.RGBA, window *glfw.Window) []Area

func (Row) GetProperties

func (row Row) GetProperties() Properties

func (Row) Initialize

func (row Row) Initialize(skip SkipAlignment) UIElement

func (Row) SetParent

func (row Row) SetParent(parent *Properties) UIElement

func (Row) SetProperties

func (row Row) SetProperties(size Size, center Point) UIElement

func (Row) ToString added in v0.1.2

func (row Row) ToString() string

type ScaleType

type ScaleType bool
const (
	ScalePixel    ScaleType = true
	ScaleRelative ScaleType = false
)

type Size

type Size struct {
	Scale  ScaleType
	Width  int
	Height int
}

Size

func (Size) ToString added in v0.1.2

func (s Size) ToString() string

type SkipAlignment

type SkipAlignment byte
const (
	SkipAlignmentNone  SkipAlignment = 0
	SkipAlignmentHoriz SkipAlignment = 1
	SkipAlignmentVert  SkipAlignment = 2
)

type Style

type Style struct {
	Color color.Color
}

func DefaultStyle added in v0.1.2

func DefaultStyle(style Style) Style

func (Style) ToString added in v0.1.2

func (s Style) ToString() string

type StyleText

type StyleText struct {
	Font      string
	FontSize  int
	FontColor color.Color
}

func DefaultStyleText added in v0.1.2

func DefaultStyleText(style StyleText) StyleText

func (StyleText) ToString added in v0.1.2

func (s StyleText) ToString() string

type Text

type Text struct {
	Properties Properties
	StyleText  StyleText
}

func (Text) Draw

func (text Text) Draw(img *image.RGBA, window *glfw.Window) []Area

func (Text) GetProperties

func (text Text) GetProperties() Properties

func (Text) Initialize

func (text Text) Initialize(skip SkipAlignment) UIElement

func (Text) SetParent

func (text Text) SetParent(parent *Properties) UIElement

func (Text) SetProperties

func (text Text) SetProperties(size Size, center Point) UIElement

func (Text) ToString added in v0.1.2

func (text Text) ToString() string

type UIElement

type UIElement interface {
	Draw(img *image.RGBA, window *glfw.Window) []Area
	SetProperties(size Size, center Point) UIElement
	GetProperties() Properties
	Initialize(skip SkipAlignment) UIElement
	SetParent(parent *Properties) UIElement
	ToString() string
}

func ApplyAlignment

func ApplyAlignment(element UIElement) UIElement

func ApplyPadding

func ApplyPadding(element UIElement) UIElement

func ApplyRelative

func ApplyRelative(element UIElement) UIElement

type UIType added in v0.1.2

type UIType byte
const (
	UIContainer UIType = 0
	UIButton    UIType = 1
	UIImage     UIType = 2
	UIRow       UIType = 3
	UIColumn    UIType = 4
	UIText      UIType = 5
)

func (UIType) ToString added in v0.1.2

func (u UIType) ToString() string

Jump to

Keyboard shortcuts

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