configui

package
v0.0.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 7, 2026 License: MIT Imports: 10 Imported by: 0

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

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]) Build

func (e *Editor[T]) Build(context *guigui.Context, adder *guigui.ChildAdder) error

func (*Editor[T]) IsOpen

func (e *Editor[T]) IsOpen() bool

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))

func (*Editor[T]) SetOpen

func (e *Editor[T]) SetOpen(open bool)

func (*Editor[T]) SetTarget

func (e *Editor[T]) SetTarget(v *T)

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

type Page interface {
	guigui.Widget
	Bind(v any)
}

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL