]> git.tdb.fi Git - libs/gltk.git/blobdiff - source/layout.cpp
Make autosize_special const and add a const autosize overload
[libs/gltk.git] / source / layout.cpp
index 7902902abf2541082b0d455de9a185145545a84c..bee972d903ab242415f992767247e425e9109922 100644 (file)
@@ -340,6 +340,7 @@ void Layout::solve_constraints(int dir, SolveMode mode)
        remaining three are slack columns; see below for their purposes. */
        LinearProgram linprog(n_active_slots*5+n_slack_constraints[dir]+1);
        float weight = slots.size();
+       unsigned k = n_active_slots*5;
        for(list<Slot *>::iterator i=slots.begin(); i!=slots.end(); ++i)
        {
                if((*i)->index<0)
@@ -396,7 +397,6 @@ void Layout::solve_constraints(int dir, SolveMode mode)
 
                /* Add rows for user-defined constraints.  Constraints are always added
                in pairs, so it's only necessary to create a row for one half. */
-               unsigned k = n_active_slots*5;
                for(list<Constraint>::iterator j=(*i)->constraints.begin(); j!=(*i)->constraints.end(); ++j)
                        if(j->target.index>(*i)->index && (j->type&1)==dir)
                        {
@@ -470,16 +470,13 @@ Layout::Slot::Slot(Layout &l, Widget &w):
 
 void Layout::Slot::autosize_changed()
 {
-       widget.autosize();
-       autosize_geom = widget.get_geometry();
+       widget.autosize(autosize_geom);
 
        if(!widget.is_visible() && !ghost)
                return;
 
-       // 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
+       // Only trigger an update if the widget won't fit in its current area.
+       if(autosize_geom.w>geom.w || autosize_geom.h>geom.h)
        {
                layout.container->signal_autosize_changed.emit();
                layout.update();