From: Mikko Rasa Date: Fri, 15 Oct 2010 04:50:20 +0000 (+0000) Subject: Make sure that at least one line of text is always rendered X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=dc33fa600b334e10f52da4baf9758aacaca87f2c;p=libs%2Fgltk.git Make sure that at least one line of text is always rendered Initialize Entry's visible rows and make sure it's always at least 1 --- diff --git a/source/entry.cpp b/source/entry.cpp index 654ac6c..3fa4c91 100644 --- a/source/entry.cpp +++ b/source/entry.cpp @@ -27,6 +27,7 @@ Entry::Entry(const Resources &r, const string &t): multiline(false), edit_pos(0), first_row(0), + visible_rows(1), text_part(0), slider(0) { @@ -187,7 +188,7 @@ void Entry::check_view_range() unsigned line_spacing = static_cast(font_size*6/5); const Sides &margin = text_part->get_margin(); - visible_rows = (geom.h-margin.top-margin.bottom)/line_spacing; + visible_rows = max((geom.h-margin.top-margin.bottom)/line_spacing, 1U); unsigned row, col; text.offset_to_coords(edit_pos, row, col); diff --git a/source/text.cpp b/source/text.cpp index 1b46512..c173a8a 100644 --- a/source/text.cpp +++ b/source/text.cpp @@ -209,7 +209,7 @@ void Text::process_lines(const Part &part, const Geometry &parent, unsigned firs int y_offset = static_cast(-font->get_descent()*font_size); const Sides &margin = part.get_margin(); - unsigned n_lines = min(lines.size(), (parent.h-margin.top-margin.bottom)/line_spacing); + unsigned n_lines = max(min(lines.size(), (parent.h-margin.top-margin.bottom)/line_spacing), 1U); first_row = min(first_row, lines.size()-n_lines); for(unsigned i=0; i