From: Mikko Rasa Date: Tue, 21 Jan 2014 23:03:31 +0000 (+0200) Subject: Improve Dropdown list management X-Git-Url: http://git.tdb.fi/?p=libs%2Fgltk.git;a=commitdiff_plain;h=96df5b14a964da5a592a36e10a23022d5649462a;hp=1d6cebd9f1795a22d6be47a7a049496b89de46f7 Improve Dropdown list management Having the list marked as visible when it shouldn't be could cause trouble in some corner cases. There's no need to resize the list if it isn't visible. --- diff --git a/source/dropdown.cpp b/source/dropdown.cpp index 7dc0d35..e483033 100644 --- a/source/dropdown.cpp +++ b/source/dropdown.cpp @@ -28,6 +28,7 @@ void Dropdown::init() dropped = false; add(list); + list.set_visible(false); 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)); @@ -90,6 +91,7 @@ void Dropdown::button_press(int x, int y, unsigned btn) if(!click_focus) { dropped = false; + list.set_visible(false); clear_state(ACTIVE); signal_ungrab_pointer.emit(); } @@ -97,6 +99,7 @@ void Dropdown::button_press(int x, int y, unsigned btn) else if(btn==1) { dropped = true; + list.set_visible(true); resize_list(); set_state(ACTIVE); signal_grab_pointer.emit(); @@ -105,18 +108,21 @@ void Dropdown::button_press(int x, int y, unsigned btn) void Dropdown::on_geometry_change() { - resize_list(); + if(dropped) + resize_list(); } void Dropdown::on_style_change() { text.set_style(style); - resize_list(); + if(dropped) + resize_list(); } void Dropdown::list_autosize_changed() { - resize_list(); + if(dropped) + resize_list(); signal_autosize_changed.emit(); }