- list.autosize();
- const Geometry &lgeom = list.get_geometry();
- list.set_geometry(Geometry(0, -lgeom.h, max(geom.w, lgeom.w), lgeom.h));
+ Geometry lgeom;
+ list.autosize(lgeom);
+ lgeom.x = 0;
+ lgeom.y = -lgeom.h;
+ lgeom.w = max(geom.w, lgeom.w);
+ int root_x = geom.x;
+ int root_y = geom.y;
+ for(Widget *p=parent; p; p=p->get_parent())
+ {
+ root_x += p->get_geometry().x;
+ root_y += p->get_geometry().y;
+ if(Root *root = dynamic_cast<Root *>(p))
+ {
+ const Geometry &rgeom = root->get_geometry();
+ if(lgeom.h*2>rgeom.h)
+ {
+ lgeom.h = rgeom.h/2;
+ lgeom.y = -lgeom.h;
+ }
+ if(root_y+lgeom.y<0)
+ lgeom.y = -root_y;
+ if(root_y+lgeom.y+lgeom.h>rgeom.h)
+ lgeom.y = rgeom.h-lgeom.h-root_y;
+ if(root_x+lgeom.x+lgeom.w>rgeom.w)
+ lgeom.x = rgeom.w-lgeom.w-root_x;
+ break;
+ }
+ }
+ list.set_geometry(lgeom);