Compute foreground and background colours for setEnabled and setEditable in StyledText#3154
Compute foreground and background colours for setEnabled and setEditable in StyledText#3154elsazac wants to merge 1 commit intoeclipse-platform:masterfrom
Conversation
8363d1c to
18583c9
Compare
67d983f to
d4c145b
Compare
|
Does this still work fine when CSS styling is used in the IDE? |
|
This is going to resolve, #230, correct? |
There was a problem hiding this comment.
Pull request overview
This PR makes StyledText apply consistent foreground/background color recomputation for both setEnabled(...) and setEditable(...), and introduces a distinct visual style for the non-editable (but enabled) state.
Changes:
- Added a shared
updateColors(enabled, editable)helper and invoked it from bothsetEnabledandsetEditable. - Introduced new system color choices for the enabled-but-non-editable state to improve visual differentiation.
- Guarded
resetCache(...)/ caret recomputation insetBackground/setForegroundwhencontentis not yet initialized.
...les/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledText.java
Show resolved
Hide resolved
...les/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledText.java
Show resolved
Hide resolved
...les/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledText.java
Show resolved
Hide resolved
| setForeground(display.getSystemColor(SWT.COLOR_WIDGET_DISABLED_FOREGROUND)); | ||
| } else if (!editable) { | ||
| if (!customBackground) | ||
| setBackground(display.getSystemColor(SWT.COLOR_TITLE_INACTIVE_BACKGROUND)); |
There was a problem hiding this comment.
SWT.COLOR_TITLE_INACTIVE_BACKGROUND is semantically a title-bar color and can render inconsistently across platforms/themes when used as a text background. For an enabled-but-non-editable text area, consider using text/widget-related system colors (or a derived variant of the normal text background) to better track platform theming and maintain consistent look-and-feel.
| setBackground(display.getSystemColor(SWT.COLOR_TITLE_INACTIVE_BACKGROUND)); | |
| setBackground(display.getSystemColor(SWT.COLOR_LIST_BACKGROUND)); |
d4c145b to
e2635ea
Compare
The |
e2635ea to
3e90179
Compare
This commit adds the foreground and background color computation for setEditable. Earlier this was handled only for setEnabled. This commit also adds a different foreground and background color for StyledText when background is not editable. Fixes :eclipse-platform#3132
3e90179 to
032bd55
Compare





This PR adds consistent handling of both foreground and background colors for both
setEnabledandsetEditablefunctionsThe foreground and background colors were computed only for setEnabled. This has to be done for setEditable as
well to achieve consistency. Both the functions setEditable and setEnabled now recomputes foreground and background colour (earlier only applied in
setEnabled)This commit also adds a distinct foreground and background colour combination. Earlier the editable and non-editable state showed no difference. This now improves visual differentiation in StyledText.
Test Snippet : Test.txt
The StyledText behaviour in non editable state is shown below :
Before :

After :

Fixes: #3132, Fixes: #230