Cassowary: add extra constraints for Min(v)/Max(v).

These added weak constraints prevent zero width/height widgets when combining Min(v)/Max(v) together in a chunk.

The UI will now reflow correctly when (re)sizing, gracefully preserving Max(v) constraints as much as possible.
pull/647/head
Simon Allen 2 years ago
parent a6b25a4877
commit 4a58e86459

@ -260,6 +260,16 @@ fn split(area: Rect, layout: &Layout) -> Vec<Rect> {
Constraint::Min(v) => elements[i].width | GE(WEAK) | f64::from(v),
Constraint::Max(v) => elements[i].width | LE(WEAK) | f64::from(v),
});
match *size {
Constraint::Min(v) => {
ccs.push(elements[i].width | EQ(WEAK) | f64::from(v));
}
Constraint::Max(v) => {
ccs.push(elements[i].width | EQ(WEAK) | f64::from(v));
}
_ => {}
}
}
}
Direction::Vertical => {
@ -282,6 +292,16 @@ fn split(area: Rect, layout: &Layout) -> Vec<Rect> {
Constraint::Min(v) => elements[i].height | GE(WEAK) | f64::from(v),
Constraint::Max(v) => elements[i].height | LE(WEAK) | f64::from(v),
});
match *size {
Constraint::Min(v) => {
ccs.push(elements[i].height | EQ(WEAK) | f64::from(v));
}
Constraint::Max(v) => {
ccs.push(elements[i].height | EQ(WEAK) | f64::from(v));
}
_ => {}
}
}
}
}

Loading…
Cancel
Save