Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -705,4 +705,14 @@ public interface IWorkbenchPreferenceConstants {
* @since 3.130
*/
String LARGE_VIEW_LIMIT = "largeViewLimit"; //$NON-NLS-1$

/**
* <p>
* <strong>EXPERIMENTAL</strong>. Whether the UI adapts to DPI changes at
* runtime. It only effects Windows.
* </p>
*
* @since 3.133
*/
String RESCALING_AT_RUNTIME = "RESCALING_AT_RUNTIME"; //$NON-NLS-1$
}
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,7 @@ public static int createAndRunWorkbench(final Display display, final WorkbenchAd
int orientation = store.getInt(IPreferenceConstants.LAYOUT_DIRECTION);
Window.setDefaultOrientation(orientation);
}

setRescaleAtRuntimePropertyFromPreference(display);
if (obj instanceof E4Application) {
E4Application e4app = (E4Application) obj;
E4Workbench e4Workbench = e4app.createE4Workbench(getApplicationContext(), display);
Expand Down Expand Up @@ -678,6 +678,15 @@ public void update() {
return returnCode[0];
}

private static void setRescaleAtRuntimePropertyFromPreference(final Display display) {
boolean rescaleAtRuntime = PrefUtil.getAPIPreferenceStore()
.getBoolean(IWorkbenchPreferenceConstants.RESCALING_AT_RUNTIME);
if (rescaleAtRuntime) {
display.setRescalingAtRuntime(rescaleAtRuntime);
System.setProperty("org.eclipse.swt.browser.DefaultType", "edge"); //$NON-NLS-1$ //$NON-NLS-2$
}
}

private static void setSearchContribution(MApplication app, boolean enabled) {
for (MTrimContribution contribution : app.getTrimContributions()) {
if ("org.eclipse.ui.ide.application.trimcontribution.QuickAccess".contains(contribution //$NON-NLS-1$
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,16 @@ public class WorkbenchMessages extends NLS {

public static String ThemingEnabled;

public static String HiDpiSettingsGroupTitle;

public static String RescaleAtRuntimeEnabled;

public static String RescaleAtRuntimeDisclaimer;

public static String RescaleAtRuntimeSettingChangeWarningTitle;

public static String RescaleAtRuntimeSettingChangeWarningText;

public static String ThemeChangeWarningText;

public static String ThemeChangeWarningTitle;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import org.eclipse.core.runtime.IExtensionPoint;
import org.eclipse.core.runtime.IExtensionRegistry;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Platform.OS;
import org.eclipse.core.runtime.RegistryFactory;
import org.eclipse.core.runtime.preferences.DefaultScope;
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
Expand All @@ -53,6 +54,7 @@
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.fieldassist.ControlDecoration;
import org.eclipse.jface.fieldassist.FieldDecorationRegistry;
import org.eclipse.jface.layout.GridDataFactory;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.preference.PreferencePage;
import org.eclipse.jface.util.Util;
Expand All @@ -73,6 +75,7 @@
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPreferenceConstants;
Expand Down Expand Up @@ -114,6 +117,7 @@ public class ViewsPreferencePage extends PreferencePage implements IWorkbenchPre
private boolean highContrastMode;

private Button themingEnabled;
private Button rescaleAtRuntime;

private Button hideIconsForViewTabs;
private Button showFullTextForViewTabs;
Expand All @@ -135,6 +139,7 @@ protected Control createContents(Composite parent) {
layout.horizontalSpacing = 10;
comp.setLayout(layout);
createThemeIndependentComposits(comp);
createHiDPISettingsGroup(comp);
return comp;
}

Expand Down Expand Up @@ -180,6 +185,8 @@ protected Control createContents(Composite parent) {
createHideIconsForViewTabs(comp);
createDependency(showFullTextForViewTabs, hideIconsForViewTabs);

createHiDPISettingsGroup(comp);

if (currentTheme != null) {
String colorsAndFontsThemeId = getColorAndFontThemeIdByThemeId(currentTheme.getId());
if (colorsAndFontsThemeId != null && !currentColorsAndFontsTheme.getId().equals(colorsAndFontsThemeId)) {
Expand All @@ -192,6 +199,30 @@ protected Control createContents(Composite parent) {
return comp;
}

private void createHiDPISettingsGroup(Composite parent) {
if (!OS.isWindows()) {
return;
}
createLabel(parent, ""); //$NON-NLS-1$
Group group = new Group(parent, SWT.LEFT);
group.setText(WorkbenchMessages.HiDpiSettingsGroupTitle);

GridData gridData = new GridData(SWT.FILL, SWT.CENTER, true, false);
gridData.horizontalSpan = ((GridLayout) parent.getLayout()).numColumns;
group.setLayoutData(gridData);
group.setFont(parent.getFont());
GridLayout layout = new GridLayout(1, false);
group.setLayout(layout);
Label infoLabel = new Label(group, SWT.WRAP);
infoLabel.setText(WorkbenchMessages.RescaleAtRuntimeDisclaimer);
infoLabel.setLayoutData(GridDataFactory.defaultsFor(infoLabel).create());
createLabel(group, ""); //$NON-NLS-1$

boolean initialStateRescaleAtRuntime = PrefUtil.getAPIPreferenceStore()
.getBoolean(IWorkbenchPreferenceConstants.RESCALING_AT_RUNTIME);
rescaleAtRuntime = createCheckButton(group, WorkbenchMessages.RescaleAtRuntimeEnabled, initialStateRescaleAtRuntime);
}

private void createThemeIndependentComposits(Composite comp) {
createUseRoundTabs(comp);
createColoredLabelsPref(comp);
Expand Down Expand Up @@ -227,7 +258,6 @@ private void createDependency(Button parent, Button dependent) {
GridData gridData = new GridData();
gridData.horizontalIndent = 20;
dependent.setLayoutData(gridData);

boolean parentState = parent.getSelection();
dependent.setEnabled(parentState);

Expand Down Expand Up @@ -341,6 +371,14 @@ public boolean performOk() {
.getSelection();
prefs.putBoolean(PartRenderingEngine.ENABLED_THEME_KEY, themingEnabled.getSelection());

boolean isRescaleAtRuntimeChanged = false;
if (rescaleAtRuntime != null) {
boolean initialStateRescaleAtRuntime = PrefUtil.getAPIPreferenceStore()
.getBoolean(IWorkbenchPreferenceConstants.RESCALING_AT_RUNTIME);
isRescaleAtRuntimeChanged = initialStateRescaleAtRuntime != rescaleAtRuntime.getSelection();
apiStore.setValue(IWorkbenchPreferenceConstants.RESCALING_AT_RUNTIME, rescaleAtRuntime.getSelection());
}

prefs.putBoolean(CTabRendering.USE_ROUND_TABS, useRoundTabs.getSelection());
try {
prefs.flush();
Expand All @@ -367,19 +405,22 @@ public boolean performOk() {
colorFontsDecorator.hide();

if (themeChanged || colorsAndFontsThemeChanged) {
showRestartDialog();
showRestartDialog(WorkbenchMessages.ThemeChangeWarningTitle, WorkbenchMessages.ThemeChangeWarningText);
}
}
if (themingEnabledChanged) {
showRestartDialog();
showRestartDialog(WorkbenchMessages.ThemeChangeWarningTitle, WorkbenchMessages.ThemeChangeWarningText);
}
if (isRescaleAtRuntimeChanged) {
showRestartDialog(WorkbenchMessages.RescaleAtRuntimeSettingChangeWarningTitle,
WorkbenchMessages.RescaleAtRuntimeSettingChangeWarningText);
}

return super.performOk();
}

private void showRestartDialog() {
if (new MessageDialog(null, WorkbenchMessages.ThemeChangeWarningTitle, null,
WorkbenchMessages.ThemeChangeWarningText, MessageDialog.NONE, 2,
private void showRestartDialog(String title, String warningText) {
if (new MessageDialog(null, title, null, warningText, MessageDialog.NONE, 2,
WorkbenchMessages.Workbench_RestartButton, WorkbenchMessages.Workbench_DontRestartButton)
.open() == Window.OK) {
Display.getDefault().asyncExec(() -> PlatformUI.getWorkbench().restart());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,11 @@ PreferencePageParameterValues_pageLabelSeparator = \ >\
ThemingEnabled = E&nable theming
ThemeChangeWarningText = Restart for the theme changes to take full effect
ThemeChangeWarningTitle = Theme Changed
RescaleAtRuntimeSettingChangeWarningTitle = DPI Setting Changed
RescaleAtRuntimeSettingChangeWarningText = Restart for the DPI setting changes to take effect
HiDpiSettingsGroupTitle = HiDPI settings
RescaleAtRuntimeEnabled = Monitor-specific UI &scaling
RescaleAtRuntimeDisclaimer = EXPERIMENTAL! Activating this option will dynamically scale all windows according to the monitor they are currently in. It will also set the default browser to Edge in order to provide the appropriate scaling of content displayed in a browser. This feature is still in development and therefore considered experimental.
# --- Workbench -----
WorkbenchPreference_openMode=Open mode
WorkbenchPreference_doubleClick=D&ouble click
Expand Down
Loading