ui

package
v0.0.0-...-ecc5831 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2024 License: MIT Imports: 10 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bounds

func Bounds() glitch.Rect

func Button

func Button(label string, rect glitch.Rect) bool

func Button2

func Button2(label string, rect glitch.Rect) bool

func ButtonExt

func ButtonExt(label string, rect glitch.Rect, style Style) bool

func Checkbox

func Checkbox(val *bool, rect glitch.Rect) bool

Returns true if the value has changed

func CheckboxExt

func CheckboxExt(val *bool, rect glitch.Rect, styleTrue, styleFalse Style) bool

func Clear

func Clear()

Must be called every frame before any UI draws happen TODO - This is hard to remember to do

func ClearActive

func ClearActive()

func Contains

func Contains(point glitch.Vec2) bool

func CursorPos

func CursorPos() int

func Debug

func Debug() bool

func DefaultTooltipMount

func DefaultTooltipMount() (glm.Rect, glm.Vec2)

Returns the cursor rect and the anchor vector for the tooltip

func DragData

func DragData() any

func DragItem

func DragItem(label string, rect glitch.Rect, style Style) (bool, bool, bool, bool)

returns (Clicked, hovered, isdragging, dropSlot)

func DragSlot

func DragSlot(label string, rect glitch.Rect, style Style) bool

Returns true if we dropped the drag Item to this drag slot location

func GridList

func GridList(rect glitch.Rect, numX, numY int) gridList

func HList

func HList(rect glitch.Rect, num int) hList

func HList2

func HList2(rect glitch.Rect, size float64) hList

func Hovered

func Hovered(label string, rect glitch.Rect) bool

func HoveredNoBlock

func HoveredNoBlock(rect glitch.Rect) bool

func Initialize

func Initialize(win *glitch.Window, camera *glitch.CameraOrtho, atlas *glitch.Atlas, sorter *glitch.Sorter)

TODO: 1. Would be nice to have per-state styles that include text rendering style (rather than one global) 2. Some default style that "just works" and renders flat geometry 3. Mousechecks should happen based on active/hot and not bounds checks 4. Better interface for overriding styles: maybe variadic configs? Maybe push/pop? Maybe just really nice builder functions? 5. How to do layer swiching? As style override? 6. Ability to do WorldSpaceUI (maybe not interactable?)?

func Layer

func Layer() int8

func LineGraph

func LineGraph(rect glitch.Rect, series []glitch.Vec2, textStyle TextStyle)

func MeasureText

func MeasureText(str string, rect glitch.Rect, t TextStyle) glitch.Rect

Returns the rectangular bounds of the drawn text

func MeasureTextSize

func MeasureTextSize(str string, t TextStyle) glm.Vec2

func MouseCaptured

func MouseCaptured() bool

Returns true if the mouse is captured by a group

func MousePosition

func MousePosition() (float64, float64)

Returns the mouse position with respect to the group camera

func MultiText

func MultiText(label string, rect glitch.Rect, textStyle TextStyle) glitch.Rect

func Panel2

func Panel2(label string, rect glitch.Rect) bool

func PanelExt

func PanelExt(label string, rect glitch.Rect, style Style) bool

func PopId

func PopId()

func PushId

func PushId[T constraints.Integer](id T)

TODO: You could potententially do an ID stack system: https://github.com/ocornut/imgui/blob/master/docs/FAQ.md#q-about-the-id-stack-system

func Scrollbar

func Scrollbar(idx *int, total int, rect, hoverRect glitch.Rect)

func SetActive

func SetActive(label string)

func SetButtonStyle

func SetButtonStyle(style Style)

func SetCheckboxStyleFalse

func SetCheckboxStyleFalse(style Style)

func SetCheckboxStyleTrue

func SetCheckboxStyleTrue(style Style)

func SetCursorPos

func SetCursorPos(pos int)

func SetDebug

func SetDebug(val bool)

func SetDragData

func SetDragData(data any)

func SetDragItemLayer

func SetDragItemLayer(layer int8)

func SetDragSlotStyle

func SetDragSlotStyle(style Style)

func SetFontScale

func SetFontScale(scale float64)

func SetHudScale

func SetHudScale(scale float64)

func SetLayer

func SetLayer(layer int8)

func SetPanelStyle

func SetPanelStyle(style Style)

func SetScrollbarBgStyle

func SetScrollbarBgStyle(style Style)

func SetScrollbarBottomStyle

func SetScrollbarBottomStyle(style Style)

func SetScrollbarHandleStyle

func SetScrollbarHandleStyle(style Style)

func SetScrollbarTopStyle

func SetScrollbarTopStyle(style Style)

func SetTooltipStyle

func SetTooltipStyle(style Style)

func SliderH

func SliderH(val *float64, min, max, step float64, rect, hoverRect glitch.Rect)

func SliderV

func SliderV(val *float64, min, max, step float64, rect, hoverRect glitch.Rect)

func SmoothDragButton

func SmoothDragButton(label string, rect *glitch.Rect, bounds glitch.Rect, step glitch.Vec2, style Style) bool

--------------------------------------------------------------------------------

func Sprite

func Sprite(sprite Drawer, rect glitch.Rect, color glitch.RGBA)

func SpritePanel

func SpritePanel(sprite Drawer, rect glitch.Rect, color glitch.RGBA) bool

func TextExt

func TextExt(label string, rect glitch.Rect, textStyle TextStyle) glitch.Rect

func TextInput

func TextInput(label string, str *string, rect glitch.Rect, style Style)

func Tooltip

func Tooltip(label string, rect glitch.Rect)

func TooltipExt

func TooltipExt(label string, rect glitch.Rect, style Style)

func Update

func Update()

func VList

func VList(rect glitch.Rect, num int) vList

func VList2

func VList2(rect glitch.Rect, size float64) vList

Types

type Drawer

type Drawer interface {
	RectDraw(glitch.BatchTarget, glitch.Rect)
	RectDrawColorMask(glitch.BatchTarget, glitch.Rect, glitch.RGBA)
}

type FullStyle

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

type Layout

type Layout struct {
	Type    LayoutType
	Bounds  glitch.Rect
	Padding glitch.Rect
	Size    Size
}

func (*Layout) Next

func (l *Layout) Next(textBounds glitch.Rect) glitch.Rect

type LayoutType

type LayoutType uint8

-------------------------------------------------------------------------------- - Layout --------------------------------------------------------------------------------

const (
	CutLeft LayoutType = iota
	CutTop
	CutRight
	CutBottom
	Centered
)

type Size

type Size struct {
	TypeX, TypeY SizeType
	Value        glitch.Vec2
}

type SizeType

type SizeType uint8
const (
	// SizeNone SizeType = iota
	SizePixels SizeType = iota
	SizeText
	SizeParent // Percent of parent
	SizeChildren
)

func (SizeType) Calc

func (s SizeType) Calc(val float64, parentSize float64, textSize float64) float64

type SpriteStyle

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

func NewSpriteStyle

func NewSpriteStyle(sprite Drawer, color glitch.RGBA) SpriteStyle

func (SpriteStyle) Color

func (s SpriteStyle) Color(v glitch.RGBA) SpriteStyle

func (SpriteStyle) Sprite

func (s SpriteStyle) Sprite(v Drawer) SpriteStyle

type Style

type Style struct {
	Normal, Hovered, Pressed SpriteStyle // These are kind of like button states
	Text                     TextStyle
}

func ButtonStyle

func ButtonStyle(normal, hovered, pressed Drawer) Style

func DragItemStyle

func DragItemStyle() Style
func SetDragItemStyle(style Style) {
	gStyle.dragItemStyle = style
}

func DragSlotStyle

func DragSlotStyle() Style

func NewStyle

func NewStyle(normal Drawer, color glitch.RGBA) Style

type TextStyle

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

func NewTextStyle

func NewTextStyle() TextStyle

TODO: I kind of feel like the string needs to be in here, I'm not sure though

func (TextStyle) Anchor

func (s TextStyle) Anchor(v glitch.Vec2) TextStyle

func (TextStyle) Autofit

func (s TextStyle) Autofit(v bool) TextStyle

func (TextStyle) Color

func (s TextStyle) Color(v glitch.RGBA) TextStyle

func (TextStyle) FitInteger

func (s TextStyle) FitInteger(v bool) TextStyle

func (TextStyle) Padding

func (s TextStyle) Padding(v glitch.Rect) TextStyle

func (TextStyle) Pivot

func (s TextStyle) Pivot(v glitch.Vec2) TextStyle

func (TextStyle) Scale

func (s TextStyle) Scale(v float64) TextStyle

func (TextStyle) Shadow

func (s TextStyle) Shadow(v glitch.Vec2) TextStyle

func (TextStyle) WordWrap

func (s TextStyle) WordWrap(v bool) TextStyle

type WidgetResp

type WidgetResp struct {

	// mouseDragDelta glitch.Vec2
	Pressed  bool
	Repeated bool
	Held     bool
	Released bool
	Dragging bool
	// contains filtered or unexported fields
}

func ButtonFull

func ButtonFull(label string, rect glitch.Rect, style Style) WidgetResp

Jump to

Keyboard shortcuts

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