Skip to content

LayoutJob should use a build pattern #8220

@j-ac

Description

@j-ac

Is your feature request related to a problem? Please describe.
It is quite verbose to create a layout job and then change a parameter that is not in the constructor:

let mut layout = LayoutJob::simple(
     // ...
);

layout.halign = egui::Align::Center;

It is also not ideal that this pattern requires the layout to be declared mutable unnecessarily.

Describe the solution you'd like
LayoutJob should have a builder pattern api where it consumes the self and returns a LayoutJob. Eg the above code snippet would be

let layout = LayoutJob::simple(
     // ...
).halign(egui::Align::Center);

Describe alternatives you've considered
The only alternative is keeping it as-is. But this is a very simple API change that would bring this struct into step with the rest of egui.

Additional context
N/A

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions