Community
Participate
Working Groups
Please launch the attached sample code on Windows and Linux. It sets non-standard colors for tree and table cells. To make the table cell use the selected background color, the line event.detail &= ~SWT.SELECTED; has to be added to the SWT.EraseItem listener. Unfortunately, this option is not set again in the SWT.PaintItem any more, so the foreground color cannot be set correctly. The commented code provides a work-around, but it depends on the event order and I'm not sure whether this is guaranteed to always be the case.
Created attachment 271782 [details] Sample code
Created attachment 271783 [details] wrong foreground color (unfocused)
Created attachment 271784 [details] wrong foreground color (focused)
I can reproduce the issue. It happens on GTK3.12+. This is with 4.8 master as of today.
Thomas could you attach a screenshot of your snippet running on Windows? So I have a reference of what the correct colours should be.
(In reply to Eric Williams from comment #4) > I can reproduce the issue. It happens on GTK3.12+. This is with 4.8 master > as of today. Correction: 3.14+.
Created attachment 272095 [details] Windows 10 - tree focused
Created attachment 272096 [details] Windows 10 - table focused
Thanks for the windows screenshots. It turns out this bug happens on all GTK versions. I originally thought it didn't happen on 3.14- but as it turns out the platform default selection foreground for those versions happens to be black. This was causing me not to notice the bug. I'll continue to investigate.
Thomas, in the snippet you provided I see that you are clearing the SWT.SELECTED bit for the Table EraseItem listener, but not the Tree EraseItem listener. Is this not required for both? Reading this article: http://www.eclipse.org/articles/Article-CustomDrawingTableAndTreeItems/customDraw.htm#_tr30C It says that the SWT.SELECTED bit should be cleared to ensure that the default selection background isn't drawn. If you clear the SWT.SELECTED bit for both the Table and the Tree, then the bug manifests itself in both widgets.
You are right, when adding the line event.detail &= ~SWT.SELECTED; also to the tree's EraseItem listener, the "Windows 10 - table focused" image would show just one gray instead of the 2 grays.
(In reply to Thomas Singer from comment #11) > You are right, when adding the line > > event.detail &= ~SWT.SELECTED; > > also to the tree's EraseItem listener, the "Windows 10 - table focused" > image would show just one gray instead of the 2 grays. Okay. So both Table and Tree are broken on GTK.
New Gerrit change created: https://git.eclipse.org/r/114957
Gerrit change https://git.eclipse.org/r/114957 was merged to [master]. Commit: http://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/?id=ca42124d01c6987adde92880f9ba6d7d97f9f982
(In reply to Eclipse Genie from comment #14) > Gerrit change https://git.eclipse.org/r/114957 was merged to [master]. > Commit: > http://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/ > ?id=ca42124d01c6987adde92880f9ba6d7d97f9f982 Bug snippet committed. Thanks again Thomas for providing excellent reproducer snippets!
New Gerrit change created: https://git.eclipse.org/r/114961
(In reply to Eclipse Genie from comment #16) > New Gerrit change created: https://git.eclipse.org/r/114961 I have a proposed patch: Thomas please review.
Looks similar to my work-around.
(In reply to Thomas Singer from comment #18) > Looks similar to my work-around. Yes, there is a corner case when having an EraseItem listener and PaintItem listener that deals with selection drawn. After the EraseItem is sent the drawState is cleared of the SWT.SELECTED bit. I will continue to test and will merge if I don't find any issues.
Gerrit change https://git.eclipse.org/r/114961 was merged to [master]. Commit: http://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/?id=ac74a09868e8b5887cede3661179712181968312
(In reply to Eclipse Genie from comment #20) > Gerrit change https://git.eclipse.org/r/114961 was merged to [master]. > Commit: > http://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/ > ?id=ac74a09868e8b5887cede3661179712181968312 Patch is in master.
New Gerrit change created: https://git.eclipse.org/r/115150
Backport patch for 4.7.3: https://git.eclipse.org/r/#/c/115150/
Gerrit change https://git.eclipse.org/r/115150 was merged to [R4_7_maintenance]. Commit: http://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/?id=2a77f729c852f703fea77d9c38322bafb65efae3
(In reply to Eclipse Genie from comment #24) > Gerrit change https://git.eclipse.org/r/115150 was merged to > [R4_7_maintenance]. > Commit: > http://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/ > ?id=2a77f729c852f703fea77d9c38322bafb65efae3 Patch backported.
Verified in M20180214-1700.