mirror of
https://codeberg.org/dnkl/yambar.git
synced 2025-04-23 20:35:42 +02:00
particle/list: don’t adjust spacing if all sub-items are zero-width
That is, if all sub-items are zero-width, make sure *we* return a zero width, instead of a negative width.
This commit is contained in:
parent
ca43eb3016
commit
73e1d328c3
1 changed files with 15 additions and 4 deletions
|
@ -39,18 +39,29 @@ static int
|
||||||
begin_expose(struct exposable *exposable)
|
begin_expose(struct exposable *exposable)
|
||||||
{
|
{
|
||||||
const struct eprivate *e = exposable->private;
|
const struct eprivate *e = exposable->private;
|
||||||
|
bool have_at_least_one = false;
|
||||||
|
|
||||||
exposable->width = exposable->particle->left_margin;
|
exposable->width = 0;
|
||||||
|
|
||||||
for (size_t i = 0; i < e->count; i++) {
|
for (size_t i = 0; i < e->count; i++) {
|
||||||
struct exposable *ee = e->exposables[i];
|
struct exposable *ee = e->exposables[i];
|
||||||
e->widths[i] = ee->begin_expose(ee);
|
e->widths[i] = ee->begin_expose(ee);
|
||||||
|
|
||||||
|
assert(e->widths[i] >= 0);
|
||||||
|
|
||||||
|
if (e->widths[i] > 0) {
|
||||||
exposable->width += e->left_spacing + e->widths[i] + e->right_spacing;
|
exposable->width += e->left_spacing + e->widths[i] + e->right_spacing;
|
||||||
|
have_at_least_one = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (have_at_least_one) {
|
||||||
exposable->width -= e->left_spacing + e->right_spacing;
|
exposable->width -= e->left_spacing + e->right_spacing;
|
||||||
|
exposable->width += exposable->particle->left_margin;
|
||||||
exposable->width += exposable->particle->right_margin;
|
exposable->width += exposable->particle->right_margin;
|
||||||
|
} else
|
||||||
|
assert(exposable->width == 0);
|
||||||
|
|
||||||
return exposable->width;
|
return exposable->width;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue