Skip to content

Commit b8a2c8c

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 b8a2c8c

File tree

1 file changed

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

1 file changed

+8
-8
lines changed

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

Lines changed: 8 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, getZoom());
471+
itemRect.right += Win32DPIUtils.pointToPixel(EXPLORER_EXTRA, getZoom()) + 1;
472472
pClipRect.left = itemRect.left;
473473
pClipRect.right = itemRect.right;
474474
if (columnCount > 0 && hwndHeader != 0) {
@@ -1135,11 +1135,11 @@ LRESULT CDDS_ITEMPREPAINT (NMTVCUSTOMDRAW nmcd, long wParam, long lParam) {
11351135
if (measureEvent != null) {
11361136
pRect.right = Math.min (pClipRect.right, boundsInPixels.x + boundsInPixels.width);
11371137
} else {
1138-
pRect.right += EXPLORER_EXTRA;
1139-
pClipRect.right += EXPLORER_EXTRA;
1138+
pRect.right += Win32DPIUtils.pointToPixel(EXPLORER_EXTRA, getZoom());
1139+
pClipRect.right += Win32DPIUtils.pointToPixel(EXPLORER_EXTRA, getZoom());
11401140
}
1141-
pRect.left -= EXPLORER_EXTRA;
1142-
pClipRect.left -= EXPLORER_EXTRA;
1141+
pRect.left -= Win32DPIUtils.pointToPixel(EXPLORER_EXTRA, getZoom());
1142+
pClipRect.left -= Win32DPIUtils.pointToPixel(EXPLORER_EXTRA, getZoom());
11431143
long hTheme = OS.OpenThemeData (handle, Display.TREEVIEW, getZoom());
11441144
int iStateId = selected ? OS.TREIS_SELECTED : OS.TREIS_HOT;
11451145
if (OS.GetFocus () != handle && selected && !hot) iStateId = OS.TREIS_SELECTEDNOTFOCUS;
@@ -1208,8 +1208,8 @@ LRESULT CDDS_ITEMPREPAINT (NMTVCUSTOMDRAW nmcd, long wParam, long lParam) {
12081208
OS.SaveDC (hDC);
12091209
OS.SelectClipRgn (hDC, 0);
12101210
if (explorerTheme) {
1211-
itemRect.left -= EXPLORER_EXTRA;
1212-
itemRect.right += EXPLORER_EXTRA;
1211+
itemRect.left -= Win32DPIUtils.pointToPixel(EXPLORER_EXTRA, getZoom());
1212+
itemRect.right += Win32DPIUtils.pointToPixel(EXPLORER_EXTRA, getZoom());
12131213
}
12141214
//TODO - bug in Windows selection or SWT itemRect
12151215
/*if (selected)*/ itemRect.right++;

0 commit comments

Comments
 (0)