Home » U++ Library support » U++ Library : Other (not classified elsewhere) » TextDiffCtrl rendering glitch [+PATCH]
TextDiffCtrl rendering glitch [+PATCH] [message #26127] |
Fri, 02 April 2010 22:32 |
|
Hi,
there is a small glitch in rendering of TextDiffCtrl for files that are shorter than "one screen height". The bottom part of line numbers area is not repainted and contains random stuff:
The fix is really simple, just one line at the very end of TextCompareCtrl::Paint():
void TextCompareCtrl::Paint(Draw& draw)
{
Point sc = scroll.Get();
Size offset = (Size)sc * letter;
Size sz = GetSize();
int lcnt = lines.GetCount();
int first_line = offset.cy / letter.cy;
int last_line = min(idivceil(sz.cy + offset.cy, letter.cy), lines.GetCount() - 1);
if(gutter_width > 0)
{
int t = 0, b = 0;
int gx = sz.cx - gutter_width;
for(int i = 0; i < lcnt; i++)
if(lines[i].level > 1) {
b = idivceil(sz.cy * i, lcnt);
if(b >= t) {
draw.DrawRect(gx, t, gutter_width, b - t, gutter_bg);
draw.DrawRect(gx, b, gutter_width, 1, gutter_fg);
t = b + 1;
}
}
draw.DrawRect(gx, t, gutter_width, sz.cy - t, gutter_bg);
int total = letter.cy * lcnt;
if(total <= 0)
total = 1;
int page_height = (sz.cy * sz.cy) / total;
int ty = max(0, (sz.cy * offset.cy) / total);
int by = min(sz.cy, ty + page_height);
draw.DrawRect(gx, ty, gutter_width, 2, Black);
draw.DrawRect(gx, by - 2, gutter_width, 2, Black);
draw.DrawRect(gx, ty, 2, by - ty, Black);
draw.DrawRect(gx + gutter_width - 2, ty, 2, by - ty, Black);
}
Font ifont = Font(font).Italic();
for(int i = first_line; i <= last_line; i++) {
const Line& l = lines[i];
int y = i * letter.cy - offset.cy;
draw.DrawRect(0, y, number_width, letter.cy, number_bg);
if(!IsNull(l.number))
draw.DrawText(0, y + number_yshift, FormatInt(l.number), number_font, l.color);
}
draw.Clip(number_width, 0, sz.cx - gutter_width - number_width, sz.cy);
for(int i = first_line; i <= last_line; i++) {
const Line& l = lines[i];
int y = i * letter.cy - offset.cy;
draw.DrawRect(0, y, sz.cx, letter.cy, SWhite());
draw.DrawText(number_width - offset.cx, y, ExpandTabs(l.text), l.level == 1 ? ifont : font, l.color);
}
int lcy = lcnt * letter.cy - offset.cy;
draw.DrawRect(0, lcy, sz.cx, sz.cy - lcy, SGray());
draw.End();
draw.DrawRect(0, lcy, number_width, sz.cy - lcy, number_bg); // this line added to fix the problem
}
Could someone please put it into svn? (I don't have access to uppsrc...)
Regards,
Honza
-
Attachment: img.png
(Size: 24.50KB, Downloaded 397 times)
|
|
|
|
Goto Forum:
Current Time: Fri Apr 26 16:10:22 CEST 2024
Total time taken to generate the page: 0.03363 seconds
|