]> git.tdb.fi Git - libs/gltk.git/blobdiff - source/widget.cpp
Rename Widget::on_geometry_change to on_size_change
[libs/gltk.git] / source / widget.cpp
index 5fc208268d06e117d7b181b6542154fbf47eb450..d6d57554fc5f324f02f22f48a48c5dbe3386903c 100644 (file)
@@ -72,8 +72,7 @@ void Widget::set_geometry(const Geometry &g)
        geom = g;
        if(size_changed)
        {
-               // TODO maybe rename this to on_size_change
-               on_geometry_change();
+               on_size_change();
                rebuild();
        }
 }
@@ -188,12 +187,26 @@ void Widget::set_state(State mask, State bits)
                rebuild();
 }
 
+void Widget::set_animation_interval(const Time::TimeDelta &iv)
+{
+       if(iv<Time::zero)
+               throw invalid_argument("Widget::set_animation_interval");
+
+       anim_interval = iv;
+       signal_request_animation.emit(anim_interval);
+}
+
+void Widget::stop_animation()
+{
+       set_animation_interval(Time::zero);
+}
+
 void Widget::rebuild()
 {
        if(!style)
                return;
 
-       part_cache.begin_rebuild();
+       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)
        {
@@ -202,7 +215,6 @@ void Widget::rebuild()
                else
                        rebuild_special(*i);
        }
-       part_cache.end_rebuild();
 }
 
 void Widget::rebuild_special(const Part &part)
@@ -215,8 +227,8 @@ 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));
 
-       GL::MatrixStack::Push _pushm(renderer.matrix_stack());
-       renderer.matrix_stack() *= GL::Matrix::translation(geom.x, geom.y, 0);
+       GL::Renderer::Push _push(renderer);
+       renderer.transform(GL::Matrix::translation(geom.x, geom.y, 0));
        const PartCache::PartList &parts = part_cache.get_parts();
        for(PartCache::PartList::const_iterator i=parts.begin(); i!=parts.end(); ++i)
        {