X-Git-Url: http://git.tdb.fi/?p=libs%2Fgltk.git;a=blobdiff_plain;f=source%2Fdropdown.cpp;h=2aac55ec511dc184b5d7952901ebc7bbe5b6ece0;hp=ce0ba71f642c45ca7f672e4bf8e80f78d8fb60ed;hb=d2d5b4c4dedf90a42dd2baff8334318b1d000f64;hpb=c8291177b545ec81930603a5915234a60296db51 diff --git a/source/dropdown.cpp b/source/dropdown.cpp index ce0ba71..2aac55e 100644 --- a/source/dropdown.cpp +++ b/source/dropdown.cpp @@ -33,18 +33,16 @@ void Dropdown::init() 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(); - 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(); @@ -55,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();