Documentation
¶
Index ¶
- Constants
- Variables
- func PtrToBytes(ptr unsafe.Pointer) []byte
- type BaseCommand
- type ClipCommand
- type Color
- type Command
- type Container
- type Context
- func (ctx *Context) AddScrollbar(cnt *Container, b *Rect, cs Vec2, swap bool)
- func (ctx *Context) Begin()
- func (ctx *Context) BeginPanel(name string)
- func (ctx *Context) BeginPanelEx(name string, opt int)
- func (ctx *Context) BeginPopup(name string) int
- func (ctx *Context) BeginRootContainer(cnt *Container)
- func (ctx *Context) BeginTreeNode(label string) bool
- func (ctx *Context) BeginTreeNodeEx(label string, opt int) int
- func (ctx *Context) BeginWindow(title string, rect Rect) bool
- func (ctx *Context) BeginWindowEx(title string, rect Rect, opt int) int
- func (ctx *Context) BringToFront(cnt *Container)
- func (ctx *Context) Button(label string) bool
- func (ctx *Context) ButtonEx(label string, icon int, opt int) int
- func (ctx *Context) CheckClip(r Rect) int
- func (ctx *Context) Checkbox(label string, state *bool) int
- func (ctx *Context) DrawBox(rect Rect, color Color)
- func (ctx *Context) DrawControlFrame(id mu_Id, rect Rect, colorid int, opt int)
- func (ctx *Context) DrawControlText(str string, rect Rect, colorid int, opt int)
- func (ctx *Context) DrawIcon(id int, rect Rect, color Color)
- func (ctx *Context) DrawRect(rect Rect, color Color)
- func (ctx *Context) DrawText(font Font, str string, pos Vec2, color Color)
- func (ctx *Context) End()
- func (ctx *Context) EndPanel()
- func (ctx *Context) EndPopup()
- func (ctx *Context) EndRootContainer()
- func (ctx *Context) EndTreeNode()
- func (ctx *Context) EndWindow()
- func (ctx *Context) GetClipRect() Rect
- func (ctx *Context) GetContainer(name string) *Container
- func (ctx *Context) GetCurrentContainer() *Container
- func (ctx *Context) GetID(data []byte) mu_Id
- func (ctx *Context) GetLayout() *Layout
- func (ctx *Context) Header(label string) bool
- func (ctx *Context) HeaderEx(label string, opt int) int
- func (ctx *Context) InHoverRoot() bool
- func (ctx *Context) InputKeyDown(key int)
- func (ctx *Context) InputKeyUp(key int)
- func (ctx *Context) InputMouseDown(x, y int, btn int)
- func (ctx *Context) InputMouseMove(x, y int)
- func (ctx *Context) InputMouseUp(x, y int, btn int)
- func (ctx *Context) InputScroll(x, y int)
- func (ctx *Context) InputText(text []rune)
- func (ctx *Context) Label(text string)
- func (ctx *Context) LayoutBeginColumn()
- func (ctx *Context) LayoutEndColumn()
- func (ctx *Context) LayoutHeight(height int)
- func (ctx *Context) LayoutNext() Rect
- func (ctx *Context) LayoutRow(items int, widths []int, height int)
- func (ctx *Context) LayoutSetNext(r Rect, relative bool)
- func (ctx *Context) LayoutWidth(width int)
- func (ctx *Context) MouseOver(rect Rect) bool
- func (ctx *Context) MuHeader(label string, istreenode bool, opt int) int
- func (ctx *Context) NextCommand(cmd **Command) bool
- func (ctx *Context) Number(value *float32, step float32) int
- func (ctx *Context) NumberEx(value *float32, step float32, format string, opt int) int
- func (ctx *Context) NumberTextBox(value *float32, r Rect, id mu_Id) bool
- func (ctx *Context) OpenPopup(name string)
- func (ctx *Context) PoolGet(items []MuPoolItem, id mu_Id) int
- func (ctx *Context) PoolInit(items []MuPoolItem, id mu_Id) int
- func (ctx *Context) PoolUpdate(items []MuPoolItem, idx int)
- func (ctx *Context) PopClipRect()
- func (ctx *Context) PopContainer()
- func (ctx *Context) PopID()
- func (ctx *Context) PushClipRect(rect Rect)
- func (ctx *Context) PushCommand(cmd_type int) *Command
- func (ctx *Context) PushContainerBody(cnt *Container, body Rect, opt int)
- func (ctx *Context) PushID(data []byte)
- func (ctx *Context) PushJump(dstIdx int) int
- func (ctx *Context) PushLayout(body Rect, scroll Vec2)
- func (ctx *Context) Render(nextCmdFunc func(cmd *Command))
- func (ctx *Context) Scrollbars(cnt *Container, body *Rect)
- func (ctx *Context) SetClip(rect Rect)
- func (ctx *Context) SetFocus(id mu_Id)
- func (ctx *Context) Slider(value *float32, lo, hi float32) int
- func (ctx *Context) SliderEx(value *float32, low float32, high float32, step float32, format string, ...) int
- func (ctx *Context) Text(text string)
- func (ctx *Context) TextBox(buf *string) int
- func (ctx *Context) TextBoxEx(buf *string, opt int) int
- func (ctx *Context) TextboxRaw(buf *string, id mu_Id, r Rect, opt int) int
- func (ctx *Context) UpdateControl(id mu_Id, rect Rect, opt int)
- type Font
- type IconCommand
- type JumpCommand
- type Layout
- type MuPoolItem
- type Rect
- type RectCommand
- type Style
- type TextCommand
- type Vec2
Constants ¶
const ( MU_COMMANDLIST_SIZE = 256 * 1024 MU_ROOTLIST_SIZE = 32 MU_CONTAINERSTACK_SIZE = 32 MU_CLIPSTACK_SIZE = 32 MU_IDSTACK_SIZE = 32 MU_LAYOUTSTACK_SIZE = 16 MU_CONTAINERPOOL_SIZE = 48 MU_TREENODEPOOL_SIZE = 48 MU_MAX_WIDTHS = 16 )
const ( MU_REAL_FMT = "%.3g" MU_SLIDER_FMT = "%.2f" MU_MAX_FMT = 127 )
const ( MU_CLIP_PART = 1 + iota MU_CLIP_ALL )
const ( MU_COMMAND_JUMP = 1 + iota MU_COMMAND_CLIP MU_COMMAND_RECT MU_COMMAND_TEXT MU_COMMAND_ICON MU_COMMAND_MAX )
const ( MU_COLOR_TEXT = iota MU_COLOR_BORDER MU_COLOR_WINDOWBG MU_COLOR_TITLEBG MU_COLOR_TITLETEXT MU_COLOR_PANELBG MU_COLOR_BUTTON MU_COLOR_BUTTONHOVER MU_COLOR_BUTTONFOCUS MU_COLOR_BASE MU_COLOR_BASEHOVER MU_COLOR_BASEFOCUS MU_COLOR_SCROLLBASE MU_COLOR_SCROLLTHUMB MU_COLOR_MAX )
const ( MU_ICON_CLOSE = 1 + iota MU_ICON_CHECK MU_ICON_COLLAPSED MU_ICON_EXPANDED MU_ICON_MAX )
const ( MU_RES_ACTIVE = (1 << 0) MU_RES_SUBMIT = (1 << 1) MU_RES_CHANGE = (1 << 2) )
const ( MU_OPT_ALIGNCENTER = (1 << 0) MU_OPT_ALIGNRIGHT = (1 << 1) MU_OPT_NOINTERACT = (1 << 2) MU_OPT_NOFRAME = (1 << 3) MU_OPT_NORESIZE = (1 << 4) MU_OPT_NOSCROLL = (1 << 5) MU_OPT_NOCLOSE = (1 << 6) MU_OPT_NOTITLE = (1 << 7) MU_OPT_HOLDFOCUS = (1 << 8) MU_OPT_AUTOSIZE = (1 << 9) MU_OPT_POPUP = (1 << 10) MU_OPT_CLOSED = (1 << 11) MU_OPT_EXPANDED = (1 << 12) )
const ( MU_MOUSE_LEFT = (1 << 0) MU_MOUSE_RIGHT = (1 << 1) MU_MOUSE_MIDDLE = (1 << 2) )
const ( MU_KEY_SHIFT = (1 << 0) MU_KEY_CTRL = (1 << 1) MU_KEY_ALT = (1 << 2) MU_KEY_BACKSPACE = (1 << 3) MU_KEY_RETURN = (1 << 4) )
const ( RELATIVE = 1 + iota ABSOLUTE )
const (
HASH_INITIAL = 2166136261 // 32bit fnv-1a hash
)
const MU_VERSION = "2.01"
Variables ¶
var (
UnclippedRect = Rect{0, 0, 0x1000000, 0x1000000}
)
Functions ¶
func PtrToBytes ¶
Convinience function for custom widgets. This will convert the literal pointer (NOT the data it points to) to a byte slice (to be used with GetID()). This is basically equivalent to passing a pointer pointer to mu_get_id.
This function will allocate a new byte slice on the heap. It produces different results based on the endianess of the machine, but that should be fine for hashing purposes.
Types ¶
type BaseCommand ¶
type BaseCommand struct {
Type int
}
type ClipCommand ¶
type ClipCommand struct { Base BaseCommand Rect Rect }
type Command ¶
type Command struct { Type int Idx int Base BaseCommand // type 0 (TODO) Jump JumpCommand // type 1 Clip ClipCommand // type 2 Rect RectCommand // type 3 Text TextCommand // type 4 Icon IconCommand // type 5 }
type Container ¶
type Context ¶
type Context struct { TextWidth func(font Font, str string) int TextHeight func(font Font) int DrawFrame func(ctx *Context, rect Rect, colorid int) Style *Style Hover mu_Id Focus mu_Id LastID mu_Id LastRect Rect LastZindex int UpdatedFocus bool Frame int HoverRoot *Container NextHoverRoot *Container ScrollTarget *Container NumberEditBuf string NumberEdit mu_Id CommandList []*Command RootList []*Container ContainerStack []*Container ClipStack []Rect IdStack []mu_Id LayoutStack []Layout ContainerPool [MU_CONTAINERPOOL_SIZE]MuPoolItem Containers [MU_CONTAINERPOOL_SIZE]Container TreeNodePool [MU_TREENODEPOOL_SIZE]MuPoolItem MousePos Vec2 MouseDelta Vec2 ScrollDelta Vec2 MouseDown int MousePressed int KeyDown int KeyPressed int TextInput []rune // contains filtered or unexported fields }
func NewContext ¶
func NewContext() *Context
func (*Context) AddScrollbar ¶
if `swap` is true, X = Y, Y = X, W = H, H = W
func (*Context) BeginPanel ¶
func (*Context) BeginPanelEx ¶
func (*Context) BeginPopup ¶
func (*Context) BeginRootContainer ¶
func (*Context) BeginTreeNode ¶
func (*Context) BeginWindowEx ¶
func (*Context) BringToFront ¶
func (*Context) DrawControlFrame ¶
func (*Context) DrawControlText ¶
func (*Context) EndRootContainer ¶
func (ctx *Context) EndRootContainer()
func (*Context) EndTreeNode ¶
func (ctx *Context) EndTreeNode()
func (*Context) GetClipRect ¶
func (*Context) GetContainer ¶
func (*Context) GetCurrentContainer ¶
func (*Context) InHoverRoot ¶
func (*Context) InputKeyDown ¶
func (*Context) InputKeyUp ¶
func (*Context) InputMouseDown ¶
func (*Context) InputMouseMove ¶
func (*Context) InputMouseUp ¶
func (*Context) InputScroll ¶
func (*Context) LayoutBeginColumn ¶
func (ctx *Context) LayoutBeginColumn()
func (*Context) LayoutEndColumn ¶
func (ctx *Context) LayoutEndColumn()
func (*Context) LayoutNext ¶
func (*Context) LayoutSetNext ¶
func (*Context) NextCommand ¶
sets cmd to the next command in command_list, returns true if success
func (*Context) NumberTextBox ¶
func (*Context) PoolGet ¶
func (ctx *Context) PoolGet(items []MuPoolItem, id mu_Id) int
returns the index of an ID in the pool. returns -1 if it is not found
func (*Context) PoolInit ¶
func (ctx *Context) PoolInit(items []MuPoolItem, id mu_Id) int
func (*Context) PoolUpdate ¶
func (ctx *Context) PoolUpdate(items []MuPoolItem, idx int)
func (*Context) PopClipRect ¶
func (ctx *Context) PopClipRect()
func (*Context) PopContainer ¶
func (ctx *Context) PopContainer()
func (*Context) PushClipRect ¶
func (*Context) PushCommand ¶
adds a new command with type cmd_type to command_list
func (*Context) PushContainerBody ¶
func (*Context) PushLayout ¶
func (*Context) Render ¶
calls nextCmdFunc for every command in the command list, clears it when done. equivalent to calling `ctx.NextCommand` in a loop
func (*Context) Scrollbars ¶
func (*Context) TextboxRaw ¶
func (*Context) UpdateControl ¶
type IconCommand ¶
type IconCommand struct { Base BaseCommand Rect Rect Id int Color Color }
type JumpCommand ¶
type JumpCommand struct { Base BaseCommand DstIdx int }
type MuPoolItem ¶
type MuPoolItem struct { ID mu_Id LastUpdate int }
type RectCommand ¶
type RectCommand struct { Base BaseCommand Rect Rect Color Color }
type TextCommand ¶
type TextCommand struct { Base BaseCommand Font Font Pos Vec2 Color Color Str string }