X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Flist.cpp;h=a4550c4ee9ad220dfd22336657894b9cca13de9a;hb=729cb06f85e2888a7ac1e72375380257936106c9;hp=653a40c92bc1195e7b75276a50f08fc37891ff29;hpb=d155c3559f7801825a2326b4186b3c7d18c23214;p=libs%2Fgltk.git diff --git a/source/list.cpp b/source/list.cpp index 653a40c..a4550c4 100644 --- a/source/list.cpp +++ b/source/list.cpp @@ -55,7 +55,7 @@ List::~List() delete data; } -void List::autosize_special(const Part &part, Geometry &ageom) +void List::autosize_special(const Part &part, Geometry &ageom) const { if(part.get_name()=="items") { @@ -65,7 +65,8 @@ void List::autosize_special(const Part &part, Geometry &ageom) unsigned total_h = 0; for(unsigned i=0; iget_geometry(); + Geometry igeom; + items[i]->autosize(igeom); max_w = max(max_w, igeom.w); if(view_size==0 || iget_string(index)); add(*item); - item->autosize(); - item->signal_autosize_changed.connect(sigc::bind(sigc::mem_fun(this, &List::item_autosize_changed), item)); + item->signal_autosize_changed.connect(sigc::mem_fun(this, &List::item_autosize_changed)); return item; } @@ -213,10 +213,9 @@ void List::reposition_slider() } } -void List::item_autosize_changed(Item *item) +void List::item_autosize_changed() { signal_autosize_changed.emit(); - item->autosize(); reposition_items(); } @@ -228,15 +227,16 @@ void List::reposition_items() if(const Part *items_part = style->get_part("items")) { const Sides &margin = items_part->get_margin(); - unsigned w = geom.w-margin.left-margin.right; - unsigned y = geom.h-margin.top; + unsigned w = geom.w-min(geom.w, margin.left+margin.right); + unsigned y = geom.h-min(geom.h, margin.top); for(unsigned i=0; iset_visible(false); else { - Geometry igeom = items[i]->get_geometry(); + Geometry igeom; + items[i]->autosize(igeom); if(igeom.h+margin.bottom<=y) { items[i]->set_visible(true); @@ -344,14 +344,15 @@ void List::DataObserver::refresh_item(unsigned i) } -void List::Item::autosize_special(const Part &part, Geometry &ageom) +void List::Item::autosize_special(const Part &part, Geometry &ageom) const { if(part.get_name()=="children") { const Sides &margin = part.get_margin(); for(list::const_iterator i=children.begin(); i!=children.end(); ++i) { - const Geometry &cgeom = (*i)->widget->get_geometry(); + Geometry cgeom; + (*i)->widget->autosize(cgeom); ageom.w = max(ageom.w, cgeom.x+cgeom.w+margin.right); ageom.h = max(ageom.h, cgeom.y+cgeom.h+margin.top); }