Skip to content

Commit 4733859

Browse files
ShahzaibIbrahimakoch-yatta
authored andcommitted
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 1bad9a2 commit 4733859

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

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

Lines changed: 4 additions & 4 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
/**
@@ -8056,7 +8056,7 @@ LRESULT wmNotifyHeader (NMHDR hdr, long wParam, long lParam) {
80568056
int deltaX = newItem.cxy - oldItem.cxy;
80578057
RECT headerRect = new RECT ();
80588058
OS.SendMessage (hwndHeader, OS.HDM_GETITEMRECT, phdn.iItem, headerRect);
8059-
int gridWidth = linesVisible ? GRID_WIDTH : 0;
8059+
int gridWidth = linesVisible ? Win32DPIUtils.pointToPixel(GRID_WIDTH, getZoom()) : 0;
80608060
rect.left = headerRect.right - gridWidth;
80618061
int newX = rect.left + deltaX;
80628062
rect.right = Math.max (rect.right, rect.left + Math.abs (deltaX));
@@ -8235,7 +8235,7 @@ LRESULT wmNotifyToolTip (NMTTCUSTOMDRAW nmcd, long lParam) {
82358235
}
82368236
if (drawForeground) {
82378237
int nSavedDC = OS.SaveDC (nmcd.hdc);
8238-
int gridWidth = getLinesVisible () ? Table.GRID_WIDTH : 0;
8238+
int gridWidth = getLinesVisible () ? Win32DPIUtils.pointToPixel(GRID_WIDTH, getZoom()) : 0;
82398239
RECT insetRect = toolTipInset (cellRect [0]);
82408240
OS.SetWindowOrgEx (nmcd.hdc, insetRect.left, insetRect.top, null);
82418241
GCData data = new GCData ();

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)