X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fdropdown.cpp;h=41e42fa72fa4b45b399ede99167d3a45d0bbe869;hb=d9d787503ae41842309f74a2eabc5b848abe1f22;hp=cab6d918e536210190a256b67b7965c0851c2f1b;hpb=4ab33a06c9f8a85b193d7db8bc6ee9b8895aab09;p=libs%2Fgltk.git diff --git a/source/dropdown.cpp b/source/dropdown.cpp index cab6d91..41e42fa 100644 --- a/source/dropdown.cpp +++ b/source/dropdown.cpp @@ -36,6 +36,8 @@ void Dropdown::autosize() unsigned line_height = static_cast((font.get_ascent()-font.get_descent())*font_size); geom.h = max(geom.h, line_height+margin.top+margin.bottom); } + + rebuild(); } void Dropdown::append(const string &item) @@ -78,15 +80,21 @@ int Dropdown::get_selected_index() const return list.get_selected_index(); } -void Dropdown::render_special(const Part &part) const +void Dropdown::rebuild_special(const Part &part, CachedPart &cache) { if(part.get_name()=="text") { if(list.get_selected_index()>=0) - Text(*style, list.get_selected()).render(part, geom); + Text(*style, list.get_selected()).build(part, geom, cache); + else + cache.texture = 0; } - else if(part.get_name()=="list" && dropped) - list.render(); +} + +void Dropdown::render_special(const Part &part, GL::Renderer &renderer) const +{ + if(part.get_name()=="list" && dropped) + list.render(renderer); } void Dropdown::button_press(int x, int y, unsigned btn) @@ -97,14 +105,14 @@ void Dropdown::button_press(int x, int y, unsigned btn) if(!click_focus) { dropped = false; - state &= ~ACTIVE; + clear_state(ACTIVE); signal_ungrab_pointer.emit(); } } else if(btn==1) { dropped = true; - state |= ACTIVE; + set_state(ACTIVE); signal_grab_pointer.emit(); } } @@ -160,7 +168,7 @@ void Dropdown::list_item_selected(unsigned index, const std::string &item) if(dropped) { dropped = false; - state &= ~ACTIVE; + clear_state(ACTIVE); signal_ungrab_pointer.emit(); }