From: Mikko Rasa Date: Wed, 6 Nov 2013 11:42:35 +0000 (+0200) Subject: Fix list autosizing logic X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=d9bf5e84b71e634b68011e321ee13caa3299adbf;p=libs%2Fgltk.git Fix list autosizing logic --- diff --git a/source/list.cpp b/source/list.cpp index 461d5e4..c5dddf5 100644 --- a/source/list.cpp +++ b/source/list.cpp @@ -65,7 +65,8 @@ void List::autosize_special(const Part &part, Geometry &ageom) const 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 +214,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 +228,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); diff --git a/source/list.h b/source/list.h index 6f6aec1..0761caf 100644 --- a/source/list.h +++ b/source/list.h @@ -182,7 +182,7 @@ private: virtual void on_style_change(); void reposition_slider(); - void item_autosize_changed(Item *); + void item_autosize_changed(); void reposition_items(); void check_view_range(); void slider_value_changed(double);