Skip to content

Class FormBuilder

Definition

Namespace: StardewUI.Widgets
Assembly: StardewUI.dll

Fluent builder style API for creating form-like tables within a view.

public class FormBuilder

Inheritance
Object ⇦ FormBuilder

Remarks

Useful for "settings" style views.

Members

Constructors

Name Description
FormBuilder(Int32, Int32) Fluent builder style API for creating form-like tables within a view.

Methods

Name Description
AddCustom(IView) Adds a custom row, which is simply a horizontal Lane consisting of the specified views, not including any label - i.e. the first view is flush with the labels on other rows.
AddField(string, string, IView) Adds a labeled control row, i.e. a field.
AddSection(string) Starts a new section by adding header text.
Build() Builds the form.
CreateSectionHeading(string) Creates the banner used as a section heading.
SetMargin(Edges) Configures the margin for the entire form.
SetPadding(Edges) Configures the padding for the entire form.

Details

Constructors

FormBuilder(int, int)

Fluent builder style API for creating form-like tables within a view.

public FormBuilder(int labelWidth, int fieldIndent);
Parameters

labelWidth   Int32
The width of the label column. Same for all rows.

fieldIndent   Int32
Pixel amount by which to indent the field rows, relative to any heading rows.

Remarks

Useful for "settings" style views.


Methods

AddCustom(IView)

Adds a custom row, which is simply a horizontal Lane consisting of the specified views, not including any label - i.e. the first view is flush with the labels on other rows.

public StardewUI.Widgets.FormBuilder AddCustom(StardewUI.IView views);
Parameters

views   IView
The views to display in this row.

Returns

FormBuilder

The current builder instance.

Remarks

Might be used for a row of confirmation buttons, a paragraph of help text, etc.


AddField(string, string, IView)

Adds a labeled control row, i.e. a field.

public StardewUI.Widgets.FormBuilder AddField(string title, string description, StardewUI.IView view);
Parameters

title   string
The field title, displayed on the left side.

description   string
Description of the field's value or purpose, displayed as a tooltip when hovering over the title text.

view   IView
The view for modifying the field's value.

Returns

FormBuilder

The current builder instance.


AddSection(string)

Starts a new section by adding header text.

public StardewUI.Widgets.FormBuilder AddSection(string title);
Parameters

title   string
The section title.

Returns

FormBuilder

The current builder instance.


Build()

Builds the form.

public StardewUI.IView Build();
Returns

IView

The view containing the form layout.


CreateSectionHeading(string)

Creates the banner used as a section heading.

public static StardewUI.IView CreateSectionHeading(string title);
Parameters

title   string
The section title.

Returns

IView

Section heading view.

Remarks

This is the standalone version of AddSection(string) that can be used by any views wanting to provide form-style section headings outside of an actual form.


SetMargin(Edges)

Configures the margin for the entire form.

public StardewUI.Widgets.FormBuilder SetMargin(StardewUI.Layout.Edges margin);
Parameters

margin   Edges
Margin outside the form.

Returns

FormBuilder

The current builder instance.


SetPadding(Edges)

Configures the padding for the entire form.

public StardewUI.Widgets.FormBuilder SetPadding(StardewUI.Layout.Edges padding);
Parameters

padding   Edges
Padding inside the form.

Returns

FormBuilder

The current builder instance.