microui

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: May 23, 2023 License: MIT Imports: 5 Imported by: 5

Documentation

Index

Constants

View Source
const (
	FormatReal   = "%.3g"
	FormatSlider = "%.2f"
)

Variables

View Source
var (
	DefaultGetTextWidth GetTextWidthFunc = func(font Font, text string) int32 {
		println("DefaultGetTextWidth", font, text)

		return 1
	}
	DefaultGetTextHeight GetTextHeightFunc = func(font Font) int32 {
		println("DefaultGetTextHeight", font)

		return 1
	}
)
View Source
var (
	ErrBufferTooSmall = errors.New("buffer too small")
)

Functions

func Max

func Max[T constraints.Ordered](a, b T) T

func PushID

func PushID[T AddressableByC](ctx *Context, data *T)

func SizeOfCommand

func SizeOfCommand() int32

Types

type AddressableByC

type AddressableByC interface {
	constraints.Integer | constraints.Float
}

type Buf

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

func NewBuf

func NewBuf(size int) *Buf

func (*Buf) Clear

func (sb *Buf) Clear()

Clear sets the first byte of the buffer to 0.

func (*Buf) SetString

func (sb *Buf) SetString(s string) error

func (*Buf) Size

func (sb *Buf) Size() int

func (*Buf) String

func (sb *Buf) String() string

type ClipCommand

type ClipCommand struct {
	*Command
}

func (*ClipCommand) Rect

func (c *ClipCommand) Rect() Rect

type Color

type Color struct {
	R uint8
	G uint8
	B uint8
	A uint8
}

func NewColor

func NewColor(r, g, b, a uint8) Color

func (Color) Equals

func (r Color) Equals(other Color) bool

type ColorID

type ColorID int32
const (
	ColorText ColorID = iota
	ColorBorder
	ColorWindowbg
	ColorTitlebg
	ColorTitletext
	ColorPanelbg
	ColorButton
	ColorButtonhover
	ColorButtonfocus
	ColorBase
	ColorBasehover
	ColorBasefocus
	ColorScrollbase
	ColorScrollthumb
)

type Command

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

func (*Command) Clip

func (c *Command) Clip() ClipCommand

func (*Command) Icon

func (c *Command) Icon() IconCommand

func (*Command) Jump

func (c *Command) Jump() JumpCommand

func (*Command) Rect

func (c *Command) Rect() RectCommand

func (*Command) Size

func (c *Command) Size() int32

func (*Command) Text

func (c *Command) Text() TextCommand

func (*Command) Type

func (c *Command) Type() CommandType

type CommandType

type CommandType int32
const (
	CommandJump CommandType = iota + 1
	CommandClip
	CommandRect
	CommandText
	CommandIcon
	CommandMax
)

type Container

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

func (*Container) Body

func (c *Container) Body() Rect

func (*Container) ContentSize

func (c *Container) ContentSize() Vec2

func (*Container) Open

func (c *Container) Open() bool

func (*Container) Rect

func (c *Container) Rect() Rect

func (*Container) Scroll

func (c *Container) Scroll() Vec2

func (*Container) SetBody

func (c *Container) SetBody(r Rect)

func (*Container) SetOpen added in v0.0.3

func (c *Container) SetOpen(v bool)

func (*Container) SetRect

func (c *Container) SetRect(r Rect)

func (*Container) SetScroll

func (c *Container) SetScroll(v Vec2)

func (*Container) ZIndex

func (c *Container) ZIndex() int32

type Context

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

func NewContext

func NewContext() *Context

func (*Context) Begin

func (ctx *Context) Begin()

func (*Context) BeginPanel

func (ctx *Context) BeginPanel(name string)

func (*Context) BeginPanelEx

func (ctx *Context) BeginPanelEx(name string, flags OptFlags)

func (*Context) BeginPopup

func (ctx *Context) BeginPopup(name string) bool

func (*Context) BeginTreenode

func (ctx *Context) BeginTreenode(label string) bool

func (*Context) BeginTreenodeEx

func (ctx *Context) BeginTreenodeEx(label string, flags OptFlags) bool

func (*Context) BeginWindow

func (ctx *Context) BeginWindow(title string, rect Rect) bool

func (*Context) BeginWindowEx

func (ctx *Context) BeginWindowEx(title string, rect Rect, flags OptFlags) bool

func (*Context) Button

func (ctx *Context) Button(label string) bool

func (*Context) ButtonEx

func (ctx *Context) ButtonEx(label string, icon int32, flags OptFlags) bool

func (*Context) Checkbox

func (ctx *Context) Checkbox(label string, state *int32) ResultFlags

func (*Context) DrawControlText

func (ctx *Context) DrawControlText(str string, rect Rect, colorid ColorID, flags OptFlags)

func (*Context) DrawIcon

func (ctx *Context) DrawIcon(id int32, rect Rect, color Color)

func (*Context) DrawRect

func (ctx *Context) DrawRect(rect Rect, color Color)

func (*Context) End

func (ctx *Context) End()

func (*Context) EndPanel

func (ctx *Context) EndPanel()

func (*Context) EndPopup

func (ctx *Context) EndPopup()

func (*Context) EndTreenode

func (ctx *Context) EndTreenode()

func (*Context) EndWindow

func (ctx *Context) EndWindow()

func (*Context) Focus

func (ctx *Context) Focus() ID

Focus returns the id of the currently focused item.

func (*Context) GetContainer added in v0.0.2

func (ctx *Context) GetContainer(name string) *Container

func (*Context) GetCurrentContainer

func (ctx *Context) GetCurrentContainer() *Container

func (*Context) Header

func (ctx *Context) Header(label string) bool

func (*Context) HeaderEx

func (ctx *Context) HeaderEx(label string, flags OptFlags) bool

func (*Context) Hover

func (ctx *Context) Hover() ID

Hover returns the id of the currently hovered item.

func (*Context) HoverRoot

func (ctx *Context) HoverRoot() *Container

HoverRoot returns the container that is currently hovered. This is useful for determining if the mouse is hovering over a window.

func (*Context) InputKeyDown

func (ctx *Context) InputKeyDown(k Key)

func (*Context) InputKeyUp

func (ctx *Context) InputKeyUp(k Key)

func (*Context) InputMouseDown

func (ctx *Context) InputMouseDown(x, y int32, b MouseButton)

func (*Context) InputMouseMove

func (ctx *Context) InputMouseMove(x, y int32)

InputMouseMove is the actual position of the mouse in pixels.

func (*Context) InputMouseUp

func (ctx *Context) InputMouseUp(x, y int32, b MouseButton)

func (*Context) InputScroll

func (ctx *Context) InputScroll(x, y int32)

func (*Context) InputText

func (ctx *Context) InputText(text string)

func (*Context) Label

func (ctx *Context) Label(str string)

func (*Context) LastID

func (ctx *Context) LastID() ID

func (*Context) LayoutBeginColumn

func (ctx *Context) LayoutBeginColumn()

func (*Context) LayoutEndColumn

func (ctx *Context) LayoutEndColumn()

func (*Context) LayoutHeight

func (ctx *Context) LayoutHeight(height int32)

func (*Context) LayoutNext

func (ctx *Context) LayoutNext() Rect

func (*Context) LayoutRow

func (ctx *Context) LayoutRow(items int32, widths []int32, height int32)

func (*Context) LayoutSetNext

func (ctx *Context) LayoutSetNext(rect Rect, relative bool)

func (*Context) LayoutWidth

func (ctx *Context) LayoutWidth(width int32)

func (*Context) OpenPopup

func (ctx *Context) OpenPopup(name string)

func (*Context) PopID

func (ctx *Context) PopID()

func (*Context) PopStyle

func (c *Context) PopStyle()

func (*Context) PushIDInt32

func (ctx *Context) PushIDInt32(id *int32)

func (*Context) PushStyleColor

func (c *Context) PushStyleColor(id ColorID, color Color)

func (*Context) PushStyleFont

func (c *Context) PushStyleFont(font Font)

func (*Context) PushStyleInt

func (c *Context) PushStyleInt(id IntStyles, value int32)

func (*Context) PushStyleSize

func (c *Context) PushStyleSize(size Vec2)

func (*Context) Render

func (ctx *Context) Render()

func (*Context) SetBeginCallback

func (ctx *Context) SetBeginCallback(fn func())

func (*Context) SetBeginRender

func (ctx *Context) SetBeginRender(fn func())

func (*Context) SetEndCallback

func (ctx *Context) SetEndCallback(fn func())

func (*Context) SetEndRender

func (ctx *Context) SetEndRender(fn func())

func (*Context) SetFocus

func (ctx *Context) SetFocus(id ID)

func (*Context) SetRenderCommand

func (ctx *Context) SetRenderCommand(fn func(cmd *Command))

func (*Context) Slider

func (ctx *Context) Slider(value *float32, low, high float32) ResultFlags

func (*Context) SliderEx

func (ctx *Context) SliderEx(value *float32, low, high, step float32, format string, flags OptFlags) ResultFlags

func (*Context) Style

func (ctx *Context) Style() *Style

func (*Context) Text

func (ctx *Context) Text(str string)

func (*Context) Textbox

func (ctx *Context) Textbox(buf *Buf) ResultFlags

func (*Context) TextboxEx

func (ctx *Context) TextboxEx(buf *Buf, flags OptFlags) ResultFlags

type Font

type Font uintptr

type GetTextHeightFunc

type GetTextHeightFunc func(font Font) int32

type GetTextWidthFunc

type GetTextWidthFunc func(font Font, text string) int32

type ID

type ID uint32

func GetID

func GetID[T any](ctx *Context, data *T) ID

type IconCommand

type IconCommand struct {
	*Command
}

func (*IconCommand) Color

func (c *IconCommand) Color() Color

func (*IconCommand) ID

func (c *IconCommand) ID() int32

func (*IconCommand) Rect

func (c *IconCommand) Rect() Rect

type IntStyles

type IntStyles int32
const (
	StylePadding IntStyles = iota
	StyleSpacing
	StyleIndent
	StyleTitleHeight
	StyleFooterHeight
	StyleScrollbarSize
	StyleThumbSize
)

type JumpCommand

type JumpCommand struct {
	*Command
}

func (*JumpCommand) Dst

func (c *JumpCommand) Dst() uintptr

type Key

type Key int32
const (
	KeyShift Key = 1 << iota
	KeyCtrl
	KeyAlt
	KeyBackspace
	KeyReturn
)

type MouseButton

type MouseButton int32
const (
	MouseLeft MouseButton = 1 << iota
	MouseRight
	MouseMiddle
)

type OptFlags

type OptFlags int32
const (
	OptAlignCenter OptFlags = 1 << iota
	OptAlignRight
	OptNoInteract
	OptNoFrame
	OptNoResize
	OptNoScroll
	OptNoClose
	OptNoTitle
	OptHoldFocus
	OptAutosize
	OptPopup
	OptClosed
	OptExpanded
)

type Rect

type Rect struct {
	X int32
	Y int32
	W int32
	H int32
}

typedef struct { int x, y, w, h; } mu_Rect;

func NewRect

func NewRect(x, y, w, h int32) Rect

func (*Rect) Contains

func (r *Rect) Contains(x, y int32) bool

type RectCommand

type RectCommand struct {
	*Command
}

func (*RectCommand) Color

func (c *RectCommand) Color() Color

func (*RectCommand) Rect

func (c *RectCommand) Rect() Rect

type ResultFlags

type ResultFlags int32
const (
	ResActive ResultFlags = 1 << iota
	ResSubmit
	ResChange
)

type Style

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

func (*Style) Color

func (s *Style) Color(id ColorID) Color

func (*Style) SetColor

func (s *Style) SetColor(id ColorID, color Color)

type TextCommand

type TextCommand struct {
	*Command
}

func (*TextCommand) Color

func (c *TextCommand) Color() Color

func (*TextCommand) Font

func (c *TextCommand) Font() Font

func (*TextCommand) Pos

func (c *TextCommand) Pos() Vec2

func (*TextCommand) Text

func (c *TextCommand) Text() string

type Vec2

type Vec2 struct {
	X int32
	Y int32
}

Jump to

Keyboard shortcuts

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