Skip to content

Remove the Val::try_* arithmetic functions #9571

@ickshonpe

Description

@ickshonpe

What problem does this solve or what need does it fill?

Wondering if these are useful at all, or even make sense.
They aren't used internally or in any of the examples.

let mut r = UiRect::new(Val::Px(10.), Val::Percent(5.), Val::Auto, Val::VMin(50.));

// Just feels like nonsense; they don't compose or handle failure well
r.left.try_sub_assign(Val::Px(10.).unwrap();
r.right = r.right.try_add(Val::Px(10.)).unwrap_or(r.right.try_add(Val::Percent(10.)));

The try_*_assign_with_size functions seem problematic too:

r.bottom.try_add_assign_with_context(Val::Px(50.), 100., vec2(800., 600.));

r.bottom equals Val::VMin(50.) and is resolved to 600. * 50. / 100. = 300..

So r.bottom is assigned the value: Val::Px(350.).

This might seem like it's okay. But now r.bottom is no longer responsive to changes in the viewport size.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-UIGraphical user interfaces, styles, layouts, and widgetsC-Code-QualityA section of code that is hard to understand or changeD-TrivialNice and easy! A great choice to get started with Bevy

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions