Bug 463358 - [Dark][API] Enhance ToolItem API to support setBackground() and/or setSelectedBackground
Summary: [Dark][API] Enhance ToolItem API to support setBackground() and/or setSelecte...
Status: NEW
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 4.5   Edit
Hardware: All All
: P3 enhancement with 1 vote (vote)
Target Milestone: ---   Edit
Assignee: Platform-SWT-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 577357 578260 430162 491531
  Show dependency tree
 
Reported: 2015-03-28 10:37 EDT by Stefan Winkler CLA
Modified: 2023-01-18 04:33 EST (History)
10 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Stefan Winkler CLA 2015-03-28 10:37:07 EDT
Currently, the ToolItem widget does not support setting its background. AFAICS, "normal" items have a transparent background so they inherit the background of the containing ToolBar.
But when it comes to selection (either because of hovering or a radio-button-like selected state), the background changes without having the possibility to specify how.

This leads to varying behavior for different OSes. For example, GTK highlights the button (which leads to unreadable text in the Dark Theme), while Cocoa adds a black semi-transparent layer on top of the item.

We should add API to be able to style at least the selected state, better even: add possibilities to style also the regular background, text color, and selection border color.
Comment 1 Leo Ufimtsev CLA 2015-03-30 11:21:01 EDT
Good point there. 

As a code-note:
For Gtk, I'd recommend to set 'background' as oppose to 'background-image' as background-image doesn't seem to be well supported by all widgets with all themes.

e.g (not tested.. gtk3...)
setBackgroundColor(... GdkRGB rgba)	 {
String css ="* {\n";
if (rgba != null) {
	String color = gtk_rgba_to_css_string (rgba);
	css += "background: " + color + ";\n";
}
css += "}\n";
gtk_css_provider_load_from_css (context, css);
Comment 2 Leo Ufimtsev CLA 2015-05-08 10:59:34 EDT
It's technically possible on Gtk3. (Not sure about gtk2). Can this be done on Win32/Cocoa?
Comment 3 Lakshmi P Shanmugam CLA 2016-03-18 03:51:29 EDT
We are past API freeze for 4.6, moving bug to the 4.7 list.
Comment 4 Lakshmi P Shanmugam CLA 2017-03-24 05:01:36 EDT
We are past API freeze for 4.7, moving out of 4.7.
Comment 5 Ian Pun CLA 2017-03-27 17:04:28 EDT
(In reply to Leo Ufimtsev from comment #1)
> Good point there. 
> 
> As a code-note:
> For Gtk, I'd recommend to set 'background' as oppose to 'background-image'
> as background-image doesn't seem to be well supported by all widgets with
> all themes.
> 
> e.g (not tested.. gtk3...)
> setBackgroundColor(... GdkRGB rgba)	 {
> String css ="* {\n";
> if (rgba != null) {
> 	String color = gtk_rgba_to_css_string (rgba);
> 	css += "background: " + color + ";\n";
> }
> css += "}\n";
> gtk_css_provider_load_from_css (context, css);

Hey Leo,

is your suggestion a viable patch? Perhaps you can post and I can test it to see if its a feasible addition for 4.8
Comment 6 Leo Ufimtsev CLA 2017-03-28 10:19:14 EDT
(In reply to Ian Pun from comment #5)
> Hey Leo,
> 
> is your suggestion a viable patch? Perhaps you can post and I can test it to
> see if its a feasible addition for 4.8

Maybe. My todo list at the moment is kinda long. Wouldn't get to this any time soon if at all.
Comment 7 Eric Williams CLA 2017-03-28 19:33:46 EDT
(In reply to Leo Ufimtsev from comment #6)
> (In reply to Ian Pun from comment #5)
> > Hey Leo,
> > 
> > is your suggestion a viable patch? Perhaps you can post and I can test it to
> > see if its a feasible addition for 4.8
> 
> Maybe. My todo list at the moment is kinda long. Wouldn't get to this any
> time soon if at all.

I would be willing to work on this once I return to work full time.
Comment 8 Pierre-Yves Bigourdan CLA 2020-04-11 08:42:46 EDT
(In reply to Eric Williams from comment #7)
> I would be willing to work on this once I return to work full time.

Any news on this one? Would be a great addition to the API in general, not just for the dark theme. :)