- items.insert(items.begin()+i, v);
- recalculate_parameters();
+ if(const Part *items_part = style->get_part("items"))
+ {
+ const Sides &margin = items_part->get_margin();
+
+ unsigned max_w = 0;
+ unsigned total_h = 0;
+ for(unsigned i=0; i<items.size(); ++i)
+ {
+ items[i]->autosize();
+ const Geometry &igeom = items[i]->get_geometry();
+ max_w = max(max_w, igeom.w);
+ if(i<n)
+ total_h += igeom.h;
+ }
+
+ if(!items.empty() && items.size()<n)
+ total_h = total_h*n/items.size();
+
+ geom.w = max(geom.w, max_w+margin.left+margin.right);
+ geom.h = max(geom.h, total_h+margin.top+margin.bottom);
+ }
+
+ check_view_range();
+ rebuild();
+}
+
+void List::autosize_all()
+{
+ autosize_rows(data->size());