+}
+
+void Widget::rebuild()
+{
+ if(!style)
+ return;
+
+ PartCache::Rebuild rebuild_cache(part_cache);
+ for(const Part &p: style->get_parts())
+ {
+ if(p.get_name().empty())
+ p.build(geom, state, part_cache);
+ else
+ rebuild_special(p);
+ }
+}
+
+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));
+ for(const CachedPart &p: part_cache.get_parts())
+ {
+ if(p.mesh && p.texture)
+ {
+ renderer.set_texture(texture_tag, p.texture, &style->get_sampler());
+ p.mesh->draw(renderer);
+ }
+ else if(p.part)
+ render_special(*p.part, renderer);
+ }
+}
+
+void Widget::pointer_enter()
+{
+ set_state(HOVER);
+}
+
+void Widget::pointer_leave()
+{
+ clear_state(HOVER);
+}
+
+void Widget::touch_press(int x, int y, unsigned finger)
+{
+ if(finger==0)
+ button_press(x, y, 1);
+}
+
+void Widget::touch_release(int x, int y, unsigned finger)
+{
+ if(finger==0)
+ button_release(x, y, 1);
+}
+
+void Widget::touch_motion(int x, int y, unsigned finger)
+{
+ if(finger==0)
+ pointer_motion(x, y);
+}
+
+void Widget::focus_in()
+{
+ set_state(FOCUS);
+}
+
+void Widget::focus_out()
+{
+ clear_state(FOCUS);