eclipse-platform / eclipse.platform.ui

Eclipse Platform
https://projects.eclipse.org/projects/eclipse.platform
Eclipse Public License 2.0
77 stars 162 forks source link

Make it possible to ColorDefinitions from CSS theme also in preference CSS nodes #93

Open gayanper opened 2 years ago

gayanper commented 2 years ago

Add support to resolve Color and Font definitions in the following PreferenceHandler

https://github.com/eclipse-platform/eclipse.platform.ui/blob/daf172a06947bd242b2c1b9c646968839894ec72/bundles/org.eclipse.e4.ui.css.swt/src/org/eclipse/e4/ui/css/swt/properties/preference/EclipsePreferencesHandler.java#L26

UseCase

When defining new themes, we can define template preferences in a more core theme, which can be extended by importing those theme templates and providing color and font definitions. Today this can only be done at SWT widget styling. Adding this to preference we can improve the support. This will enable us to define more of a predefined theme configuration like in vscode.

gayanper commented 2 years ago

@vogella @mickaelistria WDYT, If you think its good I can start work on it.

vogella commented 2 years ago

@gayanper sorry, I'm not sure what is missing here. You could define colors and fonts via the colors and fonts extension point and style them via CSS. What is the intended change here?

gayanper commented 2 years ago

@gayanper sorry, I'm not sure what is missing here. You could define colors and fonts via the colors and fonts extension point and style them via CSS. What is the intended change here?

We can only use color and font definitions in css style blocks. The suggestion is to add support for preferences blocks as well. Today preference blocks are parsed as it is. Allowing it to be parameterize using color and font definitions will enable us to have these sections as templates in their respective plugins and redefine the color and fonts in theme plugins, at least thats my intension here. Got this idea from vscode theming.

vogella commented 2 years ago

@gayanper I still don't fully get your suggestion but feel free to send a PR to support it, I'm happy to help with the review. I may also final understand the proposal after I saw the code. :-)

gayanper commented 2 years ago

Let try again. Lets take the vscode theme i shared few weeks back. Now when i defined it, i wanted the javadoc, source view popups to have the same background which is used for views like in vscode.

I used a color definition for this view background and use it for all swt styling. But javadoc seems to use the information background. Now i can of course override it as a preference in my stylesheet. But i have to duplicate the color as rgb value in the preference entry string.

But if we had the support to refer to the color definition then it would be simple to change this color value later so all referenced places will get effected in runtime.

vogella commented 2 years ago

Thanks @gayanper. I still think we already partially support this (at least in the IDE case), see e4-dark_ide_colorextensions.css in org.eclipse.ui.themes which is for example used in e4-dark_tabstyle.css

CTabFolder {
    /* Set the styles for the inner tabs: */
    color: '#org-eclipse-ui-workbench-INACTIVE_TAB_TEXT_COLOR';
    swt-tab-renderer: url('bundleclass://org.eclipse.e4.ui.workbench.renderers.swt/org.eclipse.e4.ui.workbench.renderers.swt.CTabRendering');
    swt-tab-outline: '#org-eclipse-ui-workbench-ACTIVE_TAB_OUTLINE_COLOR'; /* border color for selected tab */
    swt-outer-keyline-color: '#org-eclipse-ui-workbench-ACTIVE_TAB_OUTER_KEYLINE_COLOR'; /* border color for whole tabs container */
    swt-unselected-tabs-color: '#org-eclipse-ui-workbench-ACTIVE_UNSELECTED_TABS_COLOR_START' '#org-eclipse-ui-workbench-ACTIVE_UNSELECTED_TABS_COLOR_END' 100% 100%; /* title background for unselected tab */
    swt-selected-tab-fill: '#org-eclipse-ui-workbench-ACTIVE_TAB_BG_END'; /* title background for selected tab */
    swt-unselected-hot-tab-color-background: #161616; /* Bug 465711 */
    swt-selected-tab-highlight: none;
}

So what I think is missing and you are suggesting:

That is a great goal. It would also be great if we would replace all the color constants in our default files with color definitions so that we actually allow the user to change these.