Bug 563475 - [Dark Theme][Win32] Table enablement breaks background color
Summary: [Dark Theme][Win32] Table enablement breaks background color
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 4.12   Edit
Hardware: PC Windows 10
: P3 normal (vote)
Target Milestone: 4.17 M3   Edit
Assignee: Alexandr Miloslavskiy CLA
QA Contact: Alexandr Miloslavskiy CLA
URL:
Whiteboard:
Keywords:
: 540682 (view as bug list)
Depends on: 536621
Blocks: 563540
  Show dependency tree
 
Reported: 2020-05-22 07:36 EDT by Lars Vogel CLA
Modified: 2021-10-13 16:22 EDT (History)
5 users (show)

See Also:


Attachments
Screenshot (25.38 KB, image/png)
2020-05-22 07:36 EDT, Lars Vogel CLA
no flags Details
Screenshot of disabled tree with patch (8.63 KB, image/png)
2020-05-27 01:59 EDT, Lars Vogel CLA
no flags Details
Clean dialog with patch (6.11 KB, image/png)
2020-08-13 09:01 EDT, Lars Vogel CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Lars Vogel CLA 2020-05-22 07:36:39 EDT
Created attachment 282993 [details]
Screenshot

If I call setEnabled(false) it looses its background color, this looks really bad in the dark theme.

Snippet to reproduce:

-----

import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
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.TableItem;

public class SnippetTableBackground {
	public static void main (String [] args) {
		Display display = new Display ();
		Shell shell = new Shell (display);
		shell.setText("Snippet 301"); //$NON-NLS-1$
		FillLayout layout = new FillLayout();
		layout.marginHeight = 10;
		layout.marginWidth = 10;
		shell.setLayout(layout);
		Table table = new Table(shell, SWT.BORDER);
		table.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK));
		table.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_WHITE));
		for (int i=0; i<10; i++) {
			TableItem item = new TableItem (table, SWT.NONE);
			item.setText("Item " + i);//$NON-NLS-1$
		}

		Button button = new Button(shell, SWT.PUSH);
		button.setText("Switch Enablement"); //$NON-NLS-1$
		button.addSelectionListener(new SelectionAdapter() {
			@Override
			public void widgetSelected(SelectionEvent e) {
				table.setEnabled(!table.getEnabled());
			}
		});

		shell.pack ();
		shell.open ();
		while (!shell.isDisposed ()) {
			if (!display.readAndDispatch ()) display.sleep ();
		}
		display.dispose ();
	}

}


-----

One example in the IDE is the Project Clean Dialog which can be triggered via Project -> Clean.
Comment 1 Lars Vogel CLA 2020-05-22 07:42:18 EDT
Nirja, Alexandr, please have a look. Works well on other platforms (at least Linux).
Comment 2 Alexandr Miloslavskiy CLA 2020-05-26 16:33:39 EDT
I can see the same problem in my native snippet.

It also happens without `OS.setTheme(true)`.

I do not expect that it will be easy to fix. Also, our product doesn't suffer from it, because we don't disable Tables. I'm afraid I won't be able to look into this, sorry.

For some hints, search [1] for 'disabled'.

[1] http://www.geoffchappell.com/studies/windows/shell/comctl32/controls/listview/background.htm
Comment 3 Lars Vogel CLA 2020-05-26 16:44:25 EDT
Thanks Alexandr for checking
Comment 4 Eclipse Genie CLA 2020-05-26 17:46:58 EDT
New Gerrit change created: https://git.eclipse.org/r/163643
Comment 5 Alexandr Miloslavskiy CLA 2020-05-26 17:47:57 EDT
Turns out, SWT already had the necessary code!
I submitted a patch with another `Display.setData()` knob.
Comment 6 Alexandr Miloslavskiy CLA 2020-05-26 17:59:35 EDT
Lars, would you please do the testing and also select specific color value you want for Eclipse?
Comment 7 Lars Vogel CLA 2020-05-27 01:59:30 EDT
Created attachment 283032 [details]
Screenshot of disabled tree with patch

Thanks Alexandr, looks better but it seems that the icon background still goes to light (see screenshot).
Comment 8 Niraj Modi CLA 2020-05-27 08:48:45 EDT
I notice, this issue got introduced in 4.12 via Bug 536621 - [win32][Table] Custom cell style on table doesn't work anymore is some cases
Comment 9 Niraj Modi CLA 2020-05-27 08:50:24 EDT
Hi Nikita,
Appreciate your comments/review here..
Gerrit(https://git.eclipse.org/r/163643) tries to address the issue but it's not complete yet(image part is pending)
Comment 10 Alexandr Miloslavskiy CLA 2020-05-27 20:21:55 EDT
I have updated my patch:
* It still doesn't fix icon background
  It seems that a workaround for Windows behavior is needed here.
* `Display.setData()` knob is removed and replaced with a fix.
  As Niraj correctly pointed out, this was a regression from Bug 536621.
  Thanks for noticing!
* It also fixes Bug 547989.
* The test snippet was significantly improved to cover all problems.
Comment 11 Lars Vogel CLA 2020-08-12 11:10:34 EDT
*** Bug 540682 has been marked as a duplicate of this bug. ***
Comment 13 Alexandr Miloslavskiy CLA 2020-08-12 16:55:33 EDT
In master now.
Comment 14 Lars Vogel CLA 2020-08-13 09:00:45 EDT
Looks great, thanks a bunch!
Comment 15 Lars Vogel CLA 2020-08-13 09:01:06 EDT
Created attachment 283856 [details]
Clean dialog with patch