add an index parameter to layout item
Extract layout attributes calculation into the layout section