particle/ramp: don’t add margins if all sub-items are zero-width

That is, if all sub-items are zero-width, make sure *we* return a zero
width.
This commit is contained in:
Daniel Eklöf 2021-08-25 13:58:20 +02:00
parent def90edde1
commit af0b7e57d8
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F

View file

@ -37,11 +37,13 @@ begin_expose(struct exposable *exposable)
{
struct eprivate *e = exposable->private;
exposable->width = (
exposable->particle->left_margin +
e->exposable->begin_expose(e->exposable) +
exposable->particle->right_margin);
int width = e->exposable->begin_expose(e->exposable);
assert(width >= 0);
if (width > 0)
width += exposable->particle->left_margin + exposable->particle->right_margin;
exposable->width = width;
return exposable->width;
}