Community
Participate
Working Groups
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
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.
Yes, please do attach a screen shot and a stand alone snippet that shows the problem.
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; } }
Created attachment 41555 [details] Shows the artifacts in a table containing checkboxes and non-grey backgrounds
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.
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 ;-)
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.
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?
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).
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.
Created attachment 41887 [details] Here is the patch
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
+1
Mcq, could you review this patch and approve it with appropriate?
+1.
John, do I have your +1?
Fixed for RC5.
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 ;-)
Stefan, we are honestly glad to help.
Verified in I20060519-1206