forked from AuroraMiddleware/gtk
grid: Work harder for tight homogeneous allocation
When doing homogeneous allocation in the presence of overlapping spanning children, we need to avoid uneven line allocations, otherwise, the final homogenization will blow up the size request of the grid. https://bugzilla.gnome.org/show_bug.cgi?id=671170
This commit is contained in:
parent
897dc37289
commit
47c190a1b7
@ -770,8 +770,27 @@ gtk_grid_request_spanning (GtkGridRequest *request,
|
||||
/* If we need to request more space for this child to fill
|
||||
* its requisition, then divide up the needed space amongst the
|
||||
* lines it spans, favoring expandable lines if any.
|
||||
*
|
||||
* When doing homogeneous allocation though, try to keep the
|
||||
* line allocations even, since we're going to force them to
|
||||
* be the same anyway, and we don't want to introduce unnecessary
|
||||
* extra space.
|
||||
*/
|
||||
if (span_minimum < minimum)
|
||||
{
|
||||
if (linedata->homogeneous)
|
||||
{
|
||||
gint total, m;
|
||||
|
||||
total = minimum - (attach->span - 1) * linedata->spacing;
|
||||
m = total / attach->span + (total % attach->span ? 1 : 0);
|
||||
for (i = 0; i < attach->span; i++)
|
||||
{
|
||||
line = &lines->lines[attach->pos - lines->min + i];
|
||||
line->minimum = MAX(line->minimum, m);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
extra = minimum - span_minimum;
|
||||
expand = span_expand;
|
||||
@ -787,8 +806,23 @@ gtk_grid_request_spanning (GtkGridRequest *request,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (span_natural < natural)
|
||||
{
|
||||
if (linedata->homogeneous)
|
||||
{
|
||||
gint total, n;
|
||||
|
||||
total = natural - (attach->span - 1) * linedata->spacing;
|
||||
n = total / attach->span + (total % attach->span ? 1 : 0);
|
||||
for (i = 0; i < attach->span; i++)
|
||||
{
|
||||
line = &lines->lines[attach->pos - lines->min + i];
|
||||
line->natural = MAX(line->natural, n);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
extra = natural - span_natural;
|
||||
expand = span_expand;
|
||||
@ -806,6 +840,7 @@ gtk_grid_request_spanning (GtkGridRequest *request,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Marks empty and expanding lines and counts them.
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user