]> git.tdb.fi Git - libs/gltk.git/blobdiff - source/dropdown.cpp
Cache widget parts in meshes
[libs/gltk.git] / source / dropdown.cpp
index 47496f4bc385121d7c5c2862cec06947427cb799..c2ceefa78957348ee6edd188e71e8ec1faf1fd95 100644 (file)
@@ -36,6 +36,8 @@ void Dropdown::autosize()
                unsigned line_height = static_cast<unsigned>((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,14 +80,20 @@ 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)
+}
+
+void Dropdown::render_special(const Part &part) const
+{
+       if(part.get_name()=="list" && dropped)
                list.render();
 }