Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
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 Go to next message
dolik.rce is currently offline  dolik.rce
Messages: 1789
Registered: August 2008
Location: Czech Republic
Ultimate Contributor

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:
index.php?t=getfile&id=2461&private=0

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 395 times)
Re: TextDiffCtrl rendering glitch [+PATCH] [message #26158 is a reply to message #26127] Tue, 06 April 2010 14:51 Go to previous message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
dolik.rce wrote on Fri, 02 April 2010 16:32

/ this line added to fix the problem
}[/code]

Could someone please put it into svn? (I don't have access to uppsrc...)

Regards,
Honza

Yes! Thanks!

Mirek
Previous Topic: Calendar problem
Next Topic: UWord bug
Goto Forum:
  


Current Time: Fri Mar 29 10:15:05 CET 2024

Total time taken to generate the page: 0.01078 seconds