X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fdropdown.cpp;h=7dc0d3550bcaf7d8953ec2a8b5d1013355ad69fd;hb=1d6cebd9f1795a22d6be47a7a049496b89de46f7;hp=50aced9fe9fcaafd4317884ea4b370caa2395b03;hpb=b61361ee9f1f049fb3c22a38f68c757c7ca54cd0;p=libs%2Fgltk.git diff --git a/source/dropdown.cpp b/source/dropdown.cpp index 50aced9..7dc0d35 100644 --- a/source/dropdown.cpp +++ b/source/dropdown.cpp @@ -33,11 +33,12 @@ void Dropdown::init() list.signal_autosize_changed.connect(sigc::mem_fun(this, &Dropdown::list_autosize_changed)); } -void Dropdown::autosize_special(const Part &part, Geometry &ageom) +void Dropdown::autosize_special(const Part &part, Geometry &ageom) const { if(part.get_name()=="list") { - list.autosize(); + Geometry lgeom; + list.autosize(lgeom); ageom.w = max(ageom.w, list.get_geometry().w); } else if(part.get_name()=="text") @@ -58,8 +59,6 @@ void Dropdown::autosize_special(const Part &part, Geometry &ageom) unsigned line_height = static_cast((font.get_ascent()-font.get_descent())*font_size); ageom.h = max(ageom.h, line_height+margin.top+margin.bottom); } - - rebuild(); } void Dropdown::set_selected_index(int index) @@ -98,6 +97,7 @@ void Dropdown::button_press(int x, int y, unsigned btn) else if(btn==1) { dropped = true; + resize_list(); set_state(ACTIVE); signal_grab_pointer.emit(); } @@ -122,8 +122,8 @@ void Dropdown::list_autosize_changed() void Dropdown::resize_list() { - list.autosize(); - Geometry lgeom = list.get_geometry(); + Geometry lgeom; + list.autosize(lgeom); lgeom.x = 0; lgeom.y = -lgeom.h; lgeom.w = max(geom.w, lgeom.w); @@ -137,7 +137,10 @@ void Dropdown::resize_list() { const Geometry &rgeom = root->get_geometry(); if(lgeom.h*2>rgeom.h) + { lgeom.h = rgeom.h/2; + lgeom.y = -lgeom.h; + } if(root_y+lgeom.y<0) lgeom.y = -root_y; if(root_y+lgeom.y+lgeom.h>rgeom.h)