Documentation
¶
Overview ¶
Package configui builds a settings dialog from a Go struct.
Editor lists the exported fields and edits them in place:
- bool -> checkbox
- string -> text field
- integer -> number field
- type implementing Enum -> dropdown
- struct -> nested settings section
- type implementing CustomGroup -> custom widget
Index ¶
- type CustomGroup
- type CustomWidget
- type Editor
- func (e *Editor[T]) Build(context *guigui.Context, adder *guigui.ChildAdder) error
- func (e *Editor[T]) IsOpen() bool
- func (e *Editor[T]) Layout(context *guigui.Context, widgetBounds *guigui.WidgetBounds, ...)
- func (e *Editor[T]) OnClose(f func(context *guigui.Context, reason basicwidget.PopupCloseReason))
- func (e *Editor[T]) SetOpen(open bool)
- func (e *Editor[T]) SetTarget(v *T)
- type Enum
- type EnumOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CustomGroup ¶
type CustomGroup interface {
NewConfigWidget() CustomWidget
}
CustomGroup replaces the generated controls for a field with a custom widget.
Implement it on the field's type. NewConfigWidget returns the widget shown for that field; configui keeps the widget and calls CustomWidget.Bind with a pointer to the value. Use this when the field needs a layout the generated form does not provide.
type CustomWidget ¶
CustomWidget edits one configuration field.
Bind receives a pointer to that field on each build. A field of type T is passed as *T.
type Editor ¶
type Editor[T any] struct { guigui.DefaultWidget // contains filtered or unexported fields }
Editor is a modal settings overlay for a configuration struct T. Open it from a menu (or anywhere else) with Editor.SetOpen. Editing a field in the UI mutates *target directly through reflection.
func (*Editor[T]) Layout ¶
func (e *Editor[T]) Layout(context *guigui.Context, widgetBounds *guigui.WidgetBounds, layouter *guigui.ChildLayouter)
func (*Editor[T]) OnClose ¶
func (e *Editor[T]) OnClose(f func(context *guigui.Context, reason basicwidget.PopupCloseReason))
type Enum ¶
type Enum interface {
// EnumOptions returns the choices for the enumeration.
EnumOptions() []EnumOption
}
Enum is a string field shown as a dropdown.
type EnumOption ¶
type EnumOption struct {
Value string // Value is stored on the struct field.
Label string // Label is shown in the dropdown.
}
EnumOption holds a single choice in an Enum dropdown.