[Win32] Table column resizing broken

Abierto
#3,777 1 comentario 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
54/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
java
Área
desktop, frontend

Línea de trabajo

Start by tracing how Table.getClientArea() and TableColumn.setWidth() interact with scrollbar sizing on Windows at 175% zoom. The issue provides a reproducer but names no implementation files or tests, so locate the relevant Win32 table code and existing resizing tests first. Done means resizing the window no longer shows a horizontal scrollbar when the column should fit the client area.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

HiDPI Windows

Describe the bug
We want a table column to be as wide as the table to avoid a horizontal scrollbar. This is broken with the rounding of getClientArea() for zoom factors like 175% (typical for 4k displays).

To Reproduce

import org.eclipse.swt.*;
import org.eclipse.swt.layout.*;
import org.eclipse.swt.widgets.*;

public class OneTableColumn {

	public static void main(String[] args) {
		final Display display = new Display();

		final Shell shell = new Shell(display);
		shell.setLayout(new FillLayout());

		final Table table = new Table(shell, SWT.BORDER | SWT.SINGLE | SWT.FULL_SELECTION | SWT.H_SCROLL | SWT.V_SCROLL);
		table.setHeaderVisible(false);
		final TableColumn column = new TableColumn(table, SWT.LEFT);
		column.setResizable(false);
		table.addListener(SWT.Resize, new Listener() {
			private boolean updating;

			@Override
			public void handleEvent(Event event) {
				updateColumnWidth();
				// Update again after SWT has adjusted the scrollbars.
				display.asyncExec(() -> {
					if (!table.isDisposed()) {
						updateColumnWidth();
					}
				});
			}

			private void updateColumnWidth() {
				if (updating) {
					return;
				}

				updating = true;
				try {
					final int width = table.getClientArea().width;
					if (column.getWidth() != width) {
						column.setWidth(width);
					}
				}
				finally {
					updating = false;
				}
			}
		});

		for (int i = 0; i < 10; i++) {
			new TableItem(table, SWT.NONE).setText("Item " + i);
		}

		shell.setSize(400, 300);
		shell.open();

		while (!shell.isDisposed()) {
			if (!display.readAndDispatch()) {
				display.sleep();
			}
		}

		display.dispose();
	}
}
  • run this snippet on Windows with a zoom factor of 175%
  • resize the window -> the horizontal scrollbar occurs for some window widths
  • even changing column.setWidth(width) to column.setWidth(width - 1) does not prevent the scrollbar from occurring

Expected behavior
The column should be as wide as the client area, but not wider, so no horizontal scrollbar is shown.

Screenshots
Image

Environment:

  1. Select the platform(s) on which the behavior is seen:
    • All OS
    • Windows
    • Linux
    • macOS
  1. Additional OS info (e.g. OS version, Linux Desktop, etc)
    Windows 11 25H2

Workaround (or) Additional context
Workaround: use SWT v4972r4 or earlier

Lenguaje dominante
Java
Estrellas
202
Forks
206
Merge medio
1 d 22 h
PR fusionados (30 d)
102

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de eclipse-platform/eclipse.platform.swt

Todos los issues de eclipse-platform/eclipse.platform.swt

Issues similares

Más issues de Java

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.