This avoids having to autosize all widgets in the layout every time one of
them changes, and allows checking whether an update is actually needed.
- for(list<Slot *>::iterator i=slots.begin(); i!=slots.end(); ++i)
- {
- (*i)->widget.autosize();
- (*i)->geom = (*i)->widget.get_geometry();
- }
-
solve_constraints(HORIZONTAL);
solve_constraints(VERTICAL);
solve_constraints(HORIZONTAL);
solve_constraints(VERTICAL);
LinearProgram::Row row = linprog.add_row();
row[(*i)->index*5+1] = 1;
row[(*i)->index*5+4] = -1;
LinearProgram::Row row = linprog.add_row();
row[(*i)->index*5+1] = 1;
row[(*i)->index*5+4] = -1;
- row.back() = (*i)->geom.*(ptrs.dim);
+ row.back() = (*i)->autosize_geom.*(ptrs.dim);
}
/* Add rows for user-defined constraints. Below/above and left/right of
}
/* Add rows for user-defined constraints. Below/above and left/right of
{
vert_pack.gravity = 1;
widget.signal_autosize_changed.connect(sigc::mem_fun(this, &Slot::autosize_changed));
{
vert_pack.gravity = 1;
widget.signal_autosize_changed.connect(sigc::mem_fun(this, &Slot::autosize_changed));
+ widget.autosize();
+ autosize_geom = widget.get_geometry();
}
void Layout::Slot::autosize_changed()
{
}
void Layout::Slot::autosize_changed()
{
+ widget.autosize();
+ autosize_geom = widget.get_geometry();
+
+ // If the widget fits in the area it had, just leave it there.
+ if(autosize_geom.w<=geom.w && autosize_geom.h<=geom.h)
+ widget.set_geometry(geom);
+ else
+ layout.update();
Layout &layout;
unsigned index;
Widget &widget;
Layout &layout;
unsigned index;
Widget &widget;
+ Geometry autosize_geom;
Geometry geom;
std::list<Constraint> constraints;
Packing horiz_pack;
Geometry geom;
std::list<Constraint> constraints;
Packing horiz_pack;