Skip to content

Commit a3526b1

Browse files
ShahzaibIbrahimakoch-yatta
authored andcommitted
Scale Table.GRID_WIDTH by zoom level instead of using fixed pixels
The Table.GRID_WIDTH constant specifies the extra width added to a table item when lines between columns are visible (`lineVisible = true`). This accounts for the space taken by the grid line. Previously, it was defined as a fixed pixel value, which appeared too small on high-DPI monitors. This change redefines GRID_WIDTH in points and scales it to pixels based on the current zoom level. At 100% zoom this results in 2px instead of 1px, which is visually negligible but ensures consistency by keeping all constants defined in points and scaled according to zoom level.
1 parent 9bf4caf commit a3526b1

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2334,11 +2334,11 @@ int getFocusIndex () {
23342334
*/
23352335
public int getGridLineWidth () {
23362336
checkWidget ();
2337-
return DPIUtil.pixelToPoint(getGridLineWidthInPixels(), getZoom());
2337+
return GRID_WIDTH;
23382338
}
23392339

23402340
int getGridLineWidthInPixels () {
2341-
return GRID_WIDTH;
2341+
return Win32DPIUtils.pointToPixel(GRID_WIDTH, getZoom());
23422342
}
23432343

23442344
/**
@@ -5308,7 +5308,7 @@ public void showColumn (TableColumn column) {
53085308
OS.GetScrollInfo (handle, OS.SB_HORZ, info);
53095309
int newPos = info.nPos;
53105310
if (newPos < oldPos) {
5311-
rect.right = oldPos - newPos + GRID_WIDTH;
5311+
rect.right = oldPos - newPos + getGridLineWidthInPixels();
53125312
OS.InvalidateRect (handle, rect, true);
53135313
}
53145314
}
@@ -6353,7 +6353,7 @@ LRESULT WM_HSCROLL (long wParam, long lParam) {
63536353
if (newPos < oldPos) {
63546354
RECT rect = new RECT ();
63556355
OS.GetClientRect (handle, rect);
6356-
rect.right = oldPos - newPos + GRID_WIDTH;
6356+
rect.right = oldPos - newPos + getGridLineWidthInPixels();
63576357
OS.InvalidateRect (handle, rect, true);
63586358
}
63596359
}
@@ -6462,9 +6462,9 @@ LRESULT WM_VSCROLL (long wParam, long lParam) {
64626462
long oneItem = OS.SendMessage (handle, OS.LVM_APPROXIMATEVIEWRECT, 1, 0);
64636463
int itemHeight = OS.HIWORD (oneItem) - OS.HIWORD (empty);
64646464
if (code == OS.SB_LINEDOWN) {
6465-
clientRect.top = clientRect.bottom - itemHeight - GRID_WIDTH;
6465+
clientRect.top = clientRect.bottom - itemHeight - getGridLineWidthInPixels();
64666466
} else {
6467-
clientRect.bottom = clientRect.top + itemHeight + GRID_WIDTH;
6467+
clientRect.bottom = clientRect.top + itemHeight + getGridLineWidthInPixels();
64686468
}
64696469
OS.InvalidateRect (handle, clientRect, true);
64706470
break;
@@ -7283,7 +7283,7 @@ LRESULT wmNotifyToolTip (NMTTCUSTOMDRAW nmcd, long lParam) {
72837283
}
72847284
if (drawForeground) {
72857285
int nSavedDC = OS.SaveDC (nmcd.hdc);
7286-
int gridWidth = getLinesVisible () ? Table.GRID_WIDTH : 0;
7286+
int gridWidth = getLinesVisible () ? getGridLineWidthInPixels() : 0;
72877287
RECT insetRect = toolTipInset (cellRect);
72887288
OS.SetWindowOrgEx (nmcd.hdc, insetRect.left, insetRect.top, null);
72897289
GCData data = new GCData ();

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ RECT getBounds (int row, int column, boolean getText, boolean getImage, boolean
415415
* the grid width when the grid is visible. The fix is to
416416
* move the top of the rectangle up by the grid width.
417417
*/
418-
int gridWidth = parent.getLinesVisible () ? Table.GRID_WIDTH : 0;
418+
int gridWidth = parent.getLinesVisible () ? parent.getGridLineWidthInPixels() : 0;
419419
rect.top -= gridWidth;
420420
if (column != 0) rect.left += gridWidth;
421421
rect.right = Math.max (rect.right, rect.left);

0 commit comments

Comments
 (0)