]> git.tdb.fi Git - libs/gltk.git/blobdiff - source/widget.cpp
Combine common parts of Column and Row into LinearArrangement
[libs/gltk.git] / source / widget.cpp
index bbd2e8877af608b1255d21eb10d9b23d2506fba4..1113c971974f84779a3ca863df1b57f4ddf973ea 100644 (file)
@@ -30,18 +30,12 @@ Widget::~Widget()
 
 void Widget::set_position(int x, int y)
 {
-       geom.x = x;
-       geom.y = y;
-       on_geometry_change();
-       rebuild();
+       set_geometry(Geometry(x, y, geom.w, geom.h));
 }
 
 void Widget::set_size(unsigned w, unsigned h)
 {
-       geom.w = w;
-       geom.h = h;
-       on_geometry_change();
-       rebuild();
+       set_geometry(Geometry(geom.x, geom.y, w, h));
 }
 
 void Widget::autosize()
@@ -52,8 +46,10 @@ void Widget::autosize()
        for(Style::PartSeq::const_iterator i=parts.begin(); i!=parts.end(); ++i)
                if(i->get_name().empty())
                {
-                       geom.w = max(geom.w, i->get_geometry().w);
-                       geom.h = max(geom.h, i->get_geometry().h);
+                       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);
                }
 }