]> git.tdb.fi Git - libs/gltk.git/blobdiff - source/dropdown.cpp
Add method to get a Part by name
[libs/gltk.git] / source / dropdown.cpp
index b911df370de3579e89d3430a8882362346071e14..5901414f3a033a9ad786a537d70e93163840da4e 100644 (file)
@@ -117,12 +117,11 @@ void Dropdown::resize_list()
        const Style &stl = list.get_style();
        const GL::Font &font = *stl.get_font();
        unsigned h = min(max(n_items, 1U), 10U)*static_cast<unsigned>((font.get_ascent()-font.get_descent())*font.get_default_size());
-       for(std::list<Part>::const_iterator i=stl.get_parts().begin(); i!=stl.get_parts().end(); ++i)
-               if(i->get_name()=="items")
-               {
-                       const Sides &margin = i->get_margin();
-                       h += margin.top+margin.bottom;
-               }
+       if(const Part *items_part = stl.get_part("items"))
+       {
+               const Sides &margin = items_part->get_margin();
+               h += margin.top+margin.bottom;
+       }
        list.set_geometry(Geometry(0, -h, geom.w, h));
 }