Skip to content

Commit 9bf4caf

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 3444886 commit 9bf4caf

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
@@ -2964,11 +2964,11 @@ TreeItem getFocusItem () {
29642964
*/
29652965
public int getGridLineWidth () {
29662966
checkWidget ();
2967-
return DPIUtil.pixelToPoint(getGridLineWidthInPixels (), getZoom());
2967+
return GRID_WIDTH;
29682968
}
29692969

29702970
int getGridLineWidthInPixels () {
2971-
return GRID_WIDTH;
2971+
return Win32DPIUtils.pointToPixel(GRID_WIDTH, getZoom());
29722972
}
29732973

29742974
/**
@@ -8060,7 +8060,7 @@ LRESULT wmNotifyHeader (NMHDR hdr, long wParam, long lParam) {
80608060
int deltaX = newItem.cxy - oldItem.cxy;
80618061
RECT headerRect = new RECT ();
80628062
OS.SendMessage (hwndHeader, OS.HDM_GETITEMRECT, phdn.iItem, headerRect);
8063-
int gridWidth = linesVisible ? GRID_WIDTH : 0;
8063+
int gridWidth = linesVisible ? getGridLineWidthInPixels() : 0;
80648064
rect.left = headerRect.right - gridWidth;
80658065
int newX = rect.left + deltaX;
80668066
rect.right = Math.max (rect.right, rect.left + Math.abs (deltaX));
@@ -8239,7 +8239,7 @@ LRESULT wmNotifyToolTip (NMTTCUSTOMDRAW nmcd, long lParam) {
82398239
}
82408240
if (drawForeground) {
82418241
int nSavedDC = OS.SaveDC (nmcd.hdc);
8242-
int gridWidth = getLinesVisible () ? Table.GRID_WIDTH : 0;
8242+
int gridWidth = getLinesVisible () ? getGridLineWidthInPixels() : 0;
82438243
RECT insetRect = toolTipInset (cellRect [0]);
82448244
OS.SetWindowOrgEx (nmcd.hdc, insetRect.left, insetRect.top, null);
82458245
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 ? parent.getGridLineWidthInPixels() : 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 ? parent.getGridLineWidthInPixels() : 0;
534534
if (getText || !getImage) {
535535
rect.right = Math.max (rect.left, rect.right - gridWidth);
536536
}

0 commit comments

Comments
 (0)