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 PageProvider -> its own Page
Index ¶
- 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
- type Page
- type PageProvider
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
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.
type Page ¶ added in v0.0.4
Page is the settings page for one configuration value.
Bind is called on every build with a pointer to that value. A field of type T is passed as *T. Write edits through that pointer; the page is not the value itself.
type PageProvider ¶ added in v0.0.4
type PageProvider interface {
NewPage() Page
}
PageProvider is a configuration type that draws its own settings page.
Implement it on the field's type, not on the widget. NewPage is called once. The returned Page is kept and bound to the field on each build. A nested struct that does not implement PageProvider is a generated form instead.