forked from zeozeozeo/microui-go
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathwidgets.go
51 lines (40 loc) · 1.32 KB
/
widgets.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
// SPDX-License-Identifier: Apache-2.0
// SPDX-FileCopyrightText: 2024 The Ebitengine Authors
package debugui
import (
"image"
"strings"
)
const idSeparator = "\x00"
func (c *Context) Button(label string) Response {
label, idStr, _ := strings.Cut(label, idSeparator)
return c.button(label, idStr, optionAlignCenter)
}
func (c *Context) TextBox(buf *string) Response {
return c.textBox(buf, 0)
}
func (c *Context) Slider(value *float64, lo, hi float64, step float64, digits int) Response {
return c.slider(value, lo, hi, step, digits, optionAlignCenter)
}
func (c *Context) Number(value *float64, step float64, digits int) Response {
return c.number(value, step, digits, optionAlignCenter)
}
func (c *Context) Header(label string, expanded bool) Response {
var opt option
if expanded {
opt |= optionExpanded
}
label, idStr, _ := strings.Cut(label, idSeparator)
return c.header(label, idStr, false, opt)
}
func (c *Context) TreeNode(label string, f func(res Response)) {
label, idStr, _ := strings.Cut(label, idSeparator)
c.treeNode(label, idStr, 0, f)
}
func (c *Context) Window(title string, rect image.Rectangle, f func(res Response, layout Layout)) {
title, idStr, _ := strings.Cut(title, idSeparator)
c.window(title, idStr, rect, 0, f)
}
func (c *Context) Panel(name string, f func(layout Layout)) {
c.panel(name, 0, f)
}