Bug 481974 - [Dark] getColors().getBackgroound() returns white, while dark theme is used
Summary: [Dark] getColors().getBackgroound() returns white, while dark theme is used
Status: NEW
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 4.5   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Platform-UI-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-11-11 19:48 EST by Oleksandr Mogilevskyi CLA
Modified: 2020-11-30 05:45 EST (History)
6 users (show)

See Also:


Attachments
test project to test the current background and foreground system colors. (11.63 KB, application/x-zip-compressed)
2016-07-10 07:07 EDT, Patrik Suzzi CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Oleksandr Mogilevskyi CLA 2015-11-11 19:48:30 EST
The following import is used.

import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetWidgetFactory;

Then the following object is created.

TabbedPropertySheetWidgetFactory widgetFactory = new TabbedPropertySheetWidgetFactory();

Finally, the following call always returns white (Color object), while Eclipse is set to dark theme under Window -> Preferences -> General -> Appearance -> Theme: Dark.

widgetFactory.getColors().getBackground();
Comment 1 Vikas Chandra CLA 2015-11-12 03:55:07 EST
Moving to platform ui for comments.
Comment 2 Brian de Alwis CLA 2015-11-13 09:26:02 EST
The underlying factory uses the UI Forms FormColors class to manage colors, which initializes itself using the system colours (i.e., Display#getSystemColor()) and not CSS.

I don't think it makes sense to have UI Forms know about our CSS implementation.  But our CSS can't change the colours returned by Display#getSystemColor().

We could establish a convention of having a look-aside colour mapping on the Display instance.  FormColors already has a getSystemColor() and we could modify it (and change everything to use it) to something like:

	public RGB getSystemColor(int code) {
		Map<Integer,Color> lookaside = (Map)getDisplay().getData("org.eclipse.e4.ui.css.swt.SystemColorsLookaside");
		if(lookaside != null && lookaside.containsKey(code)) {
			return lookaside.get(code).getRGB();
		}
		return getDisplay().getSystemColor(code).getRGB();
	}
Comment 3 Lars Vogel CLA 2016-04-20 12:14:45 EDT
Mass move to 4.7 as M7 is approaching. Please move back in case you are planning to fix it for Neon.
Comment 4 Patrik Suzzi CLA 2016-07-10 07:07:15 EDT
Created attachment 263008 [details]
test project to test the current background and foreground system colors.

(In reply to Brian de Alwis from comment #2)
> 
> We could establish a convention of having a look-aside colour mapping on the
> Display instance.  FormColors already has a getSystemColor() and we could
> modify it (and change everything to use it) to something like:
> 
> 	public RGB getSystemColor(int code) {
> 		Map<Integer,Color> lookaside =
> (Map)getDisplay().getData("org.eclipse.e4.ui.css.swt.SystemColorsLookaside");
> 		if(lookaside != null && lookaside.containsKey(code)) {
> 			return lookaside.get(code).getRGB();
> 		}
> 		return getDisplay().getSystemColor(code).getRGB();
> 	}

That's a brilliant Idea!

I propose the following:
- add the Map<Integer, Color>, in the User Preferences
- each time the user changes the theme, store in the map both the Background and the Foreground color for the selected theme. 

Attached you find a plug-in project with a view to test the resolution.. 
Show View: Bug Test > System Colors. You'll see a UI like this: http://i.imgur.com/SeMV9Po.png
Comment 5 Patrik Suzzi CLA 2016-07-10 09:37:17 EDT
I've one extra question: 

Do you think we can reuse the colors defined in the CSS for Background and Foreground ?

As example, see: http://i.imgur.com/D7UHDUq.png. 
We see default_mac.css, and default_win.css importing e4_basestyle.css; where we see several colors are defined in CSS. 

So, I'm thinking to reuse some of the colors defined in the CSS, and put them as BG and FG in eclipse, using the LookAside mechanism suggested by Brian. 

What do you think about this?

Which of the colors defined in css would you use to better represent BackGround and ForeGround colors in Eclipse?
Comment 6 Tim Etchells CLA 2017-02-15 13:35:46 EST
Are there any updates of any kind for this issue, or any plans to fix?