Skip to content

Commit

Permalink
Removed and replaced autoScaleUpUsingNativeDPI
Browse files Browse the repository at this point in the history
This commit replaces the DPIUtil.autoScaleUpUsingNativeDPI calls
from clients in win32 with DPIUtil.scaleUp utilizing the zoom
available within the clients. It additionally removes the method
DPIUtil.autoScaleUpUsingNativeDPI since it's not used anymore.

contributes to #62 and #127
  • Loading branch information
amartya4256 authored and HeikoKlare committed Jul 23, 2024
1 parent c66545b commit fc0098c
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -393,15 +393,6 @@ public static int scaleUp(int size, int zoom) {
return Math.round (size * scaleFactor);
}

/**
* Auto-scale up int dimensions using Native DPI
*/
public static int autoScaleUpUsingNativeDPI (int size) {
if (nativeDeviceZoom == 100 || size == SWT.DEFAULT) return size;
float nativeScaleFactor = nativeDeviceZoom / 100f;
return Math.round (size * nativeScaleFactor);
}

/**
* Auto-scale up int dimensions if enabled for Drawable class.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1314,7 +1314,7 @@ private int getCheckboxTextOffset(long hdc) {
OS.GetThemePartSize(display.hButtonTheme(), hdc, OS.BP_CHECKBOX, OS.CBS_UNCHECKEDNORMAL, null, OS.TS_TRUE, size);
result += size.cx;
} else {
result += DPIUtil.autoScaleUpUsingNativeDPI(13);
result += DPIUtil.scaleUp(13, nativeZoom);
}

// Windows uses half width of '0' as checkbox-to-text distance.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1161,7 +1161,7 @@ LRESULT wmMeasureChild (long wParam, long lParam) {
* NOTE: autoScaleUpUsingNativeDPI() is used to avoid problems
* with applications that disable automatic scaling.
*/
struct.itemWidth = DPIUtil.autoScaleUpUsingNativeDPI(5);
struct.itemWidth = DPIUtil.scaleUp(5, nativeZoom);
OS.MoveMemory (lParam, struct, MEASUREITEMSTRUCT.sizeof);
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6915,7 +6915,7 @@ LRESULT wmNotifyHeader (NMHDR hdr, long wParam, long lParam) {
* Sort indicator size needs to scale as per the Native Windows OS DPI level
* when header is custom drawn. For more details refer bug 537097.
*/
int leg = DPIUtil.autoScaleUpUsingNativeDPI(3);
int leg = DPIUtil.scaleUp(3, nativeZoom);
if (sortDirection == SWT.UP) {
OS.Polyline(nmcd.hdc, new int[] {center-leg, 1+leg, center+1, 0}, 2);
OS.Polyline(nmcd.hdc, new int[] {center+leg, 1+leg, center-1, 0}, 2);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7884,7 +7884,7 @@ LRESULT wmNotifyHeader (NMHDR hdr, long wParam, long lParam) {
* Sort indicator size needs to scale as per the Native Windows OS DPI level
* when header is custom drawn. For more details refer bug 537097.
*/
int leg = DPIUtil.autoScaleUpUsingNativeDPI(3);
int leg = DPIUtil.scaleUp(3, nativeZoom);
if (sortDirection == SWT.UP) {
OS.Polyline(nmcd.hdc, new int[] {center-leg, 1+leg, center+1, 0}, 2);
OS.Polyline(nmcd.hdc, new int[] {center+leg, 1+leg, center-1, 0}, 2);
Expand Down

0 comments on commit fc0098c

Please sign in to comment.