X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Ftable.cpp;h=32db6c4af30ddbee2546730291bb8942e4477d3d;hb=3d84860cb25cf05ed36ee6cbd07d9e58cee52422;hp=67a93bc5bbaf0ccb1466350b90a006006e96c0e6;hpb=11d1b67a9180a0e468b56e355fbe0c88d104ef72;p=libs%2Fgltk.git diff --git a/source/table.cpp b/source/table.cpp index 67a93bc..32db6c4 100644 --- a/source/table.cpp +++ b/source/table.cpp @@ -1,6 +1,6 @@ #include #include -#include +#include #include "part.h" #include "style.h" #include "table.h" @@ -52,11 +52,11 @@ void Table::set_cell_text(unsigned r, unsigned c, const string &t) data[r*columns+c] = t; } -void Table::render_special(const Part &part) const +void Table::rebuild_special(const Part &part, CachedPart &cache) { if(part.get_name()=="cells") { - const GL::Font *const font = style->get_font(); + const GL::Font &font = style->get_font(); float font_size = style->get_font_size(); unsigned free_width = geom.w; @@ -67,6 +67,10 @@ void Table::render_special(const Part &part) const cgeom.h = geom.h/rows; cgeom.y = geom.h-cgeom.h; + cache.texture = &font.get_texture(); + cache.clear_mesh(); + + GL::MeshBuilder bld(*cache.mesh); for(unsigned i=0; i(font->get_string_width(text)*font_size); - rgeom.h = static_cast((font->get_ascent()-font->get_descent())*font_size); + rgeom.w = static_cast(font.get_string_width(text)*font_size); + rgeom.h = static_cast((font.get_ascent()-font.get_descent())*font_size); part.get_alignment().apply(rgeom, cgeom, part.get_margin()); - GL::push_matrix(); - GL::translate(rgeom.x, rgeom.y, 0); - GL::scale_uniform(font_size); - font->draw_string(text); - GL::pop_matrix(); + GL::MatrixStack::Push _push(bld.matrix()); + bld.matrix() *= GL::Matrix::translation(rgeom.x, rgeom.y, 0); + bld.matrix() *= GL::Matrix::scaling(font_size); + font.draw_string(text); cgeom.x += cgeom.w; }