[Bf-blender-cvs] [918e6cf] master: Fix T49635: column_flow Layout - last column is too small.

Bastien Montagne noreply at git.blender.org
Thu Oct 13 10:46:30 CEST 2016


Commit: 918e6cf4c9b74ff96ad06753ef9e541837eb3b22
Author: Bastien Montagne
Date:   Thu Oct 13 10:21:38 2016 +0200
Branches: master
https://developer.blender.org/rB918e6cf4c9b74ff96ad06753ef9e541837eb3b22

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.

===================================================================

M	source/blender/editors/interface/interface_layout.c

===================================================================

diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c
index b52068d..875522e 100644
--- a/source/blender/editors/interface/interface_layout.c
+++ b/source/blender/editors/interface/interface_layout.c
@@ -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);
 		}
 	}




More information about the Bf-blender-cvs mailing list