Bug 463620 - [CSS][Dark][Gkt3] No dark icons for Checkbox/Radio/Slider in Eclipse Dark Theme.
Summary: [CSS][Dark][Gkt3] No dark icons for Checkbox/Radio/Slider in Eclipse Dark Theme.
Status: RESOLVED WONTFIX
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 4.5   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Platform-UI-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 465191 (view as bug list)
Depends on:
Blocks:
 
Reported: 2015-03-31 14:47 EDT by Leo Ufimtsev CLA
Modified: 2023-04-04 21:09 EDT (History)
10 users (show)

See Also:


Attachments
GtkCheckbox + GtkImage + GtkLabel (4.10 KB, image/png)
2015-03-31 15:43 EDT, Leo Ufimtsev CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Leo Ufimtsev CLA 2015-03-31 14:47:09 EDT
-------- Summary:
@Platform UI folks: I'm interested in your thoughts on this matter:

The current eclipse dark theme doesn't define icons for checkbox/radio/sliders. 
As such if you enable the dark-theme, you still get the icons from the OS theme. 
Which looks broken if the system theme is light.

Should we consider adding checkbox/radio/slider icons to the eclipse CSS theme to make the experience more consistent?
(At least for the eclipse-dark theme?)

Thoughts?

--------- Details:

I'm on the SWT side of things, and as part of the investigation in: 
Bug 462009 - [Gtk3] Button background Color fix
I tried to fix the background of a checkbox etc..

I found that Checkboxes, radio options, sliders in gtk3 with CSS themes are 'icons' (and not a filled shapes as in previous gtk versions or un-themed gtk builds).

The eclipse dark-theme CSS doesn't define assets (i.e icons for these controls). This is the source code:
git.eclipse.org/c/platform/eclipse.platform.ui.git/tree/bundles/org.eclipse.ui.themes/css

As such, the eclipse dark-theme doesn't theme Checkboxes, Radio options, sliders etc. I.e those eclipse receives from the system theme.
As such, when you use 'eclipse dark theme' but your OS is light, then you get the light icons inherited from the OS.

For example:

Dark-Eclipse when OS is dark: (all is well)
https://bugs.eclipse.org/bugs/attachment.cgi?id=251937

Dark-Eclipse for when OS is light: (note check boxes are light, but should ideally be dark)
https://bugs.eclipse.org/bugs/attachment.cgi?id=251938


If you inspect other CSS themes, they have checkbox/radio... icons for light & dark version. For example standard gnome theme:
http://ftp.gnome.org/Public/GNOME/sources/gnome-themes-standard/3.10/
/themes/Adwaita/gtk-3.0/assets
  checkbox-unchecked.png
  checkbox-unchecked-backgrop-dark.png

Which are called in 
/themes/Adwaita/gtk-3.0/gtk-widgets-assets-dark.css
  ... 38:  background-image: -gtk-scaled(url("assets/checkbox-unchecked-dark.png"),url("assets/checkbox-unchecked-dark@2.png"));

Thoughts?
Comment 1 Leo Ufimtsev CLA 2015-03-31 14:48:50 EDT
CC'ing Alex.K & Lars Vogella as per involvement in original bug.
Comment 2 Lars Vogel CLA 2015-03-31 14:54:57 EDT
Sounds like a great suggestion (I actually wasn't aware) that SWT supports that. Would we use setImage for this? Is this supported cross platform?

Adding Brian, Stefan and Simon as our CSS experts.
Comment 3 Leo Ufimtsev CLA 2015-03-31 15:43:15 EDT
CC'ing swt
Comment 4 Leo Ufimtsev CLA 2015-03-31 15:43:57 EDT
Created attachment 252056 [details]
GtkCheckbox + GtkImage + GtkLabel
Comment 5 Leo Ufimtsev CLA 2015-03-31 15:47:37 EDT
(In reply to Lars Vogel from comment #2)
> Sounds like a great suggestion (I actually wasn't aware) that SWT supports
> that. Would we use setImage for this? Is this supported cross platform?

I haven't quite figured out the details of the implementation of this yet. 
But I looked at setImage(). That method is independent of GtkCheckbox/GtkRadio in the sense that an SWT Checkbox consists of 3 components:
(GtkCheckButton|GtkRadioButton)([GtkImage])(GtkLabel) 

setImage alters the GtkImage component. 

We might have to add api for this in SWT.
setIcon( )
Comment 6 Leo Ufimtsev CLA 2015-03-31 15:50:21 EDT
Maybe something along the lines of:
setIcon(int style, Image image) {
 switch (style) 
 ... case SWT.CHECK:
 ... case SWT.RADIO:
}

Thoughts? 

Any other ideas/suggestions are welcome.
Comment 7 Thomas Schindl CLA 2015-03-31 15:58:25 EDT
And what should this method do on other OSes? 

I have said it since the beginning all API that SWT should have provided from day 1 is Widget#setSystemStyle(String) and Widget#setStyle(String) and our CSS-Engine would have collected the CSS-Attributes and called Widget#setSystemStyle(String)

So before you start adding API like this please reconsider add the above API
Comment 8 Stefan Winkler CLA 2015-03-31 17:23:55 EDT
Hi Tom,

(In reply to Thomas Schindl from comment #7)
> And what should this method do on other OSes? 
> 
> I have said it since the beginning all API that SWT should have provided
> from day 1 is Widget#setSystemStyle(String) and Widget#setStyle(String) and
> our CSS-Engine would have collected the CSS-Attributes and called
> Widget#setSystemStyle(String)
> 
> So before you start adding API like this please reconsider add the above API

But this API still only makes sense for Gtk3, if I am not mistaken. Some time ago I was investigating roughly the possibility of supporting CSS on SWT level, but I came to the conclusion that it's not worth the effort, because besides GTK, the native window toolkits (Win32, Cocoa) do not support CSS styling natively. 

So the only sensible thing for having something like Widget#setSystemStyle(String) - if I understand correctly what you are trying to achieve - would be to specify a platform-neutral syntax for that string and then, we lose the advantage here, because we have to translate the platform-neutral string into a platform-native string (for Gtk) or into discrete native calls (for the other toolkits).
Comment 9 Thomas Schindl CLA 2015-03-31 17:56:02 EDT
(In reply to Stefan Winkler from comment #8)
> Hi Tom,
> 
> (In reply to Thomas Schindl from comment #7)
> > And what should this method do on other OSes? 
> > 
> > I have said it since the beginning all API that SWT should have provided
> > from day 1 is Widget#setSystemStyle(String) and Widget#setStyle(String) and
> > our CSS-Engine would have collected the CSS-Attributes and called
> > Widget#setSystemStyle(String)
> > 
> > So before you start adding API like this please reconsider add the above API
> 
> But this API still only makes sense for Gtk3, if I am not mistaken. Some
> time ago I was investigating roughly the possibility of supporting CSS on
> SWT level, but I came to the conclusion that it's not worth the effort,
> because besides GTK, the native window toolkits (Win32, Cocoa) do not
> support CSS styling natively. 
> 
> So the only sensible thing for having something like
> Widget#setSystemStyle(String) - if I understand correctly what you are
> trying to achieve - would be to specify a platform-neutral syntax for that
> string and then, we lose the advantage here, because we have to translate
> the platform-neutral string into a platform-native string (for Gtk) or into
> discrete native calls (for the other toolkits).


Today we have the problem of who wins when the CSS calls setBsckground and you in your code do (Hint: User code calls should always win but today most of the time CSS wins the game). This would have been solved. 

Today we are unable to express gradients, paddings, ... all this could be solved using the platform-neutral string representation.

My point is only the low-level SWT implementation knows how to best implement features like a gradient, a padding, ... on Gtk it would simply translate String into Gtk-CSS, on Win32 & Cocoa it would have to translate it to native calls, ... .
Comment 10 Leo Ufimtsev CLA 2015-04-02 13:35:26 EDT
I really like the general principle of the Widget#setStyle(String) api.
But so long as Gtk2 (& Pre Gtk3.10) are still around, a general-purpose api like that would mean that we'd still have to parse through the CSS string and manually convert it into Gtk2 calls.


This would mean maintaining a duplicate set of functionality (regular api setBackground() and a CSS-setBackground for newer GTK's.

Unfortunatley it's also not quite as simple as taking eclipse CSS and passing it to GTK.
- Eclipse-css doesn't always map onto Gtk-css very well. For instance GtkButton doesn't handle 'background-color' for all themes. It needs 'background' property instead. This means that we would have to have an intricate CSS-checking/filtering/replacement engine.
- Then there is the issue that certain properties/attributes are only supported in certain Gtk3.* versions. So for older gtk3.*'s we'd have to strip out CSS properties from the given Style string otherwise there'd be a lot of console warnings.
- What about the case where you specify a linear/radial gradient going from red to blue. Such a feature (I think?) is not supported on Win32/Cocoa for all widgets. How would you decide whether to pick the red or the blue color? This would introduce a lot of inconsistent behaviour across platforms. So to ensure consistency, we'd have to define a supported set of CSS that would work across all platforms. Which is basically sort of the same as having the same api calls?

So although it's a very good idea/principle, it might not be very feasibly at the moment.


It seems a setIcon() api would not port to Win/Cocoa well and SWT Gtk doesn't seem to be quite ready for Widget#setStyle(String). So it doesn't seem like we can add icons to the Platform.UI theme. 

There are 2 alternate solutions in sight:
1) When running under linux & dark theme, inject custom gtk-CSS into Gtk that specifies icons for checkbox/radio.
2) When running under linux & dark theme, instead of using the themes 'gtk.css', advise eclipse to use 'gtk-dark.css' instead.

But those two are conceptually a bit different and it would make sense to handle them in a different bug.

Closing for now as setIcon() api would not port well to all of swt. But feel free to post comments with thoughts or re-open if you see the need.
Comment 11 Thomas Schindl CLA 2015-04-02 13:47:14 EDT
Well we could allow CSS-Extensions in our CSS so one would do:

.button {
  -gtk-icon: url("the-drak.png");
  -gtk-padding: 5px; 
}

and the css-engine would translate that in:

button.setData("gtk-css-gtk-icon", "file:jar://..../the-drak.png");
button.setData("gtk-css-gtk-padding", "5px");
Comment 12 Lars Vogel CLA 2015-04-22 08:01:04 EDT
*** Bug 465191 has been marked as a duplicate of this bug. ***