Skip to content

Remove StagingVec in favor of VecWidget #22

@Tomaz-Vieira

Description

@Tomaz-Vieira

Initially, the model builder gui was relying on the StagingVec stateful widget to produce list-like fields. The StagingVec widget contains a list of widgets inside it, and if those widgets implement StatefulWidget, then StagingVec does as well, automatically, doing what one might expect: it renders a list on draw_and_parse by going over all internal widgets and drawing them, and it returns a Vec on .state(), that is collected from the .state() of the inner widgets.

The problem is that if one wants to render a list in slightly different ways, one either has to add generic-parameters to StagingVec (like staging Vec's Conf generic parameter) or maybe add some function-like values to the widget.

Sticking to the core design sensibilities of egui, though, there is now the VecWidget type; it is a Widget in the same way that buttons and checkboxes in egui are also widgets: it's a bundle of parameters that can then be passed to a function that actually draws the widget. This style allows for closures (=lambdas) to be passed in that change the way in which the items in the list are rendered, and also the way the headers of the list are rendered.

Most of the code has already transitioned from StagingVec to VecWidget, but there are still a few places that could use the new style, like AppState1.staging_tags.

In the future, the same style should be used to replace StagingOpt with an analogous, egui-style, non-stateful widget.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions