Skip to content

Commit 5014673

Browse files
Scale Tree.GRID_WIDTH by zoom level instead of using fixed pixels
The Tree.GRID_WIDTH constant specifies the extra width added to a tree item when lines between columns are visible (`lineVisible = true`). This compensates for the space taken by the grid line. Previously, this was defined as a fixed pixel value, which appeared too small on high-DPI monitors. This change redefines GRID_WIDTH in points and converts it to pixels based on the current zoom level, ensuring consistent column spacing across different display scales.
1 parent 1eb32bc commit 5014673

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Tree.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2960,11 +2960,11 @@ TreeItem getFocusItem () {
29602960
*/
29612961
public int getGridLineWidth () {
29622962
checkWidget ();
2963-
return DPIUtil.pixelToPoint(getGridLineWidthInPixels (), getZoom());
2963+
return GRID_WIDTH;
29642964
}
29652965

29662966
int getGridLineWidthInPixels () {
2967-
return GRID_WIDTH;
2967+
return Win32DPIUtils.pointToPixel(GRID_WIDTH, getZoom());
29682968
}
29692969

29702970
/**
@@ -8055,7 +8055,7 @@ LRESULT wmNotifyHeader (NMHDR hdr, long wParam, long lParam) {
80558055
int deltaX = newItem.cxy - oldItem.cxy;
80568056
RECT headerRect = new RECT ();
80578057
OS.SendMessage (hwndHeader, OS.HDM_GETITEMRECT, phdn.iItem, headerRect);
8058-
int gridWidth = linesVisible ? GRID_WIDTH : 0;
8058+
int gridWidth = linesVisible ? Win32DPIUtils.pointToPixel(GRID_WIDTH, getZoom()) : 0;
80598059
rect.left = headerRect.right - gridWidth;
80608060
int newX = rect.left + deltaX;
80618061
rect.right = Math.max (rect.right, rect.left + Math.abs (deltaX));

bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TreeColumn.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ public void pack () {
398398
}
399399
if (newFont != 0) OS.SelectObject (hDC, oldFont);
400400
OS.ReleaseDC (hwnd, hDC);
401-
int gridWidth = parent.linesVisible ? Tree.GRID_WIDTH : 0;
401+
int gridWidth = parent.linesVisible ? Win32DPIUtils.pointToPixel(Tree.GRID_WIDTH, getZoom()) : 0;
402402
setWidthInPixels (Math.max (headerWidth, columnWidth + gridWidth));
403403
}
404404

bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TreeItem.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,7 @@ RECT getBounds (int index, boolean getText, boolean getImage, boolean fullText,
530530
}
531531
}
532532
}
533-
int gridWidth = parent.linesVisible && columnCount != 0 ? Tree.GRID_WIDTH : 0;
533+
int gridWidth = parent.linesVisible && columnCount != 0 ? Win32DPIUtils.pointToPixel(Tree.GRID_WIDTH, getZoom()) : 0;
534534
if (getText || !getImage) {
535535
rect.right = Math.max (rect.left, rect.right - gridWidth);
536536
}

0 commit comments

Comments
 (0)