]> git.tdb.fi Git - libs/gltk.git/blobdiff - source/widget.cpp
Refactor widget autosizing
[libs/gltk.git] / source / widget.cpp
index f642004e07c3825fc1a79432f7a3acc237c1dadc..7496f8bdda1e849c3f35768d2d2ca6f29a11f503 100644 (file)
@@ -43,17 +43,22 @@ void Widget::autosize()
        if(!style)
                return;
 
-       geom.w = 0;
-       geom.h = 0;
+       Geometry ageom;
        const Style::PartSeq &parts = style->get_parts();
        for(Style::PartSeq::const_iterator i=parts.begin(); i!=parts.end(); ++i)
+       {
                if(i->get_name().empty())
                {
                        const Geometry &pgeom = i->get_geometry();
                        const Sides &pmargin = i->get_margin();
-                       geom.w = max(geom.w, pgeom.w+pmargin.left+pmargin.right);
-                       geom.h = max(geom.h, pgeom.h+pmargin.top+pmargin.bottom);
+                       ageom.w = max(ageom.w, pgeom.w+pmargin.left+pmargin.right);
+                       ageom.h = max(ageom.h, pgeom.h+pmargin.top+pmargin.bottom);
                }
+               else
+                       autosize_special(*i, ageom);
+       }
+
+       set_geometry(ageom);
 }
 
 void Widget::set_geometry(const Geometry &g)