]> git.tdb.fi Git - libs/gltk.git/blobdiff - source/dropdown.cpp
Add a selection_cleared signal to List
[libs/gltk.git] / source / dropdown.cpp
index 7dc0d3550bcaf7d8953ec2a8b5d1013355ad69fd..5b1d19b4f4d6c04576e76a9a015b945b0a956a93 100644 (file)
@@ -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));
@@ -61,13 +62,6 @@ void Dropdown::autosize_special(const Part &part, Geometry &ageom) const
        }
 }
 
-void Dropdown::set_selected_index(int index)
-{
-       list.set_selected_index(index);
-       if(index<0)
-               text.set(string());
-}
-
 void Dropdown::rebuild_special(const Part &part)
 {
        if(part.get_name()=="text")
@@ -90,6 +84,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 +92,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 +101,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();
 }