[Maya] Combining scrollLayout and flowLayout (mel)

Hi there,

I’m trying some dynamic window setup via a formLayout and a flowLayout but I’m struggling to combine them with a scrollLayout in-between. I’m creating a list with a lot of items inside a medium sized window, I would like the items to wrap to the next line when they reach the border of the window, while keeping the ability to resize the whole window in any manner (so avoiding fixed sizes).

Currently what I get is no wrapping, because I believe that the flowLayout is unaware of the parent widget size (the scrollLayout). But maybe I’m doing it wrong ?

Current mel script setup :

	string $form = `formLayout -numberOfDivisions 100`;
    string $Scroll = `scrollLayout -childResizable 1 fromMaterialScrollLayout`;
	string $Flow = `flowLayout -wrap 1 -columnSpacing 2`;
		button;
		button;
		button;
		button;
		button;
		button;
		button;
		button;
		button;
		button;
		button;
	setParent ..;
setParent ..;

string $Button1 = `button -l "Refresh" -bgc 0.3 0.2 0.2 -h 32 -c "fromRefreshMaterialList"`;

formLayout -edit
	-attachForm     $Scroll     "top"    5
	-attachForm     $Scroll     "left"   5
	-attachControl  $Scroll     "bottom" 5 $Button1
	-attachPosition $Scroll     "right"  5 100

	-attachNone	$Button1	"top"
	-attachForm	$Button1	"bottom"	5
	-attachForm	$Button1	"left"		4
	-attachForm	$Button1	"right"		4
$form;

FlowLayouts have unusual resize behavior, because they can accomodate the same content in different ways. You might want to try a GridLayout, RowColumnLayout or just a plain old ColumnLayout instead.

I have realised the flowlayout needs height set explicitly for the wrapping flag to work, like you have to reserve the extra space for items to flow into. So if that needs to be dynamic, think you will have to calculate it based on content.