configui

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 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 CustomGroup -> custom widget

Index

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

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

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

Jump to

Keyboard shortcuts

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