X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fdropdown.cpp;fp=source%2Fdropdown.cpp;h=ddf5c9268500479655796caecf9bad0a1ec71e20;hb=319cde3c06181ba1c3619567525002926d8b4889;hp=ee8ec55b7d1e8d46874e42deb82c947fa4d02ca4;hpb=768c65e13861f72929290ac2513df9975579e543;p=libs%2Fgltk.git diff --git a/source/dropdown.cpp b/source/dropdown.cpp index ee8ec55..ddf5c92 100644 --- a/source/dropdown.cpp +++ b/source/dropdown.cpp @@ -63,16 +63,19 @@ void Dropdown::autosize() rebuild(); } -void Dropdown::rebuild_special(const Part &part, CachedPart &cache) +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") - { - int sel = list.get_selected_index(); - if(sel>=0) - Text(*style, list.get_data().get_string(sel)).build(part, geom, cache); - else - cache.texture = 0; - } + text.build(part, geom, part_cache); + else + Widget::rebuild_special(part); } void Dropdown::render_special(const Part &part, GL::Renderer &renderer) const @@ -108,6 +111,7 @@ void Dropdown::on_geometry_change() void Dropdown::on_style_change() { + text.set_style(style); resize_list(); } @@ -156,6 +160,8 @@ void Dropdown::list_item_selected(unsigned index) signal_ungrab_pointer.emit(); } + text.set(list.get_data().get_string(index)); + signal_item_selected.emit(index); rebuild(); }