proc toAutoFormMenu[T](app: T, sizeRequest: tuple[x,y: int] = (400, 700), ignoreFields: static seq[string]): Widget = ## Provides a form for every field in a given `app` instance. ## The form is provided as a Popover that can be activated via a Menu-Button ## `ignoreFields` defines a list of field names to ignore for the form generation. ## `sizeRequest` defines the requested size for the popover. ## Displays a dummy widget if there is no `toFormField` implementation for a field with a custom type. var fieldWidgets: seq[Widget] = @[] const privateGeneralFields = ["app", "viewed", "stateRef"] for name, value in app[].fieldPairs: when name notin privateGeneralFields and name notin ignoreFields: let field: ptr = value.addr let fieldWidget = app.toFormField(field, name) fieldWidgets.add(fieldWidget) result = gui: MenuButton: icon = "document-properties" style = [ButtonFlat] Popover(): Box(orient = OrientY): sizeRequest = sizeRequest ScrolledWindow: PreferencesGroup: title = "Fields" margin = 12 for field in fieldWidgets: insert field # Notice the `insert field`