bytestring-net / bevy_lunex

Blazingly fast path based retained layout engine for Bevy entities, built around vanilla Bevy ECS.
https://bytestring-net.github.io/bevy_lunex/
Apache License 2.0
512 stars 21 forks source link

Widget building ergonomics #8

Closed UkoeHB closed 10 months ago

UkoeHB commented 11 months ago

I think widget builders would improve ergonomics substantially. It doesn't seem like element builders would be quite as useful though.

Before:

let slider_bar = lunex::Widget::create(
        &mut ui,
        root.end("slider_bar"),
        lunex::RelativeLayout::new()
            .with_rel_1(Vec2 { x: slider_x_left, y: 49.0 })
            .with_rel_2(Vec2 { x: slider_x_right, y: 51.0 })
    ).unwrap();

After:

let slider_bar = lunex::RelativeWidgetBuilder::new()
    .with_rel_1(Vec2 { x: slider_x_left, y: 49.0 })
    .with_rel_2(Vec2 { x: slider_x_right, y: 51.0 })
    .build(&mut ui, root.end("slider_bar"))
    .unwrap();
IDEDARY commented 11 months ago

Interesting... This is a great idea. I like it. I will add this once I do another iteration on the container part of the lib.

IDEDARY commented 10 months ago

Will be added in 0.0.7 release 🥂

let menu = RelativeLayout::new().build(tree, "Menu")?;
let boundary = SolidLayout::new().with_size(5.0, 10.0).build(tree, menu.end("Boundary"))?;