Bug 577493 - [CSS] Request: Add support for more dynamic CSS Button styles and attributes
Summary: [CSS] Request: Add support for more dynamic CSS Button styles and attributes
Status: NEW
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 4.21   Edit
Hardware: PC Windows 10
: P3 normal (vote)
Target Milestone: 4.24 M3   Edit
Assignee: Lars Vogel CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-11-26 11:18 EST by Wiebke Timm CLA
Modified: 2022-06-29 05:21 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Wiebke Timm CLA 2021-11-26 11:18:06 EST
This is a request, not a bug.

For styling eclipse SWT clients with our corporate design, we need an extension of the dynamic Button CSS functionality.


Please support these states for Buttons:

normal
selected (as 'checked' already, but not all attributes)
hover
pressed
disabled (not dynamic yet)


And these attributes:

color, 
background-color
border-color
corner-radius



Default buttons (see Shell.setDefaultButton) have to be styled differently from standard buttons. Sounds to me as if they would need a different class, but I'm no CSS expert. 

ToolItems and TreeItems styling is needed for the same states, but for ToolItems, only color and background-color make sense. (Let me know if I should create separate tickets for ToolItems and TreeItems.)
Comment 1 Lars Vogel CLA 2022-03-29 06:44:36 EDT
(In reply to Wiebke Timm from comment #0)

> Let me know if I should create separate tickets for ToolItems and TreeItems.

Yes, please create a different bug for tool items and tree items.
Comment 2 Wiebke Timm CLA 2022-03-29 07:29:38 EDT
I just realized that I never created those entries.

Here they are:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=579468
https://bugs.eclipse.org/bugs/show_bug.cgi?id=579470
Comment 3 Lars Vogel CLA 2022-03-30 03:59:57 EDT
CSS can only style what SWT / the native widgets allow to be styled. AFAIK the following attributes cannot be styled in pure SWT. Please correct me if I'm wrong.

border-color
corner-radius
Comment 4 Lars Vogel CLA 2022-03-30 04:03:31 EDT
Hover already works, AFAICS.

Button:hover {
    background-color: yellow;
    color:blue;
}
Comment 5 Lars Vogel CLA 2022-03-30 04:51:02 EDT
The CSS spies shows that currently the default button is not selectable via CSS class. You could assign a CSS class or ID to the button and use this in your styling. Depending your your implementation that might a relatively easily to implemented. Lets discuss in person.
Comment 6 Wiebke Timm CLA 2022-03-30 04:57:31 EDT
Yes, hover works for Buttons!

The only documentation I know of for supported CSS styling of SWT widgets is this:
https://wiki.eclipse.org/E4/CSS/SWT_Mapping

So I did not even try because it was not listed.
(Some other widgets like TreeItem or ToolItem are not even mentioned there)
Comment 7 Lars Vogel CLA 2022-03-30 05:07:42 EDT
(In reply to Wiebke Timm from comment #6)
> Yes, hover works for Buttons!

Great to hear.

> The only documentation I know of for supported CSS styling of SWT widgets is
> this:
> https://wiki.eclipse.org/E4/CSS/SWT_Mapping

Yes, documentation is very thin in this area, I also have to check the code for what is supported for non trivial cases. A very helpful tool to use is the CSS spy which we migrated to PDE in the latest releases.
Comment 8 Wiebke Timm CLA 2022-03-30 07:35:39 EDT
(In reply to Lars Vogel from comment #3)
> CSS can only style what SWT / the native widgets allow to be styled. AFAIK
> the following attributes cannot be styled in pure SWT. Please correct me if
> I'm wrong.
> 
> border-color
> corner-radius

It is true, SWT buttons do not support this at present.
Should I create a separate issue to add that support? (here or in bitbucket...?)
Maybe we should discuss the implications in person.
Comment 9 Lars Vogel CLA 2022-03-30 08:25:51 EDT
(In reply to Wiebke Timm from comment #8)
> (In reply to Lars Vogel from comment #3)
> > CSS can only style what SWT / the native widgets allow to be styled. AFAIK
> > the following attributes cannot be styled in pure SWT. Please correct me if
> > I'm wrong.
> > 
> > border-color
> > corner-radius
> 
> It is true, SWT buttons do not support this at present.
> Should I create a separate issue to add that support? (here or in
> bitbucket...?)
> Maybe we should discuss the implications in person.

Lets discuss tomorrow in our call.
Comment 10 Wiebke Timm CLA 2022-06-29 05:21:13 EDT
I have now tried to style default buttons by setting 
button.setData("org.eclipse.e4.ui.css.CssClassName", "DefaultButton");
...and styling .DefaultButton in the css file.

With a wrapper for "setEnabled" we can call the IThemeEngine to get a dynamic update (because unfortunately callbacks are not fired in SWT in that case).

However, when using the jface "MessageDialog", it is impossible to style the default button, because the dialog is created when "open" is called, at which point it is too late to do any (programmatic) styling: The buttons do not exist prior to the open() call. 

So for a consistent styling of default buttons, CSS support for the default button would be needed. Currently, there is NO specific styling for that button other than it is the active button (which is styled differently by the OS), which can be changed by the user (for example by pressing TAB).