]> git.tdb.fi Git - libs/gltk.git/blobdiff - source/widget.cpp
Adjust things to conform to changes in other libraries
[libs/gltk.git] / source / widget.cpp
index 1c73d7640cc610c49ccb33f6e7f4b0fe315a83d0..92cbaae9ba9a3fc4e9c9fc8c1381010481a90d70 100644 (file)
@@ -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)