X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fdropdown.cpp;h=d120c85856e60b76730ef24f4cb4b0d74e99f61a;hb=deb15ee122f963ca41121e8358d5845401ac43ca;hp=5901414f3a033a9ad786a537d70e93163840da4e;hpb=787dd5572e904a87686e7309401b86e0c528d823;p=libs%2Fgltk.git diff --git a/source/dropdown.cpp b/source/dropdown.cpp index 5901414..d120c85 100644 --- a/source/dropdown.cpp +++ b/source/dropdown.cpp @@ -112,17 +112,9 @@ void Dropdown::on_geometry_change() void Dropdown::resize_list() { - // XXX This is a hack. - unsigned n_items = list.get_n_items(); - const Style &stl = list.get_style(); - const GL::Font &font = *stl.get_font(); - unsigned h = min(max(n_items, 1U), 10U)*static_cast((font.get_ascent()-font.get_descent())*font.get_default_size()); - 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)); + list.autosize(); + const Geometry &lgeom = list.get_geometry(); + list.set_geometry(Geometry(0, -lgeom.h, max(geom.w, lgeom.w), lgeom.h)); } void Dropdown::list_item_selected(unsigned index, const std::string &item)