ui

package
v0.0.0-...-e229e0e Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2022 License: GPL-2.0 Imports: 23 Imported by: 4

Documentation

Index

Constants

View Source
const (
	LEFT_ALIGN int = iota
	CENTER_ALIGN
	RIGHT_ALIGN
)

Variables

This section is empty.

Functions

func ClickAndDragWindow

func ClickAndDragWindow(window *Window, hitbox Hitbox, c controller.Controller)

func LoadFont

func LoadFont(fontData []byte) (*truetype.Font, error)

func LoadFontFromFile

func LoadFontFromFile(fontfile string) (*truetype.Font, error)

func NewUiController

func NewUiController(window *Window) controller.Controller

func SetProgressBar

func SetProgressBar(pb *Window, progress int)

Types

type Activatable

type Activatable interface {
	Active() bool
	Activate()
	Deactivate()
}

func LoadHTML

func LoadHTML(container *Container, htmlInput, cssInput io.Reader, assets HtmlAssets) ([]Activatable, error)

LoadHTML - load the html/css code into the container

type Children

type Children []Element

func (Children) GetChild

func (c Children) GetChild(index int) Element

func (Children) GetChildById

func (c Children) GetChildById(id string) Element

func (Children) TextElementById

func (c Children) TextElementById(id string) *TextElement

type Container

type Container struct {
	Hitbox Hitbox

	GlobalOrthoOrderValue int
	// contains filtered or unexported fields
}

func NewContainer

func NewContainer() *Container

func (*Container) AddChildren

func (c *Container) AddChildren(children ...Element)

func (*Container) ElementById

func (c *Container) ElementById(id string) Element

func (*Container) GetChildren

func (c *Container) GetChildren() Children

func (*Container) GetId

func (c *Container) GetId() string

func (*Container) GlobalOrthoOrder

func (c *Container) GlobalOrthoOrder() int

func (*Container) ReRender

func (c *Container) ReRender()

func (*Container) RemoveAllChildren

func (c *Container) RemoveAllChildren()

func (*Container) RemoveChildren

func (c *Container) RemoveChildren(children ...Element)

func (*Container) Render

func (c *Container) Render(size, offset mgl32.Vec2) mgl32.Vec2

func (*Container) SetBackgroundColor

func (c *Container) SetBackgroundColor(r, g, b, a uint8)

func (*Container) SetBackgroundImage

func (c *Container) SetBackgroundImage(img image.Image)

func (*Container) SetHeight

func (c *Container) SetHeight(height float32)

func (*Container) SetId

func (c *Container) SetId(id string)

func (*Container) SetMargin

func (c *Container) SetMargin(margin Margin)

func (*Container) SetMarginPercent

func (c *Container) SetMarginPercent(marginPercent MarginPercentages)

func (*Container) SetPadding

func (c *Container) SetPadding(padding Margin)

func (*Container) SetPaddingPercent

func (c *Container) SetPaddingPercent(paddingPercent MarginPercentages)

func (*Container) SetWidth

func (c *Container) SetWidth(width float32)

func (*Container) Spatial

func (c *Container) Spatial() renderer.Spatial

func (*Container) TextElementById

func (c *Container) TextElementById(id string) *TextElement

func (*Container) UsePercentHeight

func (c *Container) UsePercentHeight(usePercent bool)

func (*Container) UsePercentWidth

func (c *Container) UsePercentWidth(usePercent bool)
type Dropdown struct {
	Parent Element
	// contains filtered or unexported fields
}

func NewDropdown

func NewDropdown(options []string, textColor color.Color, textSize float32, textFont *truetype.Font, parent Element) *Dropdown
func (dd *Dropdown) Activate()
func (dd *Dropdown) Active() bool
func (dd *Dropdown) AddOnBlur(handler func())
func (dd *Dropdown) AddOnChange(handler func(string))
func (dd *Dropdown) AddOnFocus(handler func())
func (dd *Dropdown) AddOnKeyPress(handler func(key string, release bool))
func (dd *Dropdown) CloseDropdown()
func (dd *Dropdown) Deactivate()
func (dd *Dropdown) GetChildren() Children
func (dd *Dropdown) GetHiddenText() string
func (dd *Dropdown) GetHitbox() Hitbox
func (dd *Dropdown) GetId() string
func (dd *Dropdown) GetText() string
func (dd *Dropdown) GlobalOrthoOrder() int
func (dd *Dropdown) OpenDropdown()
func (dd *Dropdown) ReRender()
func (dd *Dropdown) Render(size, offset mgl32.Vec2) mgl32.Vec2
func (dd *Dropdown) SetBackgroundColor(r, g, b, a uint8)
func (dd *Dropdown) SetBackgroundImage(img image.Image)
func (dd *Dropdown) SetFont(textFont *truetype.Font) *Dropdown
func (dd *Dropdown) SetHeight(height float32)
func (dd *Dropdown) SetHidden(hidden bool) *Dropdown
func (dd *Dropdown) SetId(id string)
func (dd *Dropdown) SetMargin(margin Margin)
func (dd *Dropdown) SetMarginPercent(marginPercent MarginPercentages)
func (dd *Dropdown) SetPadding(padding Margin)
func (dd *Dropdown) SetPaddingPercent(paddingPercent MarginPercentages)
func (dd *Dropdown) SetPlaceholder(placeholder string) *Dropdown
func (dd *Dropdown) SetText(text string) *Dropdown
func (dd *Dropdown) SetTextColor(textColor color.Color) *Dropdown
func (dd *Dropdown) SetTextSize(textSize float32) *Dropdown
func (dd *Dropdown) SetWidth(width float32)
func (dd *Dropdown) Spatial() renderer.Spatial
func (dd *Dropdown) ToggleDropdown()
func (dd *Dropdown) UsePercentHeight(usePercent bool)
func (dd *Dropdown) UsePercentWidth(usePercent bool)

type Element

type Element interface {
	Render(size, offset mgl32.Vec2) mgl32.Vec2
	ReRender()
	Spatial() (spatial renderer.Spatial)
	GlobalOrthoOrder() int
	GetId() string
	SetId(id string)
	GetChildren() Children
	// contains filtered or unexported methods
}

type Hitbox

type Hitbox interface {
	AddOnClick(handler func(button int, release bool, position mgl32.Vec2))
	AddOnHover(handler func())
	AddOnUnHover(handler func())
	AddOnMouseMove(handler func(position mgl32.Vec2))
	MouseMove(position mgl32.Vec2) bool
	MouseClick(button int, release bool, position mgl32.Vec2) bool
	SetSize(size mgl32.Vec2)
}

func NewHitbox

func NewHitbox() Hitbox

type HitboxImpl

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

func (*HitboxImpl) AddOnClick

func (hb *HitboxImpl) AddOnClick(handler func(button int, release bool, position mgl32.Vec2))

func (*HitboxImpl) AddOnHover

func (hb *HitboxImpl) AddOnHover(handler func())

func (*HitboxImpl) AddOnMouseMove

func (hb *HitboxImpl) AddOnMouseMove(handler func(position mgl32.Vec2))

func (*HitboxImpl) AddOnUnHover

func (hb *HitboxImpl) AddOnUnHover(handler func())

func (*HitboxImpl) MouseClick

func (hb *HitboxImpl) MouseClick(button int, release bool, position mgl32.Vec2) bool

func (*HitboxImpl) MouseMove

func (hb *HitboxImpl) MouseMove(position mgl32.Vec2) bool

func (*HitboxImpl) SetSize

func (hb *HitboxImpl) SetSize(size mgl32.Vec2)

type HtmlAssets

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

func NewHtmlAssets

func NewHtmlAssets() HtmlAssets

func (HtmlAssets) AddCallback

func (assets HtmlAssets) AddCallback(key string, callback func(element Element, args ...interface{}))

func (HtmlAssets) AddFont

func (assets HtmlAssets) AddFont(key string, font *truetype.Font)

func (HtmlAssets) AddImage

func (assets HtmlAssets) AddImage(key string, img image.Image)

type ImageElement

type ImageElement struct {
	Hitbox Hitbox
	// contains filtered or unexported fields
}

func NewImageElement

func NewImageElement(img image.Image) *ImageElement

func (*ImageElement) GetChildren

func (ie *ImageElement) GetChildren() Children

func (*ImageElement) GetId

func (ie *ImageElement) GetId() string

func (*ImageElement) GlobalOrthoOrder

func (ie *ImageElement) GlobalOrthoOrder() int

func (*ImageElement) ReRender

func (ie *ImageElement) ReRender()

func (*ImageElement) Render

func (ie *ImageElement) Render(size, offset mgl32.Vec2) mgl32.Vec2

func (*ImageElement) SetHeight

func (ie *ImageElement) SetHeight(height float32)

func (*ImageElement) SetId

func (ie *ImageElement) SetId(id string)

func (*ImageElement) SetImage

func (ie *ImageElement) SetImage(img image.Image)

func (*ImageElement) SetRotation

func (ie *ImageElement) SetRotation(rotation float32)

func (*ImageElement) SetWidth

func (ie *ImageElement) SetWidth(width float32)

func (*ImageElement) Spatial

func (ie *ImageElement) Spatial() renderer.Spatial

func (*ImageElement) UsePercentHeight

func (ie *ImageElement) UsePercentHeight(usePercent bool)

func (*ImageElement) UsePercentWidth

func (ie *ImageElement) UsePercentWidth(usePercent bool)

type Margin

type Margin struct {
	Top, Right, Bottom, Left float32
}

func NewMargin

func NewMargin(margin float32) Margin

type MarginPercentages

type MarginPercentages struct {
	Top, Right, Bottom, Left bool
}

func NewMarginPercentages

func NewMarginPercentages(percentage bool) MarginPercentages

type TextElement

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

func NewTextElement

func NewTextElement(text string, textColor color.Color, textSize float32, textFont *truetype.Font) *TextElement

func (*TextElement) AddOnKeyPress

func (te *TextElement) AddOnKeyPress(handler func(key string, release bool))

func (*TextElement) GetChildren

func (te *TextElement) GetChildren() Children

func (*TextElement) GetHiddenText

func (te *TextElement) GetHiddenText() string

func (*TextElement) GetId

func (te *TextElement) GetId() string

func (*TextElement) GetText

func (te *TextElement) GetText() string

func (*TextElement) GlobalOrthoOrder

func (te *TextElement) GlobalOrthoOrder() int

func (*TextElement) ReRender

func (te *TextElement) ReRender()

func (*TextElement) Render

func (te *TextElement) Render(size, offset mgl32.Vec2) mgl32.Vec2

func (*TextElement) SetAlign

func (te *TextElement) SetAlign(align int)

func (*TextElement) SetFont

func (te *TextElement) SetFont(textFont *truetype.Font) *TextElement

func (*TextElement) SetHeight

func (te *TextElement) SetHeight(height float32) *TextElement

func (*TextElement) SetHidden

func (te *TextElement) SetHidden(hidden bool) *TextElement

func (*TextElement) SetId

func (te *TextElement) SetId(id string)

func (*TextElement) SetPlaceholder

func (te *TextElement) SetPlaceholder(placeholder string) *TextElement

func (*TextElement) SetText

func (te *TextElement) SetText(text string) *TextElement

func (*TextElement) SetTextColor

func (te *TextElement) SetTextColor(textColor color.Color) *TextElement

func (*TextElement) SetTextSize

func (te *TextElement) SetTextSize(textSize float32) *TextElement

func (*TextElement) SetWidth

func (te *TextElement) SetWidth(width float32) *TextElement

func (*TextElement) Spatial

func (te *TextElement) Spatial() renderer.Spatial

type TextField

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

func NewTextField

func NewTextField(text string, textColor color.Color, textSize float32, textFont *truetype.Font) *TextField

func (*TextField) Activate

func (tf *TextField) Activate()

func (*TextField) Active

func (tf *TextField) Active() bool

func (*TextField) AddOnBlur

func (tf *TextField) AddOnBlur(handler func())

func (*TextField) AddOnChange

func (tf *TextField) AddOnChange(handler func(string))

func (*TextField) AddOnFocus

func (tf *TextField) AddOnFocus(handler func())

func (*TextField) AddOnKeyPress

func (tf *TextField) AddOnKeyPress(handler func(key string, release bool))

func (*TextField) Deactivate

func (tf *TextField) Deactivate()

func (*TextField) GetChildren

func (tf *TextField) GetChildren() Children

func (*TextField) GetHiddenText

func (tf *TextField) GetHiddenText() string

func (*TextField) GetHitbox

func (tf *TextField) GetHitbox() Hitbox

func (*TextField) GetId

func (tf *TextField) GetId() string

func (*TextField) GetText

func (tf *TextField) GetText() string

func (*TextField) GlobalOrthoOrder

func (tf *TextField) GlobalOrthoOrder() int

func (*TextField) ReRender

func (tf *TextField) ReRender()

func (*TextField) Render

func (tf *TextField) Render(size, offset mgl32.Vec2) mgl32.Vec2

func (*TextField) RenderCursor

func (tf *TextField) RenderCursor()

func (*TextField) SetBackgroundColor

func (tf *TextField) SetBackgroundColor(r, g, b, a uint8)

func (*TextField) SetBackgroundImage

func (tf *TextField) SetBackgroundImage(img image.Image)

func (*TextField) SetFont

func (tf *TextField) SetFont(textFont *truetype.Font) *TextField

func (*TextField) SetHeight

func (tf *TextField) SetHeight(height float32)

func (*TextField) SetHidden

func (tf *TextField) SetHidden(hidden bool) *TextField

func (*TextField) SetId

func (tf *TextField) SetId(id string)

func (*TextField) SetMargin

func (tf *TextField) SetMargin(margin Margin)

func (*TextField) SetMarginPercent

func (tf *TextField) SetMarginPercent(marginPercent MarginPercentages)

func (*TextField) SetPadding

func (tf *TextField) SetPadding(padding Margin)

func (*TextField) SetPaddingPercent

func (tf *TextField) SetPaddingPercent(paddingPercent MarginPercentages)

func (*TextField) SetPlaceholder

func (tf *TextField) SetPlaceholder(placeholder string) *TextField

func (*TextField) SetText

func (tf *TextField) SetText(text string) *TextField

func (*TextField) SetTextColor

func (tf *TextField) SetTextColor(textColor color.Color) *TextField

func (*TextField) SetTextSize

func (tf *TextField) SetTextSize(textSize float32) *TextField

func (*TextField) SetWidth

func (tf *TextField) SetWidth(width float32)

func (*TextField) Spatial

func (tf *TextField) Spatial() renderer.Spatial

func (*TextField) UsePercentHeight

func (tf *TextField) UsePercentHeight(usePercent bool)

func (*TextField) UsePercentWidth

func (tf *TextField) UsePercentWidth(usePercent bool)

type Window

type Window struct {
	Tabs []Activatable
	// contains filtered or unexported fields
}

func NewProgressBar

func NewProgressBar(label string) *Window

func NewWindow

func NewWindow() *Window

func (*Window) BoundingRadius

func (w *Window) BoundingRadius() float32

func (*Window) Center

func (w *Window) Center() mgl32.Vec3

func (*Window) Destroy

func (w *Window) Destroy(renderer renderer.Renderer)

func (*Window) Draw

func (w *Window) Draw(renderer renderer.Renderer, transform mgl32.Mat4)

func (*Window) ElementById

func (w *Window) ElementById(id string) Element

func (*Window) Optimize

func (w *Window) Optimize(geometry *renderer.Geometry, transform mgl32.Mat4)

func (*Window) OrthoOrder

func (w *Window) OrthoOrder() int

func (*Window) Render

func (w *Window) Render()

func (*Window) SetBackgroundColor

func (w *Window) SetBackgroundColor(r, g, b, a uint8)

func (*Window) SetElement

func (w *Window) SetElement(element Element)

func (*Window) SetOrientation

func (w *Window) SetOrientation(orientation mgl32.Quat)

func (*Window) SetParent

func (w *Window) SetParent(parent *renderer.Node)

func (*Window) SetScale

func (w *Window) SetScale(scale mgl32.Vec3)

func (*Window) SetTranslation

func (w *Window) SetTranslation(translation mgl32.Vec3)

func (*Window) TextElementById

func (w *Window) TextElementById(id string) *TextElement

Jump to

Keyboard shortcuts

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