Skip to content

Commit d6709a4

Browse files
ShahzaibIbrahimakoch-yatta
authored andcommitted
Scale Table.DRAG_IMAGE_SIZE by zoom level instead of using fixed pixels
The Table.DRAG_IMAGE_SIZE constant specifies the width of the drag image when a table item is dragged. Previously, this value was fixed in pixels, which caused the drag image to appear too small on high-DPI monitors. This change redefines DRAG_IMAGE_SIZE in points and converts it to pixels based on the current zoom level, ensuring consistent drag image sizing across different display scales.
1 parent 2143c15 commit d6709a4

File tree

1 file changed

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

1 file changed

+3
-2
lines changed

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5745,8 +5745,9 @@ long windowProc (long hwnd, int msg, long wParam, long lParam) {
57455745
OS.GetClientRect (handle, clientRect);
57465746
TableItem item = _getItem (selection);
57475747
RECT rect = item.getBounds (selection, 0, true, true, true);
5748+
int dragImageSizeInPixel = Win32DPIUtils.pointToPixel(DRAG_IMAGE_SIZE, getZoom());
57485749
if ((style & SWT.FULL_SELECTION) != 0) {
5749-
int width = DRAG_IMAGE_SIZE;
5750+
int width = dragImageSizeInPixel;
57505751
rect.left = Math.max (clientRect.left, mousePos.x - width / 2);
57515752
if (clientRect.right > rect.left + width) {
57525753
rect.right = rect.left + width;
@@ -5757,7 +5758,7 @@ long windowProc (long hwnd, int msg, long wParam, long lParam) {
57575758
}
57585759
long hRgn = OS.CreateRectRgn (rect.left, rect.top, rect.right, rect.bottom);
57595760
while ((selection = (int)OS.SendMessage (handle, OS.LVM_GETNEXTITEM, selection, OS.LVNI_SELECTED)) != -1) {
5760-
if (rect.bottom - rect.top > DRAG_IMAGE_SIZE) break;
5761+
if (rect.bottom - rect.top > dragImageSizeInPixel) break;
57615762
if (rect.bottom > clientRect.bottom) break;
57625763
RECT itemRect = item.getBounds (selection, 0, true, true, true);
57635764
long rectRgn = OS.CreateRectRgn (rect.left, itemRect.top, rect.right, itemRect.bottom);

0 commit comments

Comments
 (0)