Skip to content

Conversation

ShahzaibIbrahim
Copy link
Contributor

The Table.INSET constant defines the spacing in the width of a table cell. Previously, this was a fixed value of 3px, which looks correct at 100% zoom but causes the image and text to appear cramped on higher-DPI displays.

This change defines INSET in points and converts it to pixels based on the current zoom level (e.g. 6px at 200%), ensuring consistent spacing across different monitor scale.

How to Test

  • Run the following snippet with 100% primary and 250% secondary monitor zoom
  • Note down the width of a cell by moving it from one monitor to other.
  • See if the values adhere to zoom levels.
import org.eclipse.swt.*;
import org.eclipse.swt.graphics.*;
import org.eclipse.swt.widgets.*;

public class TableInsetTest {

public static void main (String [] args) {
	System.setProperty("swt.autoScale", "quarter");
	System.setProperty("swt.autoScale.updateOnRuntime", "true");
	Display display = new Display ();
	Shell shell = new Shell (display);
	shell.setText("Table Inset Test");
	Table table = new Table (shell, SWT.BORDER | SWT.MULTI);
	table.setLinesVisible(true);
	Rectangle clientArea = shell.getClientArea ();
	table.setBounds (clientArea.x, clientArea.y, 200, 200);
	for (int i=0; i<128; i++) {
		TableItem item = new TableItem (table, SWT.NONE);
		item.setText ("Item " + i);
	}
	table.setSelection (95);
	shell.pack ();
	shell.open ();
	while (!shell.isDisposed ()) {
		if (!display.readAndDispatch ()) display.sleep ();
	}
	display.dispose ();
}
}

Results:
Before Change
Width 150% = 77
Width 250% = 128

After change
Width 150% = 84
Width 250% = 139

Copy link
Contributor

github-actions bot commented Aug 27, 2025

Test Results

   546 files  ±0     546 suites  ±0   31m 29s ⏱️ - 5m 15s
 4 426 tests ±0   4 409 ✅ ±0   17 💤 ±0  0 ❌ ±0 
16 750 runs  ±0  16 623 ✅ ±0  127 💤 ±0  0 ❌ ±0 

Results for commit 0d2c14c. ± Comparison against base commit 1ae0e18.

♻️ This comment has been updated with latest results.

The Table.INSET constant defines the spacing in the width of a table
cell. Previously, this was a fixed value of 3px, which looks correct at
100% zoom but causes the image and text to appear cramped on higher-DPI
displays.

This change defines INSET in points and converts it to pixels based on
the current zoom level (e.g. 6px at 200%), ensuring consistent spacing
across different monitor scale.
@akoch-yatta akoch-yatta force-pushed the master-404-TABLE-INSET branch from c5d338a to 0d2c14c Compare September 4, 2025 11:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Scale Table.INSET by zoom level instead of using fixed pixels
1 participant