X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fwidget.cpp;h=92cbaae9ba9a3fc4e9c9fc8c1381010481a90d70;hb=6deafc9f236b90175a303944815f7c0eac1c95c1;hp=1c73d7640cc610c49ccb33f6e7f4b0fe315a83d0;hpb=878faa0c9283ee1e6e5e67b6ea1324cc52385742;p=libs%2Fgltk.git diff --git a/source/widget.cpp b/source/widget.cpp index 1c73d76..92cbaae 100644 --- a/source/widget.cpp +++ b/source/widget.cpp @@ -92,6 +92,16 @@ void Widget::map_coords_to_ancestor(int &x, int &y, const Widget &ancestor) cons throw hierarchy_error("not an ancestor"); } +void Widget::map_coords_to_root(int &x, int &y) const +{ + for(const Widget *w=this; w; w=w->get_parent()) + { + const Geometry &wgeom = w->get_geometry(); + x += wgeom.x; + y += wgeom.y; + } +} + void Widget::set_parent(Container *p) { if(parent && p) @@ -245,14 +255,19 @@ 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); - renderer.transform(GL::Matrix::translation(geom.x, geom.y, 0)); + 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(i->texture); + renderer.set_texture(texture_tag, i->texture, &style->get_sampler()); i->mesh->draw(renderer); } else if(i->part)