+ if(!style)
+ return;
+
+ PartCache::Rebuild rebuild_cache(part_cache);
+ const Style::PartSeq &parts = style->get_parts();
+ for(Style::PartSeq::const_iterator i=parts.begin(); i!=parts.end(); ++i)
+ {
+ if(i->get_name().empty())
+ i->build(geom, state, part_cache);
+ else
+ rebuild_special(*i);
+ }
+}
+
+void Widget::rebuild_special(const Part &part)
+{
+ part_cache.insert_special(part);
+}
+
+void Widget::render(GL::Renderer &renderer) const
+{
+ if(!style)
+ throw logic_error(format("Attempt to render a widget with null style (class=\"%s\", style_name=\"%s\")", get_class(), style_name));
+
+ static const GL::Tag texture_tag("ui_tex");
+
+ GL::Renderer::Push _push(renderer);
+ int x = 0;
+ int y = 0;
+ map_coords_to_root(x, y);
+ renderer.set_matrix(GL::Matrix::translation(x, y, 0));
+ const PartCache::PartList &parts = part_cache.get_parts();
+ for(PartCache::PartList::const_iterator i=parts.begin(); i!=parts.end(); ++i)
+ {
+ if(i->mesh && i->texture)
+ {
+ renderer.set_texture(texture_tag, i->texture, &style->get_sampler());
+ i->mesh->draw(renderer);
+ }
+ else if(i->part)
+ render_special(*i->part, renderer);
+ }