Bug 141489 - TableEditor background color artifacts on scrolling
Summary: TableEditor background color artifacts on scrolling
Status: VERIFIED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 3.2   Edit
Hardware: PC Windows XP
: P3 minor (vote)
Target Milestone: 3.2 RC5   Edit
Assignee: Steve Northover CLA
QA Contact:
URL:
Whiteboard:
Keywords: greatbug
Depends on:
Blocks:
 
Reported: 2006-05-12 03:00 EDT by Stefan Schubert CLA
Modified: 2006-05-19 14:58 EDT (History)
4 users (show)

See Also:


Attachments
Shows the artifacts in a table containing checkboxes and non-grey backgrounds (99.46 KB, image/jpeg)
2006-05-16 04:21 EDT, Stefan Schubert CLA
no flags Details
Here is the patch (2.10 KB, patch)
2006-05-18 10:34 EDT, Silenio Quarti CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Stefan Schubert CLA 2006-05-12 03:00:50 EDT
Hi,

I'd like to report a minor display bug for the SWT 3.2 RC2 and previous versions.
This is minor only as long as my customers don't get annoyed because of the artifacts ;-)

If you've got a table containing rows with alternating background colors (e.g. 3 are grey, 4 are white, another 4 grey again, 2 white and so on) and containing multiple TableEditors after scrolling the background color of the Control in such a TableEditor may be wrong.

I recognized this with checkboxes with text in multiple rows. I set the background of the checkbox to the same as the underlying TableItem (SWT.INHERIT_DEFAULT is of no use in this context). Scrolling, the background of a white checkbox may change to grey (but never from grey to white).

If you need a screenshot or further information, please contact me.

Kind regards,
Stefan Schubert
Comment 1 Stefan Schubert CLA 2006-05-12 03:03:45 EDT
Additional note: With medium to large tables (at least 3 screen pages) and a significant number of table editors (1 or 2 every row) such an artifact is very likely to appear every time you scroll in the non-grey area of table.
Comment 2 Steve Northover CLA 2006-05-12 15:57:57 EDT
Yes, please do attach a screen shot and a stand alone snippet that shows the problem.
Comment 3 Stefan Schubert CLA 2006-05-16 04:02:25 EDT
import java.util.Random;

import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.TableEditor;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.swt.widgets.TableItem;

public class TableBackgroundBugTest {

	public static void main(String[] args) {
		// setup shell
		final Display display = new Display();
		final Shell shell = new Shell(display);
		shell.setLayout(new FillLayout(SWT.HORIZONTAL));
		shell.setText("Background Artifacts Test");

		// setup table
		final Table table = new Table(shell, SWT.NONE);
		table.setHeaderVisible(true);
		table.setLinesVisible(true);
		final TableColumn c = new TableColumn(table, SWT.LEFT);
		c.setText("Test Column");
		c.setWidth(500);

		// inititializing table with test data
		final Random rnd = new Random();
		int elementsLeft = 0;
		boolean white = false;
		for (int i = 0; i < 100; i++) {
			if (elementsLeft-- == 0) {
				elementsLeft = rnd.nextInt(5) + 1;
				white = !white;
			}
			final TableItem ti = new TableItem(table, SWT.NONE);
			final int bgi = white ? SWT.COLOR_WHITE : SWT.COLOR_INFO_BACKGROUND;
			final Color bg = display.getSystemColor(bgi);
			ti.setBackground(bg);
			createButton(table, ti, bg, 0, "Test " + i, SWT.CHECK, !white);
		}

		// get it started
		shell.setVisible(true);
		while (!shell.isDisposed()) {
			if (!display.readAndDispatch()) {
				display.sleep();
			}
		}
	}

	private static Button createButton(Table internalTable, TableItem ti, Color bg, int column, String title,
			int style, boolean selection) {
		final Button result = new Button(internalTable, style);
		result.setText(title);
		result.pack();
		if (selection) {
			result.setSelection(selection);
		}
		final TableEditor editor = new TableEditor(internalTable);
		editor.minimumWidth = result.getSize().x;
		editor.minimumHeight = 15;
		editor.horizontalAlignment = SWT.LEFT;
		editor.verticalAlignment = SWT.CENTER;
		editor.setEditor(result, ti, column);
		if (bg != null) {
			result.setBackground(bg);
		}
		return result;
	}

}
Comment 4 Stefan Schubert CLA 2006-05-16 04:21:56 EDT
Created attachment 41555 [details]
Shows the artifacts in a table containing checkboxes and non-grey backgrounds
Comment 5 Steve Northover CLA 2006-05-16 09:16:25 EDT
Interesting.  It seems to be a bug windows involving table scrolling and check boxes.  For fun, I recoded your example to use a tree and it works.  I'll be doing more investigation but it's too late to fix this for 3.2.
Comment 6 Stefan Schubert CLA 2006-05-16 09:25:59 EDT
Even more interesting is that it seems to work better when scrolling up. I found artifacts with it as well but the problems are much less (just a slight grey column right to a checkbox may occur).

Thanks for your help anyway. I think my customers can still "hold out" some months for this minor bug to be solved. They may need to discover it first ;-)
Comment 7 Steve Northover CLA 2006-05-16 09:47:55 EDT
It won't be months.  I'm zeroing in on the problem (Windows ... wow).  If we weren't frozen for 3.2, the fix would go in right away.
Comment 8 Stefan Schubert CLA 2006-05-16 09:57:23 EDT
I thought this was a bug and not a feature. Isn't this whole RC-process there to fix the last bugs? :-) Or is SWT already released?
Comment 9 Steve Northover CLA 2006-05-16 10:08:48 EDT
It is a bug, but any change at this point could invalidate all of Eclipse so we leave the bug in.  I know what's wrong.  Let me see what I can do (no promises).
Comment 10 Steve Northover CLA 2006-05-17 18:55:57 EDT
SSQ?  The cheese looks really bad.  Due to a work around in the code for some other bug, the vertical scroll case is better but the horizontal scrolling looks awful.
Comment 11 Silenio Quarti CLA 2006-05-18 10:34:12 EDT
Created attachment 41887 [details]
Here  is the patch
Comment 12 Michael Valenta CLA 2006-05-18 11:12:12 EDT
I have verified that the optimization was added in revisin 1.283 (Early Feb.) and that this patch reduces the number of times the optimization is used.

+1
Comment 13 Silenio Quarti CLA 2006-05-18 11:20:14 EDT
+1
Comment 14 Silenio Quarti CLA 2006-05-18 12:01:15 EDT
Mcq, could you review this patch and approve it with appropriate?

Comment 15 Mike Wilson CLA 2006-05-18 20:51:08 EDT
+1. 
Comment 16 Silenio Quarti CLA 2006-05-19 11:01:54 EDT
John, do I have your +1?
Comment 17 John Arthorne CLA 2006-05-19 11:16:31 EDT
+1
Comment 18 Silenio Quarti CLA 2006-05-19 11:19:36 EDT
Fixed for RC5.
Comment 19 Stefan Schubert CLA 2006-05-19 11:25:43 EDT
Wow, that was fast, guys! Thanks for your efforts!

It was an experience to see you working here. I in our little company do not now such efforts for such a little if-statement ;-)
Comment 20 Steve Northover CLA 2006-05-19 13:57:05 EDT
Stefan, we are honestly glad to help.
Comment 21 Silenio Quarti CLA 2006-05-19 14:58:52 EDT
Verified in I20060519-1206