X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Flist.cpp;h=04adb399cc2adf237b3384384ac807ea5b6b5ff3;hb=d7274749cb0e171e59d7dc9d7d1712906a351119;hp=722e296edf9cae096b19e2c736f6075d439dc686;hpb=f21a56605f3534cb24e5912cd4f4ee28279dcddd;p=libs%2Fgltk.git diff --git a/source/list.cpp b/source/list.cpp index 722e296..04adb39 100644 --- a/source/list.cpp +++ b/source/list.cpp @@ -5,6 +5,7 @@ Copyright © 2007 Mikko Rasa, Mikkosoft Productions Distributed under the LGPL */ +#include #include #include #include "graphic.h" @@ -71,6 +72,8 @@ void List::clear() { items.clear(); sel_index=-1; + + recalculate_parameters(); } void List::set_selected_index(int i) @@ -145,6 +148,7 @@ void List::render_special(const Part &part) const { const GL::Font *const font=style->get_font(); const float font_size=font->get_default_size(); + const GL::Color &color=style->get_font_color(); const unsigned row_height=static_cast(font_size); const Sides &margin=part.get_margin(); @@ -157,13 +161,16 @@ void List::render_special(const Part &part) const Geometry rgeom; rgeom.w=static_cast(font->get_string_width(items[first+i])*font_size); rgeom.h=static_cast((font->get_ascent()-font->get_descent())*font_size); + rgeom.x=margin.left; rgeom.y=geom.h-margin.top-(i+1)*row_height-static_cast(font->get_descent()*font_size); part.get_alignment().apply(rgeom, pgeom); GL::push_matrix(); GL::translate(rgeom.x, rgeom.y, 0); GL::scale_uniform(font_size); - font->draw_string(items[first+i]); + GL::Immediate imm((GL::COLOR4_UBYTE, GL::TEXCOORD2, GL::VERTEX2)); + imm.color(color.r, color.g, color.b); + font->draw_string(items[first+i], imm); GL::pop_matrix(); } } @@ -261,7 +268,8 @@ void List::recalculate_parameters() void List::slider_value_changed(double value) { - first=items.size()-n_visible-static_cast(value); + if(items.size()>n_visible) + first=items.size()-n_visible-static_cast(value); }