Skip to content

Commit 5b271f9

Browse files
Scale Tree.EXPLORER_EXTRA by zoom level instead of using fixed pixels
The Tree.EXPLORER_EXTRA constant specifies the additional spacing applied to tree items when using the Explorer theme. Previously, this was defined as a fixed pixel value, which caused the extra spacing to appear too small on high-DPI monitors. This change redefines EXPLORER_EXTRA in points and converts it to pixels based on the current zoom level, ensuring consistent spacing in Explorer-themed trees across different display scales.
1 parent 93a484e commit 5b271f9

File tree

1 file changed

+9
-8
lines changed
  • bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets

1 file changed

+9
-8
lines changed

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

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -467,8 +467,8 @@ LRESULT CDDS_ITEMPOSTPAINT (NMTVCUSTOMDRAW nmcd, long wParam, long lParam) {
467467
if (explorerTheme) {
468468
if (hooks (SWT.EraseItem)) {
469469
RECT itemRect = item.getBounds (index, true, true, false, false, true, hDC);
470-
itemRect.left -= EXPLORER_EXTRA;
471-
itemRect.right += EXPLORER_EXTRA + 1;
470+
itemRect.left -= Win32DPIUtils.pointToPixel(EXPLORER_EXTRA, zoom);
471+
itemRect.right += Win32DPIUtils.pointToPixel(EXPLORER_EXTRA, zoom) + 1;
472472
pClipRect.left = itemRect.left;
473473
pClipRect.right = itemRect.right;
474474
if (columnCount > 0 && hwndHeader != 0) {
@@ -1129,17 +1129,18 @@ LRESULT CDDS_ITEMPREPAINT (NMTVCUSTOMDRAW nmcd, long wParam, long lParam) {
11291129
selectionForeground = clrText = OS.GetSysColor (OS.COLOR_HIGHLIGHTTEXT);
11301130
}
11311131
if (explorerTheme) {
1132+
int zoom = getZoom();
11321133
if ((style & SWT.FULL_SELECTION) == 0) {
11331134
RECT pRect = item.getBounds (index, true, true, false, false, false, hDC);
11341135
RECT pClipRect = item.getBounds (index, true, true, true, false, true, hDC);
11351136
if (measureEvent != null) {
11361137
pRect.right = Math.min (pClipRect.right, boundsInPixels.x + boundsInPixels.width);
11371138
} else {
1138-
pRect.right += EXPLORER_EXTRA;
1139-
pClipRect.right += EXPLORER_EXTRA;
1139+
pRect.right += Win32DPIUtils.pointToPixel(EXPLORER_EXTRA, zoom);
1140+
pClipRect.right += Win32DPIUtils.pointToPixel(EXPLORER_EXTRA, zoom);
11401141
}
1141-
pRect.left -= EXPLORER_EXTRA;
1142-
pClipRect.left -= EXPLORER_EXTRA;
1142+
pRect.left -= Win32DPIUtils.pointToPixel(EXPLORER_EXTRA, zoom);
1143+
pClipRect.left -= Win32DPIUtils.pointToPixel(EXPLORER_EXTRA, zoom);
11431144
long hTheme = OS.OpenThemeData (handle, Display.TREEVIEW, getZoom());
11441145
int iStateId = selected ? OS.TREIS_SELECTED : OS.TREIS_HOT;
11451146
if (OS.GetFocus () != handle && selected && !hot) iStateId = OS.TREIS_SELECTEDNOTFOCUS;
@@ -1208,8 +1209,8 @@ LRESULT CDDS_ITEMPREPAINT (NMTVCUSTOMDRAW nmcd, long wParam, long lParam) {
12081209
OS.SaveDC (hDC);
12091210
OS.SelectClipRgn (hDC, 0);
12101211
if (explorerTheme) {
1211-
itemRect.left -= EXPLORER_EXTRA;
1212-
itemRect.right += EXPLORER_EXTRA;
1212+
itemRect.left -= Win32DPIUtils.pointToPixel(EXPLORER_EXTRA, getZoom());
1213+
itemRect.right += Win32DPIUtils.pointToPixel(EXPLORER_EXTRA, getZoom());
12131214
}
12141215
//TODO - bug in Windows selection or SWT itemRect
12151216
/*if (selected)*/ itemRect.right++;

0 commit comments

Comments
 (0)