Bug 4745 - [StyledText] Support disabled look in StyledText widget
Summary: [StyledText] Support disabled look in StyledText widget
Status: VERIFIED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 4.8   Edit
Hardware: All All
: P4 normal with 2 votes (vote)
Target Milestone: 4.13 M3   Edit
Assignee: Eric Williams CLA
QA Contact:
URL:
Whiteboard: RHT
Keywords: plan, triaged
: 33594 183972 250658 (view as bug list)
Depends on: 22782 548190
Blocks: 158277 292860 294955
  Show dependency tree
 
Reported: 2001-10-11 14:22 EDT by Mike Wilson CLA
Modified: 2019-11-15 07:38 EST (History)
20 users (show)

See Also:


Attachments
Snippet to compare Text and StyledText (1.48 KB, application/octet-stream)
2019-05-10 02:36 EDT, Lakshmi P Shanmugam CLA
no flags Details
Windows7/10: Difference_in_disabling_behavior_of_Text_and_StyledText (19.14 KB, image/png)
2019-05-10 02:45 EDT, Niraj Modi CLA
no flags Details
Mac screenshot:Snippet with patch applied (88.14 KB, image/png)
2019-05-10 02:54 EDT, Lakshmi P Shanmugam CLA
no flags Details
Mac - SWT color constants in light theme (292.44 KB, image/png)
2019-05-13 05:43 EDT, Lakshmi P Shanmugam CLA
no flags Details
Win7 - SWT color constants in light theme (54.50 KB, image/png)
2019-05-14 02:35 EDT, Niraj Modi CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Mike Wilson CLA 2001-10-11 14:22:17 EDT
To see the problem, launch the Control example and go to the Text tab.
	Toggle the Enabled flag to off.
	Notice that the Text widget looks disabled but not the StyledText one.
		(it's labeled as RichText -- has been fixed in Eclipse View copy of Controls Example)
	For consistency, I think we should supply a Disabled look for StyledText.

NOTES:
Comment 1 DJ Houghton CLA 2001-10-29 16:35:31 EST
PRODUCT VERSION:
	Build 125

Comment 2 Mike Wilson CLA 2001-12-10 13:24:24 EST
StyledText is part of the Eclipse branding. It should draw in a way which is 
consistant with the u/i designer's vision for the platform. No action should 
be taken at this time.
Comment 3 Lynne Kues CLA 2003-03-04 12:37:24 EST
*** Bug 33594 has been marked as a duplicate of this bug. ***
Comment 4 Lynne Kues CLA 2003-09-04 13:11:39 EDT
Reassigning to SWT Inbox since OTT taking over StyledText.
Comment 5 Markus Keller CLA 2006-10-03 04:54:31 EDT
I think it's OK that read-only text/source editors don't get a "disabled" background, but if StyledText is used inside a dialog or form editor, it's rather strange that all other controls look disabled, but StyledText doesn't.

+1 for a user-settable flag to render as disabled.
Comment 6 Felipe Heidrich CLA 2006-10-03 10:58:28 EDT
To implement this feature StyeldText would need API to get the right gray color from the OS. In win32 it would be COLOR_GRAYTEXT=17.

Steve ?
Comment 7 Markus Keller CLA 2006-10-03 11:49:12 EDT
Hmm, sorry for my confusion of disabled vs. read-only. What bug 158277 actually needs is a read-only look, which is different from disabled for the Text widget:
- disabled:  gray  text, light gray bg
- read-only: black text, light gray bg

Bug 22782 requests API to draw 'disabled' gray text.
Comment 8 Felipe Heidrich CLA 2006-10-04 11:24:44 EDT
This bug asks for 'disable look'.

Markus, I didn't find API in the OS to get the background color for read-only text widget. 
Comment 9 Steve Northover CLA 2006-10-04 11:42:00 EDT
> - read-only: black text, light gray bg

On Windows only.  The other platforms don't do this.
Comment 10 Michael Valenta CLA 2007-04-25 16:25:32 EDT
*** Bug 183972 has been marked as a duplicate of this bug. ***
Comment 11 Felipe Heidrich CLA 2008-02-11 17:15:21 EST
*** Bug 216666 has been marked as a duplicate of this bug. ***
Comment 12 Felipe Heidrich CLA 2008-10-15 11:16:18 EDT
*** Bug 250658 has been marked as a duplicate of this bug. ***
Comment 13 Felipe Heidrich CLA 2009-08-14 08:44:39 EDT
Your bug has been moved to triage, visit http://www.eclipse.org/swt/triage.php for more info.
Comment 14 Dani Megert CLA 2009-11-09 09:11:03 EST
Can this be reconsidered? We'd like to use a styled label but we also need to disable it which is currently looking bad due to this bug here.
Comment 15 Dean Roberts CLA 2010-10-05 10:20:53 EDT
I will be adding functionality to the License Information pane in the Feature.xml editor in Eclipse that will look better on Windows if this defect is fixed.
Comment 16 Dean Roberts CLA 2010-10-05 12:02:15 EDT
Specifically, UI element has a side by side Text and StyledText.  The new feature causes the enabled state of these two widgets to be toggled in unison.  Unfortunately, the Text gets the disabled look but the StyledText does not.

The proximity of the two widgets really calls attention to the differing behaviours.
Comment 17 Felipe Heidrich CLA 2010-10-18 11:03:58 EDT
Please see Bug 22782.
Comment 18 Leo Ufimtsev CLA 2017-06-28 10:29:39 EDT
There are still reports about this bug.
Comment 19 Leo Ufimtsev CLA 2017-06-28 10:31:28 EDT
Maybe add a listener that changes the background color of sort...
Comment 20 Eclipse Genie CLA 2017-06-28 14:41:19 EDT
New Gerrit change created: https://git.eclipse.org/r/100286
Comment 21 Mickael Istria CLA 2017-07-03 10:37:50 EDT
(putting a target milestone since there is already a patch pending for review, so 4.8.M1 seems to be a reachable target)
Comment 22 Alexander Kurtakov CLA 2017-07-31 02:07:13 EDT
Not ready for M1.
Comment 23 Eric Williams CLA 2017-09-11 09:42:20 EDT
Re-targeting for M3.
Comment 24 Leo Ufimtsev CLA 2017-11-28 12:06:50 EST
Doesn't look like Ian will be working on this atm. Removing target milestone. If someone want's to take over, please do.
Comment 25 Lakshmi P Shanmugam CLA 2019-05-10 02:36:30 EDT
Created attachment 278558 [details]
Snippet to compare Text and StyledText

Snippet to compare the disabled look for Text and Styledtext
Comment 26 Niraj Modi CLA 2019-05-10 02:45:25 EDT
Created attachment 278561 [details]
Windows7/10: Difference_in_disabling_behavior_of_Text_and_StyledText

(In reply to Lakshmi Shanmugam from comment #25)
> Created attachment 278558 [details]
> Snippet to compare Text and StyledText
> 
> Snippet to compare the disabled look for Text and Styledtext

Attached Screen-shot of above Snippet as tested on Win7 & Win10 showing the difference in disabled behavior.
Comment 27 Lakshmi P Shanmugam CLA 2019-05-10 02:54:48 EDT
Created attachment 278562 [details]
Mac screenshot:Snippet with patch applied

Screenshot of disabled look on Mac for Light and Dark themes with the patch applied.
Comment 28 Eric Williams CLA 2019-05-10 09:09:51 EDT
Can you post a picture of the ControlExample color tab running on Mac and Windows? I want to see how the system colors look there. Please make sure you scroll to the bottom so all the system colors are visible.
Comment 29 Lakshmi P Shanmugam CLA 2019-05-13 05:43:05 EDT
Created attachment 278584 [details]
Mac - SWT color constants in light theme
Comment 30 Eric Williams CLA 2019-05-13 13:04:58 EDT
Hmm, looks like the Mac colors are a bit different. Maybe we can use COLOR_WIDGET_NORMAL_SHADOW for the disabled foreground color on Mac?
Comment 31 Niraj Modi CLA 2019-05-14 02:35:50 EDT
Created attachment 278597 [details]
Win7 - SWT color constants in light theme
Comment 32 Eric Williams CLA 2019-05-14 13:31:21 EDT
Thanks Niraj.

I'm busy with some internal tasks this week, so I plan to work on this bug for 4.13.
Comment 33 Lakshmi P Shanmugam CLA 2019-06-07 05:18:49 EDT
(In reply to Eric Williams from comment #30)
> Hmm, looks like the Mac colors are a bit different. Maybe we can use
> COLOR_WIDGET_NORMAL_SHADOW for the disabled foreground color on Mac?

I think, we should match the foreground and background colors of the disabled StyledText with the disabled native Text widget on a platform as much as possible. We should also note that the colors would be different for dark and light themes.
So, instead of using the fixed color constant like COLOR_WIDGET_NORMAL_SHADOW, may be we could have new constants for the disabled foreground and background color, and it'll be initialized correctly for the platform and theme. WDYT?
Comment 34 Dani Megert CLA 2019-06-07 05:45:11 EDT
(In reply to Lakshmi Shanmugam from comment #33)
> I think, we should match the foreground and background colors of the
> disabled StyledText with the disabled native Text widget on a platform as
> much as possible.
+1
Comment 35 Eric Williams CLA 2019-06-07 14:17:43 EDT
(In reply to Lakshmi Shanmugam from comment #33)
> (In reply to Eric Williams from comment #30)
> > Hmm, looks like the Mac colors are a bit different. Maybe we can use
> > COLOR_WIDGET_NORMAL_SHADOW for the disabled foreground color on Mac?
> 
> I think, we should match the foreground and background colors of the
> disabled StyledText with the disabled native Text widget on a platform as
> much as possible. We should also note that the colors would be different for
> dark and light themes.
> So, instead of using the fixed color constant like
> COLOR_WIDGET_NORMAL_SHADOW, may be we could have new constants for the
> disabled foreground and background color, and it'll be initialized correctly
> for the platform and theme. WDYT?

+1 from me, sounds much better.
Comment 36 Eclipse Genie CLA 2019-07-17 15:39:19 EDT
New Gerrit change created: https://git.eclipse.org/r/146273
Comment 37 Eric Williams CLA 2019-07-18 10:02:33 EDT
Should a widget change background/foreground color if a client calls setBackground/setForeground on it while it's disabled? I.e. consider the following:

Control.setEnabled(false)
Control.setBackground(red)

should the control have a red background?
Comment 38 Lakshmi P Shanmugam CLA 2019-07-22 07:50:50 EDT
(In reply to Eric Williams from comment #37)
> Should a widget change background/foreground color if a client calls
> setBackground/setForeground on it while it's disabled? I.e. consider the
> following:
> 
> Control.setEnabled(false)
> Control.setBackground(red)
> 
> should the control have a red background?

Not sure what's the behavior on all platforms.
On Mac StyledText and other controls change the background/foreground color even when disabled.
Comment 39 Eric Williams CLA 2019-07-22 09:49:58 EDT
(In reply to Lakshmi Shanmugam from comment #38)
> (In reply to Eric Williams from comment #37)
> > Should a widget change background/foreground color if a client calls
> > setBackground/setForeground on it while it's disabled? I.e. consider the
> > following:
> > 
> > Control.setEnabled(false)
> > Control.setBackground(red)
> > 
> > should the control have a red background?
> 
> Not sure what's the behavior on all platforms.
> On Mac StyledText and other controls change the background/foreground color
> even when disabled.

Same on GTK, Niraj can you check the behaviour on Windows?
Comment 40 Niraj Modi CLA 2019-07-23 02:14:59 EDT
(In reply to Eric Williams from comment #39)
> (In reply to Lakshmi Shanmugam from comment #38)
> > (In reply to Eric Williams from comment #37)
> > > Should a widget change background/foreground color if a client calls
> > > setBackground/setForeground on it while it's disabled? I.e. consider the
> > > following:
> > > 
> > > Control.setEnabled(false)
> > > Control.setBackground(red)
> > > 
> > > should the control have a red background?
> > 
> > Not sure what's the behavior on all platforms.
> > On Mac StyledText and other controls change the background/foreground color
> > even when disabled.
> 
> Same on GTK, Niraj can you check the behaviour on Windows?

On Win7:
- For disabled Native widgets: We could only set the background and not the foreground color.
- For disabled Custom widgets: We could set both background/foreground colors [Note: CCombo is an exception here, where we could only set background]
Comment 41 Eric Williams CLA 2019-07-23 09:45:49 EDT
Hmm alright, I'll make it so that setting the bg/fg color while disabled still works.
Comment 43 Eric Williams CLA 2019-08-06 10:14:52 EDT
(In reply to Eclipse Genie from comment #42)
> Gerrit change https://git.eclipse.org/r/146273 was merged to [master].
> Commit:
> http://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/
> ?id=6f7a89a9aab424b92bc846d66939ab93a4ea38d7

In master now. I'll prepare a N&N entry shortly.
Comment 44 Eclipse Genie CLA 2019-08-06 10:33:25 EDT
New Gerrit change created: https://git.eclipse.org/r/147114
Comment 45 Eclipse Genie CLA 2019-08-09 11:23:03 EDT
New Gerrit change created: https://git.eclipse.org/r/147382
Comment 47 Eric Williams CLA 2019-08-09 11:40:15 EDT
(In reply to Eclipse Genie from comment #46)
> Gerrit change https://git.eclipse.org/r/147114 was merged to [master].
> Commit:
> http://git.eclipse.org/c/www.eclipse.org/eclipse/news.git/commit/
> ?id=61e463b4759dfbb5bcf1ce470e737304cfa0906c

N&N entry in master now.
Comment 48 Lakshmi P Shanmugam CLA 2019-08-20 08:28:59 EDT
Verified on Mac with I20190819-2355.
Comment 49 Eric Williams CLA 2019-08-20 10:05:09 EDT
Verified in I20190820-0600.
Comment 50 Thomas Singer CLA 2019-09-12 08:17:11 EDT
Eric, some suggestions for the changes in StyledText.setEnabled in 6f7a89a9a:

- I suggest to put the code between the 2 assignments to insideSetEnableCall inside try-finally, so this flag is reset correctly if an exception happens in setBackground/setForeground

- the line

  public void setEnabled (boolean enabled) {

  shouldn't have a space before the brace
Comment 51 Eric Williams CLA 2019-09-12 08:25:58 EDT
(In reply to Thomas Singer from comment #50)
> Eric, some suggestions for the changes in StyledText.setEnabled in 6f7a89a9a:
> 
> - I suggest to put the code between the 2 assignments to insideSetEnableCall
> inside try-finally, so this flag is reset correctly if an exception happens
> in setBackground/setForeground
> 

Please prepare a Gerrit and I'd be happy to review it.

> - the line
> 
>   public void setEnabled (boolean enabled) {
> 
>   shouldn't have a space before the brace

AFAIK this is the SWT style convention, if you look at the other methods in StyledText, they have it too.
Comment 52 Thomas Singer CLA 2019-09-12 10:02:10 EDT
(In reply to Eric Williams from comment #51)
> (In reply to Thomas Singer from comment #50)
> > Eric, some suggestions for the changes in StyledText.setEnabled in 6f7a89a9a:
> > 
> > - I suggest to put the code between the 2 assignments to insideSetEnableCall
> > inside try-finally, so this flag is reset correctly if an exception happens
> > in setBackground/setForeground
> > 
> 
> Please prepare a Gerrit and I'd be happy to review it.

Wouldn't this be overkill?

(In reply to Eric Williams from comment #51)
> > - the line
> > 
> >   public void setEnabled (boolean enabled) {
> > 
> >   shouldn't have a space before the brace
> 
> AFAIK this is the SWT style convention, if you look at the other methods in
> StyledText, they have it too.

I have verified and found no other method declaration (in the first half of the class) that had a space between method name and (.
Comment 53 Eric Williams CLA 2019-09-12 10:42:26 EDT
(In reply to Thomas Singer from comment #52)
> (In reply to Eric Williams from comment #51)
> > (In reply to Thomas Singer from comment #50)
> > > Eric, some suggestions for the changes in StyledText.setEnabled in 6f7a89a9a:
> > > 
> > > - I suggest to put the code between the 2 assignments to insideSetEnableCall
> > > inside try-finally, so this flag is reset correctly if an exception happens
> > > in setBackground/setForeground
> > > 
> > 
> > Please prepare a Gerrit and I'd be happy to review it.
> 
> Wouldn't this be overkill?

Overkill how? I don't have time to look at this right now, but if you want to make a Gerrit I'd happily push it.


> (In reply to Eric Williams from comment #51)
> > > - the line
> > > 
> > >   public void setEnabled (boolean enabled) {
> > > 
> > >   shouldn't have a space before the brace
> > 
> > AFAIK this is the SWT style convention, if you look at the other methods in
> > StyledText, they have it too.
> 
> I have verified and found no other method declaration (in the first half of
> the class) that had a space between method name and (.

Is the issue the space between the name and the "("? Or the space between the ")" and the "{"? I see both in many other SWT classes. If you want to change it I won't oppose it.
Comment 54 Eclipse Genie CLA 2019-09-20 05:56:31 EDT
New Gerrit change created: https://git.eclipse.org/r/149895
Comment 56 Thomas Singer CLA 2019-11-15 07:38:41 EST
This fix seems to have caused bug 553099.