]> git.tdb.fi Git - libs/gltk.git/commitdiff
Use the maximum item height for autosizing List
authorMikko Rasa <tdb@tdb.fi>
Thu, 19 Sep 2019 06:21:56 +0000 (09:21 +0300)
committerMikko Rasa <tdb@tdb.fi>
Thu, 19 Sep 2019 06:21:56 +0000 (09:21 +0300)
source/list.cpp

index 5d179e195c36c412785a17ec7d731f65856f420d..005f6fa8ea29cc2a57cd23152f46167dacf922a1 100644 (file)
@@ -71,18 +71,16 @@ void List::autosize_special(const Part &part, Geometry &ageom) const
                const Sides &margin = part.get_margin();
 
                unsigned max_w = 0;
-               unsigned total_h = 0;
+               unsigned max_h = 0;
                for(unsigned i=0; i<items.size(); ++i)
                {
                        Geometry igeom;
                        items[i]->autosize(igeom);
                        max_w = max(max_w, igeom.w);
-                       if(view_size==0 || i<view_size)
-                               total_h += igeom.h;
+                       max_h = max(max_h, igeom.h);
                }
 
-               if(!items.empty() && items.size()<view_size)
-                       total_h = total_h*view_size/items.size();
+               unsigned total_h = max_h*(view_size==0 ? items.size() : view_size);
 
                ageom.w = max(ageom.w, max_w+margin.left+margin.right);
                ageom.h = max(ageom.h, total_h+margin.top+margin.bottom);