Skip to content

Commit 7ee06b0

Browse files
committed
Add preference for using desaturated disabled icons
This adds a preference which enables the use of desaturated disabled icons, which replaces the existing algorithm to create grayscaled version with an algorithm that generates a desaturated version.
1 parent 414e679 commit 7ee06b0

File tree

6 files changed

+34
-0
lines changed

6 files changed

+34
-0
lines changed

bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/IWorkbenchPreferenceConstants.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -732,4 +732,14 @@ public interface IWorkbenchPreferenceConstants {
732732
*/
733733
String IGNORE_DISABLED_ICONS = "ignoreDisabledIcons"; //$NON-NLS-1$
734734

735+
/**
736+
* <p>
737+
* Whether to use a different algorithm for generating disabled icons that
738+
* desaturates the icons rather than making them completely grayscaled.
739+
* </p>
740+
*
741+
* @since 3.139
742+
*/
743+
String USE_DESATURATED_DISABLED_ICONS = "desaturatedDisabledIcons"; //$NON-NLS-1$
744+
735745
}

bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/internal/WorkbenchMessages.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -483,6 +483,8 @@ public class WorkbenchMessages extends NLS {
483483
public static String ViewsPreference_disabledIcons_description;
484484
public static String ViewsPreference_ignoreDisabledIcons;
485485
public static String ViewsPreference_ignoreDisabledIcons_tooltip;
486+
public static String ViewsPreference_useDesaturatedDisabledIcons;
487+
public static String ViewsPreference_useDesaturatedDisabledIcons_tooltip;
486488
public static String ToggleFullScreenMode_ActivationPopup_Description;
487489
public static String ToggleFullScreenMode_ActivationPopup_Description_NoKeybinding;
488490
public static String ToggleFullScreenMode_ActivationPopup_DoNotShowAgain;

bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/internal/dialogs/ViewsPreferencePage.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ public class ViewsPreferencePage extends PreferencePage implements IWorkbenchPre
115115
private Button themingEnabled;
116116
private Button rescaleAtRuntime;
117117
private Button ignoreDisabledIcons;
118+
private Button useDesaturatedDisabledIcons;
118119

119120
private Button hideIconsForViewTabs;
120121
private Button showFullTextForViewTabs;
@@ -246,6 +247,13 @@ private void createDisabledIconsButtons(Composite parent) {
246247
ignoreDisabledIcons = createCheckButton(parent, WorkbenchMessages.ViewsPreference_ignoreDisabledIcons,
247248
initialStateIgnoreDisabledIcons);
248249
ignoreDisabledIcons.setToolTipText(WorkbenchMessages.ViewsPreference_ignoreDisabledIcons_tooltip);
250+
251+
boolean initialStateDesaturatedDisabledIcons = PrefUtil.getAPIPreferenceStore()
252+
.getBoolean(IWorkbenchPreferenceConstants.USE_DESATURATED_DISABLED_ICONS);
253+
useDesaturatedDisabledIcons = createCheckButton(parent,
254+
WorkbenchMessages.ViewsPreference_useDesaturatedDisabledIcons, initialStateDesaturatedDisabledIcons);
255+
useDesaturatedDisabledIcons
256+
.setToolTipText(WorkbenchMessages.ViewsPreference_useDesaturatedDisabledIcons_tooltip);
249257
}
250258

251259
private void createThemeIndependentComposits(Composite comp) {
@@ -373,6 +381,8 @@ public boolean performOk() {
373381
}
374382
PrefUtil.getAPIPreferenceStore().setValue(IWorkbenchPreferenceConstants.IGNORE_DISABLED_ICONS,
375383
ignoreDisabledIcons.getSelection());
384+
PrefUtil.getAPIPreferenceStore().setValue(IWorkbenchPreferenceConstants.USE_DESATURATED_DISABLED_ICONS,
385+
useDesaturatedDisabledIcons.getSelection());
376386

377387
boolean isRescaleAtRuntimeChanged = false;
378388
if (rescaleAtRuntime != null) {
@@ -477,6 +487,8 @@ protected void performDefaults() {
477487
useColoredLabels.setSelection(apiStore.getDefaultBoolean(IWorkbenchPreferenceConstants.USE_COLORED_LABELS));
478488
ignoreDisabledIcons
479489
.setSelection(apiStore.getDefaultBoolean(IWorkbenchPreferenceConstants.IGNORE_DISABLED_ICONS));
490+
useDesaturatedDisabledIcons
491+
.setSelection(apiStore.getDefaultBoolean(IWorkbenchPreferenceConstants.USE_DESATURATED_DISABLED_ICONS));
480492

481493
enableMru.setSelection(defaultPrefs.getBoolean(StackRenderer.MRU_KEY_DEFAULT, StackRenderer.MRU_DEFAULT));
482494
super.performDefaults();

bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/internal/messages.properties

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,9 @@ ViewsPreference_viewTabs_icons_and_titles_label = Tab icons and titles in view a
437437
ViewsPreference_disabledIcons_description = Icons for disabled actions:
438438
ViewsPreference_ignoreDisabledIcons = Ignore pre-generated disabled icons
439439
ViewsPreference_ignoreDisabledIcons_tooltip = When enabled ignores pre-generated disabled icons in favor of generating consistently styled disabled icons on the fly
440+
ViewsPreference_useDesaturatedDisabledIcons = Use desaturated instead of grayscaled disabled icons
441+
ViewsPreference_useDesaturatedDisabledIcons_tooltip = Changes the styling of disabled icons to use a desaturated icon version instead of a grayscaled one
442+
440443
ToggleFullScreenMode_ActivationPopup_Description=You have gone full screen. Use the Toggle Full Screen command ({0}) to deactivate.
441444
ToggleFullScreenMode_ActivationPopup_Description_NoKeybinding=You have gone full screen. Use the Toggle Full Screen command to deactivate.
442445
ToggleFullScreenMode_ActivationPopup_DoNotShowAgain=Do not show again

bundles/org.eclipse.ui/src/org/eclipse/ui/internal/UIPlugin.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,12 @@ private void initializeIconConfigurations() {
108108
boolean ignoreDisabledIcons = PrefUtil.getAPIPreferenceStore()
109109
.getBoolean(IWorkbenchPreferenceConstants.IGNORE_DISABLED_ICONS);
110110
ActionContributionItem.setIgnoreDisabledIcons(ignoreDisabledIcons);
111+
112+
boolean useDesaturatedDisabledIcons = PrefUtil.getAPIPreferenceStore()
113+
.getBoolean(IWorkbenchPreferenceConstants.USE_DESATURATED_DISABLED_ICONS);
114+
if (useDesaturatedDisabledIcons) {
115+
System.setProperty("org.eclipse.swt.image.disablement", "desaturated"); //$NON-NLS-1$ //$NON-NLS-2$
116+
}
111117
}
112118

113119
}

bundles/org.eclipse.ui/src/org/eclipse/ui/internal/UIPreferenceInitializer.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ public void initializeDefaultPreferences() {
6262

6363
node.putBoolean(IWorkbenchPreferenceConstants.USE_COLORED_LABELS, true);
6464
node.putBoolean(IWorkbenchPreferenceConstants.IGNORE_DISABLED_ICONS, true);
65+
node.putBoolean(IWorkbenchPreferenceConstants.USE_DESATURATED_DISABLED_ICONS, true);
6566
node.putBoolean(
6667
IWorkbenchPreferenceConstants.SHOW_TEXT_ON_PERSPECTIVE_BAR,
6768
false);

0 commit comments

Comments
 (0)