Documentation
¶
Index ¶
- func DrawText(dst *ebiten.Image, str string, options *text.DrawOptions)
- type ContainerLayout
- type Context
- func (c *Context) Button(label string) EventHandler
- func (c *Context) Checkbox(state *bool, label string) EventHandler
- func (c *Context) ClosePopup(popupID PopupID)
- func (c *Context) DrawOnlyWidget(f func(screen *ebiten.Image))
- func (c *Context) GridCell(f func(bounds image.Rectangle))
- func (c *Context) Header(label string, initialExpansion bool, f func())
- func (c *Context) IDScope(name string, f func())
- func (c *Context) NumberField(value *int, step int) EventHandler
- func (c *Context) NumberFieldF(value *float64, step float64, digits int) EventHandler
- func (c *Context) OpenPopup(popupID PopupID)
- func (c *Context) Panel(f func(layout ContainerLayout))
- func (c *Context) Popup(f func(layout ContainerLayout, popupID PopupID)) PopupID
- func (c *Context) Scale() int
- func (c *Context) SetGridLayout(widths []int, heights []int)
- func (c *Context) SetScale(scale int)
- func (c *Context) SetScroll(scroll image.Point)
- func (c *Context) SetTextFieldValue(value string)
- func (c *Context) Slider(value *int, lo, hi int, step int) EventHandler
- func (c *Context) SliderF(value *float64, lo, hi float64, step float64, digits int) EventHandler
- func (c *Context) Text(text string)
- func (c *Context) TextField(buf *string) EventHandler
- func (c *Context) TreeNode(label string, f func())
- func (c *Context) Window(title string, rect image.Rectangle, f func(layout ContainerLayout))
- type DebugUI
- type EventHandler
- type InputCapturingState
- type PopupID
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ContainerLayout ¶
type ContainerLayout struct { // Bounds is the bounds of the widget. Bounds image.Rectangle // BodyBounds is the bounds of the body area of the container. BodyBounds image.Rectangle // ContentSize is the size of the content. // ContentSize can be larger than Bounds or BodyBounds. In this case, the widget should be scrollable. ContentSize image.Point // ScrollOffset is the offset of the scroll. ScrollOffset image.Point }
ContainerLayout represents the layout of a container widget.
type Context ¶
type Context struct {
// contains filtered or unexported fields
}
Context is the main context for the debug UI.
func (*Context) Button ¶
func (c *Context) Button(label string) EventHandler
Button creates a button widget with the given label.
Button returns an EventHandler to handle click events. A returned EventHandler is never nil.
A Button widget is uniquely determined by its call location. Function calls made in different locations will create different widgets. If you want to generate different widgets with the same function call in a loop (such as a for loop), use [IDScope].
func (*Context) Checkbox ¶
func (c *Context) Checkbox(state *bool, label string) EventHandler
Checkbox creates a checkbox with the given boolean state and text label.
A Checkbox widget is uniquely determined by its call location. Function calls made in different locations will create different widgets. If you want to generate different widgets with the same function call in a loop (such as a for loop), use [IDScope].
func (*Context) ClosePopup ¶
ClosePopup closes a popup window.
func (*Context) DrawOnlyWidget ¶
func (c *Context) DrawOnlyWidget(f func(screen *ebiten.Image))
DrawOnlyWidget adds a widget that only draws the given function without user interaction.
func (*Context) Header ¶
Header creates a header widget with the given label.
initialExpansion specifies whether the header is initially expanded. f is called to render the content of the header. The content is only rendered when the header is expanded.
A Header widget is uniquely determined by its call location. Function calls made in different locations will create different widgets. If you want to generate different widgets with the same function call in a loop (such as a for loop), use [IDScope].
func (*Context) IDScope ¶
IDScope creates a new scope for widget IDs. IDScope creates a unique scope based on the caller's position and the given name string.
IDScope is useful when you want to create multiple widgets at the same position e.g. in a for loop.
func (*Context) NumberField ¶
func (c *Context) NumberField(value *int, step int) EventHandler
NumberField creates a number field to modify the value of a int value.
step is the amount to increment or decrement the value when the user drags the thumb.
NumberField returns an EventHandler to handle value change events. A returned EventHandler is never nil.
A NumberField widget is uniquely determined by its call location. Function calls made in different locations will create different widgets. If you want to generate different widgets with the same function call in a loop (such as a for loop), use [IDScope].
func (*Context) NumberFieldF ¶
func (c *Context) NumberFieldF(value *float64, step float64, digits int) EventHandler
NumberFieldF creates a number field to modify the value of a float64 value.
step is the amount to increment or decrement the value when the user drags the thumb. digits is the number of decimal places to display.
NumberFieldF returns an EventHandler to handle value change events. A returned EventHandler is never nil.
A NumberFieldF widget is uniquely determined by its call location. Function calls made in different locations will create different widgets. If you want to generate different widgets with the same function call in a loop (such as a for loop), use [IDScope].
func (*Context) Panel ¶
func (c *Context) Panel(f func(layout ContainerLayout))
Panel creates a new panel with the contents defined by the function f. Panel can have scroll bars, and the contents of the panel can be scrolled.
func (*Context) Popup ¶
func (c *Context) Popup(f func(layout ContainerLayout, popupID PopupID)) PopupID
Popup creates a popup window with the content defined by the provided function, and returns the PopupID of the popup window.
By default, the popup window is hidden. To show the popup window, call OpenPopup with the PopupID returned by this function.
func (*Context) SetGridLayout ¶
SetGridLayout sets the grid layout. widths and heights are the sizes of each column and row.
If a size is 0, the default size is used. If a size is negative, the size represents the ratio of the remaining space. For example, if widths is []int{100, -1}, the first column is 100 pixels and the second column takes the remaining space. If widths is []int{100, -1, -2}, the first column is 100 pixels, the second column takes 1/3 of the remaining space, and the third column takes 2/3 of the remaining space.
If widths is nil, one column width with -1 is used for windows, and 0 (the default size) is used for popups. If heights is nil, 0 (the default size) is used.
When the number of items exceeds the number of grid cells, a new row starts with the same grid layout.
func (*Context) SetScale ¶
SetScale sets the scale of the UI.
The scale affects the rendering result of the UI.
The default scale is 1.
func (*Context) SetTextFieldValue ¶
SetTextFieldValue sets the value of the current text field.
If the last widget is not a text field, this function does nothing.
func (*Context) Slider ¶
func (c *Context) Slider(value *int, lo, hi int, step int) EventHandler
Slider cretes a slider widget with the given int value, range, and step.
lo and hi specify the range of the slider.
Slider returns an EventHandler to handle value change events. A returned EventHandler is never nil.
A Slider widget is uniquely determined by its call location. Function calls made in different locations will create different widgets. If you want to generate different widgets with the same function call in a loop (such as a for loop), use [IDScope].
func (*Context) SliderF ¶
SliderF cretes a slider widget with the given float64 value, range, step, and number of digits.
lo and hi specify the range of the slider. digits specifies the number of digits to display after the decimal point.
SliderF returns an EventHandler to handle value change events. A returned EventHandler is never nil.
A SliderF widget is uniquely determined by its call location. Function calls made in different locations will create different widgets. If you want to generate different widgets with the same function call in a loop (such as a for loop), use [IDScope].
func (*Context) TextField ¶
func (c *Context) TextField(buf *string) EventHandler
TextField creates a text field to modify the value of a string buf.
TextField returns an EventHandler to handle events when the value is confirmed, such as on blur or Enter key press. A returned EventHandler is never nil.
A TextField widget is uniquely determined by its call location. Function calls made in different locations will create different widgets. If you want to generate different widgets with the same function call in a loop (such as a for loop), use [IDScope].
func (*Context) TreeNode ¶
TreeNode creates a tree node widget with the given label.
A TreeNode widget is uniquely determined by its call location. Function calls made in different locations will create different widgets. If you want to generate different widgets with the same function call in a loop (such as a for loop), use [IDScope].
type DebugUI ¶
type DebugUI struct {
// contains filtered or unexported fields
}
DebugUI is a debug UI.
The zero value for DebugUI is ready to use.
func (*DebugUI) Draw ¶
func (d *DebugUI) Draw(screen *ebiten.Image)
Draw draws the debug UI.
Draw should be called once in the game's Draw function.
func (*DebugUI) Update ¶
func (d *DebugUI) Update(f func(ctx *Context) error) (InputCapturingState, error)
Update updates the debug UI.
Update returns true if the debug UI is capturing input, e.g. when a widget has focus. Otherwise, Update returns false.
Update should be called once in the game's Update function.
type EventHandler ¶
type EventHandler interface {
// On registers a callback function to be called when the event occurs.
On(func())
}
EventHandler is an interface for handling events in a widget.
type InputCapturingState ¶
type InputCapturingState int
InputCapturingState is a bit mask that indicates the input capturing state of the debug UI.
const ( // InputCapturingStateHover indicates that a pointing device is hovering over a widget. InputCapturingStateHover InputCapturingState = 1 << iota // InputCapturingStateFocus indicates that a widget like a text field is focused. InputCapturingStateFocus )