X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fwidget.cpp;h=f642004e07c3825fc1a79432f7a3acc237c1dadc;hb=319cde3c06181ba1c3619567525002926d8b4889;hp=1113c971974f84779a3ca863df1b57f4ddf973ea;hpb=c92b1b8ebad0f19491d3a067e99aadae66335114;p=libs%2Fgltk.git diff --git a/source/widget.cpp b/source/widget.cpp index 1113c97..f642004 100644 --- a/source/widget.cpp +++ b/source/widget.cpp @@ -40,6 +40,9 @@ void Widget::set_size(unsigned w, unsigned h) void Widget::autosize() { + if(!style) + return; + geom.w = 0; geom.h = 0; const Style::PartSeq &parts = style->get_parts(); @@ -153,19 +156,22 @@ void Widget::rebuild() if(!style) return; + part_cache.clear(); const Style::PartSeq &parts = style->get_parts(); - list::iterator j = cached_parts.begin(); - for(Style::PartSeq::const_iterator i=parts.begin(); i!=parts.end(); ++i, ++j) + for(Style::PartSeq::const_iterator i=parts.begin(); i!=parts.end(); ++i) { - if(j==cached_parts.end()) - j = cached_parts.insert(j, CachedPart()); if(i->get_name().empty()) - i->build(geom, state, *j); + i->build(geom, state, part_cache); else - rebuild_special(*i, *j); + rebuild_special(*i); } } +void Widget::rebuild_special(const Part &part) +{ + part_cache.insert_special(part); +} + void Widget::render(GL::Renderer &renderer) const { if(!style) @@ -173,17 +179,16 @@ void Widget::render(GL::Renderer &renderer) const GL::MatrixStack::Push _pushm(renderer.matrix_stack()); renderer.matrix_stack() *= GL::Matrix::translation(geom.x, geom.y, 0); - const Style::PartSeq &parts = style->get_parts(); - list::const_iterator j = cached_parts.begin(); - for(Style::PartSeq::const_iterator i=parts.begin(); (i!=parts.end() && j!=cached_parts.end()); ++i, ++j) + const PartCache::PartList &parts = part_cache.get_parts(); + for(PartCache::PartList::const_iterator i=parts.begin(); i!=parts.end(); ++i) { - if(j->mesh && j->texture) + if(i->mesh && i->texture) { - renderer.set_texture(j->texture); - j->mesh->draw(renderer); + renderer.set_texture(i->texture); + i->mesh->draw(renderer); } - else if(!i->get_name().empty()) - render_special(*i, renderer); + else if(i->part) + render_special(*i->part, renderer); } }