From d05d80f438c6cd26a9b77dd5d99602d9b6f10c4c Mon Sep 17 00:00:00 2001 From: Shahzaib Ibrahim Date: Tue, 19 Aug 2025 15:52:19 +0200 Subject: [PATCH] Scale Tree.HEADER_MARGIN by zoom level instead of using fixed pixels The Tree.HEADER_MARGIN constant defines extra fixed-width spacing for tree headers. Previously, this was a fixed pixel value, which worked at 100% zoom but did not scale properly on high-DPI monitors. This change redefines HEADER_MARGIN in points and converts it to pixels based on the current zoom level, ensuring consistent header spacing across different display scales. --- .../Eclipse SWT/win32/org/eclipse/swt/widgets/TreeColumn.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TreeColumn.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TreeColumn.java index 0e66a543765..970c846ea7a 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TreeColumn.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TreeColumn.java @@ -375,8 +375,8 @@ public void pack () { int flags = OS.DT_CALCRECT | OS.DT_NOPREFIX; char [] buffer = text.toCharArray (); OS.DrawText (hDC, buffer, buffer.length, rect, flags); - int headerWidth = rect.right - rect.left + Tree.HEADER_MARGIN; - if (OS.IsAppThemed ()) headerWidth += Tree.HEADER_EXTRA; + int headerWidth = rect.right - rect.left + Win32DPIUtils.pointToPixel(Tree.HEADER_MARGIN, getZoom()); + if (OS.IsAppThemed ()) headerWidth += Win32DPIUtils.pointToPixel(Tree.HEADER_EXTRA, getZoom()); if (image != null || parent.sortColumn == this) { Image headerImage = null; if (parent.sortColumn == this && parent.sortDirection != SWT.NONE) {