Type Dialog

type Dialog struct {
	// contains filtered or unexported fields
}

Dialog is a modal Vega dialog declaration. Begin keeps its layer and focus scope active so callers can paint custom body content before End.

Constructors

BeginDialog#

func BeginDialog(canvas *ui.Canvas, theme ui.Theme, viewport ui.Rect, options DialogOptions) Dialog

BeginDialog creates a dialog declaration without retaining runtime state.

Methods

Actions#

func (dialog Dialog) Actions(layout DialogLayout, actions ...ButtonAction)

Actions paints the footer's buttons against its right edge, in the order given, so the last one sits at the corner (see ButtonRow for the layout). A disabled dialog makes every action inert. Call it between Begin and End. It needs the button recipe.

layout := dialog.Begin("Delete host?", "This cannot be undone.")
dialog.Actions(layout,
	components.ButtonAction{ID: cancelID, Label: "Cancel", Variant: components.ButtonOutline},
	components.ButtonAction{ID: deleteID, Label: "Delete", Variant: components.ButtonDestructive},
)
dialog.End()

Begin#

func (dialog Dialog) Begin(title, description string) DialogLayout

Begin paints the backdrop and surface, then leaves the modal layer and focus scope active for caller-owned body content.

Disabled#

func (dialog Dialog) Disabled() Dialog

Disabled keeps dialog actions in the semantic tree while making them inert.

End#

func (dialog Dialog) End()

End closes the focus scope and layer, then installs modal focus and Escape routing. It must match a successful Begin call. It also ends what the dialog animates in and out: the dialog is not animated without it.

Layout#

func (dialog Dialog) Layout(description string) DialogLayout

Layout is where the parts of the dialog go for a viewport, without painting anything: Begin paints at exactly these rectangles. The description wraps to the dialog's width, so the header grows with its lines; a canvas is needed to measure them, and without one the description counts as a single line.

Paint#

func (dialog Dialog) Paint(title, description string) DialogLayout

Paint paints a complete title/description dialog and closes its layer scope.

WithoutCloseButton#

func (dialog Dialog) WithoutCloseButton() Dialog

WithoutCloseButton hides the standard top-right close action.