Skip to content

Commit 36ade42

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 04547fb commit 36ade42

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
@@ -484,6 +484,8 @@ public class WorkbenchMessages extends NLS {
484484
public static String ViewsPreference_disabledIcons_description;
485485
public static String ViewsPreference_ignoreDisabledIcons;
486486
public static String ViewsPreference_ignoreDisabledIcons_tooltip;
487+
public static String ViewsPreference_useDesaturatedDisabledIcons;
488+
public static String ViewsPreference_useDesaturatedDisabledIcons_tooltip;
487489
public static String ToggleFullScreenMode_ActivationPopup_Description;
488490
public static String ToggleFullScreenMode_ActivationPopup_Description_NoKeybinding;
489491
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
@@ -116,6 +116,7 @@ public class ViewsPreferencePage extends PreferencePage implements IWorkbenchPre
116116
private Button themingEnabled;
117117
private Button rescaleAtRuntime;
118118
private Button ignoreDisabledIcons;
119+
private Button useDesaturatedDisabledIcons;
119120

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

252260
private void createThemeIndependentComposits(Composite comp) {
@@ -380,6 +388,8 @@ public boolean performOk() {
380388
}
381389
PrefUtil.getAPIPreferenceStore().setValue(IWorkbenchPreferenceConstants.IGNORE_DISABLED_ICONS,
382390
ignoreDisabledIcons.getSelection());
391+
PrefUtil.getAPIPreferenceStore().setValue(IWorkbenchPreferenceConstants.USE_DESATURATED_DISABLED_ICONS,
392+
useDesaturatedDisabledIcons.getSelection());
383393

384394
boolean isRescaleAtRuntimeChanged = false;
385395
if (rescaleAtRuntime != null) {
@@ -485,6 +495,8 @@ protected void performDefaults() {
485495
useColoredLabels.setSelection(apiStore.getDefaultBoolean(IWorkbenchPreferenceConstants.USE_COLORED_LABELS));
486496
ignoreDisabledIcons
487497
.setSelection(apiStore.getDefaultBoolean(IWorkbenchPreferenceConstants.IGNORE_DISABLED_ICONS));
498+
useDesaturatedDisabledIcons
499+
.setSelection(apiStore.getDefaultBoolean(IWorkbenchPreferenceConstants.USE_DESATURATED_DISABLED_ICONS));
488500

489501
useRoundTabs.setSelection(
490502
defaultPrefs.getBoolean(CTabRendering.USE_ROUND_TABS, CTabRendering.USE_ROUND_TABS_DEFAULT));

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
@@ -438,6 +438,9 @@ ViewsPreference_viewTabs_icons_and_titles_label = Tab icons and titles in view a
438438
ViewsPreference_disabledIcons_description = Icons for disabled actions:
439439
ViewsPreference_ignoreDisabledIcons = Ignore pre-generated disabled icons
440440
ViewsPreference_ignoreDisabledIcons_tooltip = When enabled ignores pre-generated disabled icons in favor of generating consistently styled disabled icons on the fly
441+
ViewsPreference_useDesaturatedDisabledIcons = Use desaturated instead of grayscaled disabled icons
442+
ViewsPreference_useDesaturatedDisabledIcons_tooltip = Changes the styling of disabled icons to use a desaturated icon version instead of a grayscaled one
443+
441444
ToggleFullScreenMode_ActivationPopup_Description=You have gone full screen. Use the Toggle Full Screen command ({0}) to deactivate.
442445
ToggleFullScreenMode_ActivationPopup_Description_NoKeybinding=You have gone full screen. Use the Toggle Full Screen command to deactivate.
443446
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)