[FR] FlexItem::Margin initialiser

Instead of having to do something like

        FlexItem::Margin margin(10.0);
        margin.bottom = 0.0;
        
        flexBox.items.add (FlexItem(header)
                           .withHeight(100.0)
                           .withFlex(0.15)
                           .withMargin(margin));
                
        flexBox.items.add (FlexItem(body)
                           .withFlex(0.75)
                           .withMargin(10.0));

It would flow much nicer if we could have a detailed initialiser and do e.g.

        flexBox.items.add (FlexItem(header)
                           .withHeight(100.0)
                           .withFlex(0.15)
                           .withMargin({10.0, 10.0, 10.0, 0.0}));  // left, top, right, bottom
                
        flexBox.items.add (FlexItem(body)
                           .withFlex(0.75)
                           .withMargin(10.0));

Yep, good request, will add that!

1 Like

Thanks.

While we’re there - .withAlignSelf and .withAssociatedComponent would also be useful!

Thanks for adding this to develop

I left a comment there:
Can we have this the same as the web standard? i.e. top, right, bottom, left.
Currently its left, right, top, bottom.
Thanks

Ah, my poor knowledge of web-standards… Yes, good call, I’ll change that before anyone starts using it!

1 Like

Thanks, I added withSelfAlign on FlexItem:

Saves me having to create a FlexItem object before adding it to a FlexBox.