Skip to content

Commit 3444886

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

File tree

1 file changed

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

1 file changed

+12
-8
lines changed

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

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -467,8 +467,9 @@ 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+
int explorerExtraInPixels = Win32DPIUtils.pointToPixel(EXPLORER_EXTRA, zoom);
471+
itemRect.left -= explorerExtraInPixels;
472+
itemRect.right += explorerExtraInPixels + 1;
472473
pClipRect.left = itemRect.left;
473474
pClipRect.right = itemRect.right;
474475
if (columnCount > 0 && hwndHeader != 0) {
@@ -1129,17 +1130,19 @@ LRESULT CDDS_ITEMPREPAINT (NMTVCUSTOMDRAW nmcd, long wParam, long lParam) {
11291130
selectionForeground = clrText = OS.GetSysColor (OS.COLOR_HIGHLIGHTTEXT);
11301131
}
11311132
if (explorerTheme) {
1133+
int zoom = getZoom();
11321134
if ((style & SWT.FULL_SELECTION) == 0) {
11331135
RECT pRect = item.getBounds (index, true, true, false, false, false, hDC);
11341136
RECT pClipRect = item.getBounds (index, true, true, true, false, true, hDC);
1137+
int explorerExtraInPixels = Win32DPIUtils.pointToPixel(EXPLORER_EXTRA, zoom);
11351138
if (measureEvent != null) {
11361139
pRect.right = Math.min (pClipRect.right, boundsInPixels.x + boundsInPixels.width);
11371140
} else {
1138-
pRect.right += EXPLORER_EXTRA;
1139-
pClipRect.right += EXPLORER_EXTRA;
1141+
pRect.right += explorerExtraInPixels;
1142+
pClipRect.right += explorerExtraInPixels;
11401143
}
1141-
pRect.left -= EXPLORER_EXTRA;
1142-
pClipRect.left -= EXPLORER_EXTRA;
1144+
pRect.left -= explorerExtraInPixels;
1145+
pClipRect.left -= explorerExtraInPixels;
11431146
long hTheme = OS.OpenThemeData (handle, Display.TREEVIEW, getZoom());
11441147
int iStateId = selected ? OS.TREIS_SELECTED : OS.TREIS_HOT;
11451148
if (OS.GetFocus () != handle && selected && !hot) iStateId = OS.TREIS_SELECTEDNOTFOCUS;
@@ -1208,8 +1211,9 @@ LRESULT CDDS_ITEMPREPAINT (NMTVCUSTOMDRAW nmcd, long wParam, long lParam) {
12081211
OS.SaveDC (hDC);
12091212
OS.SelectClipRgn (hDC, 0);
12101213
if (explorerTheme) {
1211-
itemRect.left -= EXPLORER_EXTRA;
1212-
itemRect.right += EXPLORER_EXTRA;
1214+
int explorerExtraInPixels = Win32DPIUtils.pointToPixel(EXPLORER_EXTRA, getZoom());
1215+
itemRect.left -= explorerExtraInPixels;
1216+
itemRect.right += explorerExtraInPixels;
12131217
}
12141218
//TODO - bug in Windows selection or SWT itemRect
12151219
/*if (selected)*/ itemRect.right++;

0 commit comments

Comments
 (0)