X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fdropdown.cpp;h=50aced9fe9fcaafd4317884ea4b370caa2395b03;hb=b61361ee9f1f049fb3c22a38f68c757c7ca54cd0;hp=ddf5c9268500479655796caecf9bad0a1ec71e20;hpb=319cde3c06181ba1c3619567525002926d8b4889;p=libs%2Fgltk.git diff --git a/source/dropdown.cpp b/source/dropdown.cpp index ddf5c92..50aced9 100644 --- a/source/dropdown.cpp +++ b/source/dropdown.cpp @@ -28,22 +28,21 @@ void Dropdown::init() dropped = false; add(list); + list.set_view_all(); list.signal_item_selected.connect(sigc::mem_fun(this, &Dropdown::list_item_selected)); list.signal_autosize_changed.connect(sigc::mem_fun(this, &Dropdown::list_autosize_changed)); } -void Dropdown::autosize() +void Dropdown::autosize_special(const Part &part, Geometry &ageom) { - if(!style) - return; - - Widget::autosize(); - list.autosize_all(); - geom.w = max(geom.w, list.get_geometry().w); - - if(const Part *text_part = style->get_part("text")) + if(part.get_name()=="list") + { + list.autosize(); + ageom.w = max(ageom.w, list.get_geometry().w); + } + else if(part.get_name()=="text") { - const Sides &margin = text_part->get_margin(); + const Sides &margin = part.get_margin(); const GL::Font &font = style->get_font(); float font_size = style->get_font_size(); @@ -54,10 +53,10 @@ void Dropdown::autosize() unsigned w = static_cast(font.get_string_width(data.get_string(i))*font_size); max_w = max(max_w, w); } - geom.w = max(geom.w, max_w+margin.left+margin.right); + ageom.w = max(ageom.w, max_w+margin.left+margin.right); unsigned line_height = static_cast((font.get_ascent()-font.get_descent())*font_size); - geom.h = max(geom.h, line_height+margin.top+margin.bottom); + ageom.h = max(ageom.h, line_height+margin.top+margin.bottom); } rebuild(); @@ -73,7 +72,7 @@ void Dropdown::set_selected_index(int index) void Dropdown::rebuild_special(const Part &part) { if(part.get_name()=="text") - text.build(part, geom, part_cache); + text.build(part, state, geom, part_cache); else Widget::rebuild_special(part); } @@ -123,7 +122,7 @@ void Dropdown::list_autosize_changed() void Dropdown::resize_list() { - list.autosize_all(); + list.autosize(); Geometry lgeom = list.get_geometry(); lgeom.x = 0; lgeom.y = -lgeom.h;