SecondHalfGames / yakui

yakui is a declarative Rust UI library for games
Apache License 2.0
221 stars 18 forks source link

Main axis constraints are lost by `List` #104

Open LPGhatguy opened 10 months ago

LPGhatguy commented 10 months ago
constrained(Constraints::tight(Vec2::splat(100.0)), || {
    row(|| {
        text("Lorem ipsum dolor sit amet blah blah blah I just want some long text here");
    });
});

In this snippet, the text bleeds outside of the constrained area because List throws away the main axis constraints when laying out non-flex objects.

A workaround is to wrap the objects that need to be constrained in expanded or flexible with a non-zero flex factor:

constrained(Constraints::tight(Vec2::splat(100.0)), || {
    row(|| {
        expanded(|| {
            text("Lorem ipsum dolor sit amet blah blah blah I just want some long text here");
        });

        // OR

        flexible(1.0, || {
            text("Lorem ipsum dolor sit amet blah blah blah I just want some long text here");
        });
    });
});