Fix T49635: column_flow Layout - last column is too small.

Column flow layout was abuse ui_item_fit in a weird way, which was
broken for last column items.

Now rather use own code, which basically spread available width as
equally as possible between all columns.
This commit is contained in:
Bastien Montagne 2016-10-13 10:21:38 +02:00
parent 786c0966ec
commit 918e6cf4c9
Notes: blender-bot 2023-04-19 22:54:54 +02:00
Referenced by issue #49635, column_flow Layout - last column is too small
1 changed files with 9 additions and 4 deletions

View File

@ -2488,10 +2488,12 @@ static void ui_litem_layout_column_flow(uiLayout *litem)
/* create column per column */
col = 0;
w = (litem->w - (flow->totcol - 1) * style->columnspace) / flow->totcol;
for (item = litem->items.first; item; item = item->next) {
ui_item_size(item, NULL, &itemh);
itemw = ui_item_fit(1, x - litem->x, flow->totcol, w, col == flow->totcol - 1, litem->alignment);
ui_item_size(item, &itemw, &itemh);
itemw = (litem->alignment == UI_LAYOUT_ALIGN_EXPAND) ? w : min_ii(w, itemw);
y -= itemh;
emy -= itemh;
ui_item_position(item, x, y, itemw, itemh);
@ -2500,10 +2502,13 @@ static void ui_litem_layout_column_flow(uiLayout *litem)
/* decide to go to next one */
if (col < flow->totcol - 1 && emy <= -emh) {
x += itemw + style->columnspace;
x += w + style->columnspace;
y = litem->y;
emy = 0; /* need to reset height again for next column */
col++;
/* (< remaining width > - < space between remaining columns >) / <remamining columns > */
w = ((litem->w - (x - litem->x)) - (flow->totcol - col - 1) * style->columnspace) / (flow->totcol - col);
}
}