forked from eclipse-platform/eclipse.platform.swt
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Apply DPI zoom changes to basic controls
This contribution adds and registers a DPI change handler for all widgets in the org.eclipse.swt.widgets package of the win32 implementation. These handler will be registered only, when the "swt.autoScale.updateOnRuntime"-flag is set to true. If a DPI change is detected they will be called accordingly. Contributes to eclipse-platform#62 and eclipse-platform#127
- Loading branch information
1 parent
ebcc084
commit 6ef2894
Showing
36 changed files
with
906 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
....eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/custom/CommonWidgetsDPIChangeHandlers.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2024 Yatta Solutions and others. | ||
* | ||
* This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License 2.0 | ||
* which accompanies this distribution, and is available at | ||
* https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Yatta Solutions - initial API and implementation | ||
*******************************************************************************/ | ||
package org.eclipse.swt.custom; | ||
|
||
import org.eclipse.swt.graphics.*; | ||
import org.eclipse.swt.internal.*; | ||
import org.eclipse.swt.widgets.*; | ||
|
||
/** | ||
* This class is used in the win32 implementation only to support | ||
* adjusting widgets in the common package to DPI changes | ||
* <p> | ||
* <b>IMPORTANT:</b> This class is <em>not</em> part of the public | ||
* API for SWT. It is marked public only so that it can be shared | ||
* within the packages provided by SWT. It is not available on all | ||
* platforms, and should never be called from application code. | ||
* </p> | ||
* @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a> | ||
* @noreference This class is not intended to be referenced by clients | ||
*/ | ||
public class CommonWidgetsDPIChangeHandlers { | ||
|
||
public static void registerCommonHandlers() { | ||
DPIZoomChangeRegistry.registerHandler(CommonWidgetsDPIChangeHandlers::handleItemDPIChange, Item.class); | ||
} | ||
|
||
private static void handleItemDPIChange(Widget widget, int newZoom, float scalingFactor) { | ||
if (!(widget instanceof Item item)) { | ||
return; | ||
} | ||
// Refresh the image | ||
Image image = item.getImage(); | ||
if (image != null) { | ||
item.setImage(Image.win32_new(image, newZoom)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.