Skip to content

Commit 786cfa5

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 29a2bec commit 786cfa5

6 files changed

Lines changed: 34 additions & 0 deletions

File tree

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
@@ -494,6 +494,8 @@ public class WorkbenchMessages extends NLS {
494494
public static String ViewsPreference_disabledIcons_description;
495495
public static String ViewsPreference_ignoreDisabledIcons;
496496
public static String ViewsPreference_ignoreDisabledIcons_tooltip;
497+
public static String ViewsPreference_useDesaturatedDisabledIcons;
498+
public static String ViewsPreference_useDesaturatedDisabledIcons_tooltip;
497499
public static String ToggleFullScreenMode_ActivationPopup_Description;
498500
public static String ToggleFullScreenMode_ActivationPopup_Description_NoKeybinding;
499501
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
@@ -118,6 +118,7 @@ public class ViewsPreferencePage extends PreferencePage implements IWorkbenchPre
118118
private Button themingEnabled;
119119
private Button rescaleAtRuntime;
120120
private Button ignoreDisabledIcons;
121+
private Button useDesaturatedDisabledIcons;
121122

122123
private Button hideIconsForViewTabs;
123124
private Button showFullTextForViewTabs;
@@ -264,6 +265,13 @@ private void createDisabledIconsButtons(Composite parent) {
264265
ignoreDisabledIcons = createCheckButton(parent, WorkbenchMessages.ViewsPreference_ignoreDisabledIcons,
265266
initialStateIgnoreDisabledIcons);
266267
ignoreDisabledIcons.setToolTipText(WorkbenchMessages.ViewsPreference_ignoreDisabledIcons_tooltip);
268+
269+
boolean initialStateDesaturatedDisabledIcons = PrefUtil.getAPIPreferenceStore()
270+
.getBoolean(IWorkbenchPreferenceConstants.USE_DESATURATED_DISABLED_ICONS);
271+
useDesaturatedDisabledIcons = createCheckButton(parent,
272+
WorkbenchMessages.ViewsPreference_useDesaturatedDisabledIcons, initialStateDesaturatedDisabledIcons);
273+
useDesaturatedDisabledIcons
274+
.setToolTipText(WorkbenchMessages.ViewsPreference_useDesaturatedDisabledIcons_tooltip);
267275
}
268276

269277
private void createThemeIndependentComposits(Composite comp) {
@@ -498,6 +506,8 @@ public boolean performOk() {
498506
}
499507
PrefUtil.getAPIPreferenceStore().setValue(IWorkbenchPreferenceConstants.IGNORE_DISABLED_ICONS,
500508
ignoreDisabledIcons.getSelection());
509+
PrefUtil.getAPIPreferenceStore().setValue(IWorkbenchPreferenceConstants.USE_DESATURATED_DISABLED_ICONS,
510+
useDesaturatedDisabledIcons.getSelection());
501511

502512
boolean isRescaleAtRuntimeChanged = false;
503513
if (rescaleAtRuntime != null) {
@@ -641,6 +651,8 @@ protected void performDefaults() {
641651
useColoredLabels.setSelection(apiStore.getDefaultBoolean(IWorkbenchPreferenceConstants.USE_COLORED_LABELS));
642652
ignoreDisabledIcons
643653
.setSelection(apiStore.getDefaultBoolean(IWorkbenchPreferenceConstants.IGNORE_DISABLED_ICONS));
654+
useDesaturatedDisabledIcons
655+
.setSelection(apiStore.getDefaultBoolean(IWorkbenchPreferenceConstants.USE_DESATURATED_DISABLED_ICONS));
644656

645657
enableMru.setSelection(defaultPrefs.getBoolean(StackRenderer.MRU_KEY_DEFAULT, StackRenderer.MRU_DEFAULT));
646658
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
@@ -439,6 +439,9 @@ ViewsPreference_showDirtyIndicatorForTabs = Indicate unsaved changes by overlayi
439439
ViewsPreference_disabledIcons_description = Icons for disabled actions:
440440
ViewsPreference_ignoreDisabledIcons = Ignore pre-generated disabled icons
441441
ViewsPreference_ignoreDisabledIcons_tooltip = When enabled ignores pre-generated disabled icons in favor of generating consistently styled disabled icons on the fly
442+
ViewsPreference_useDesaturatedDisabledIcons = Use desaturated instead of grayscaled disabled icons
443+
ViewsPreference_useDesaturatedDisabledIcons_tooltip = Changes the styling of disabled icons to use a desaturated icon version instead of a grayscaled one
444+
442445
ToggleFullScreenMode_ActivationPopup_Description=You have gone full screen. Use the Toggle Full Screen command ({0}) to deactivate.
443446
ToggleFullScreenMode_ActivationPopup_Description_NoKeybinding=You have gone full screen. Use the Toggle Full Screen command to deactivate.
444447
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
@@ -63,6 +63,7 @@ public void initializeDefaultPreferences() {
6363

6464
node.putBoolean(IWorkbenchPreferenceConstants.USE_COLORED_LABELS, true);
6565
node.putBoolean(IWorkbenchPreferenceConstants.IGNORE_DISABLED_ICONS, true);
66+
node.putBoolean(IWorkbenchPreferenceConstants.USE_DESATURATED_DISABLED_ICONS, true);
6667
node.putBoolean(
6768
IWorkbenchPreferenceConstants.SHOW_TEXT_ON_PERSPECTIVE_BAR,
6869
false);

0 commit comments

Comments
 (0)