Skip to content

Conversation

@HeikoKlare
Copy link
Contributor

The Windows Tree implementation only registers an image list at the OS control in case an image is set in the first column of an item of the tree. For images in the other columns, they are added to an SWT image list but since the images are embedded by SWT, no image list is registered at the OS.
The implementation of Tree.updateOrientation() does not consider that for the OS control no image list may have been set even if the SWT control manages an image list. As a consequence, calling Tree.setOrientation() on a Tree whose items do not have any image in the first column leads to all those items receiving a white space where an image might be placed as an empty image list is registered at the OS.

This change adapts the Tree.updateOrientation() implementation to only refresh the OS image list for the control in case one was already set before. In addition to calling Tree.setOrientation() this also affects DPI changes when moving the containing shell to a monitor with a different zoom where the same happens because of a call to Tree.updateOrientation().

Contributes to #3075

How to reproduce

Execute this snippet:

	public static void main(String[] args) {
		Display display = new Display();
		Shell shell = new Shell(display);
		shell.setLayout(new FillLayout());

		Tree tree = new Tree(shell, SWT.BORDER | SWT.FULL_SELECTION);
		tree.setLinesVisible(true);
		TreeColumn column1 = new TreeColumn(tree, SWT.NONE);
		column1.setWidth(200);
		TreeColumn column2 = new TreeColumn(tree, SWT.NONE);
		column2.setWidth(200);

		Image image = new Image(display, Snippet392.class.getResourceAsStream("eclipse.svg"));

		TreeItem item = new TreeItem(tree, SWT.None);
		item.setText(0, "Hello");
		item.setText(1, "World");
		item.setImage(1, image);
		new TreeItem(item, SWT.None);

		tree.setOrientation(SWT.LEFT_TO_RIGHT);
		shell.setSize(600, 150);
		shell.open();

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

		display.dispose();
	}

With the current code state it gives:
image

With this change (and without the call to tree.setOrientation()) it gives:
image

The Windows Tree implementation only registers an image list at the OS
control in case an image is set in the first column of an item of the
tree. For images in the other columns, they are added to an SWT image
list but since the images are embedded by SWT, no image list is
registered at the OS.
The implementation of Tree.updateOrientation() does not consider that
for the OS control no image list may have been set even if the SWT
control manages an image list. As a consequence, calling
Tree.setOrientation() on a Tree whose items do not have any image in the
first column leads to all those items receiving a white space where an
image might be placed as an empty image list is registered at the OS.

This change adapts the Tree.updateOrientation() implementation to only
refresh the OS image list for the control in case one was already set
before. In addition to calling Tree.setOrientation() this also affects
DPI changes when moving the containing shell to a monitor with a
different zoom where the same happens because of a call to
Tree.updateOrientation().

Contributes to
eclipse-platform#3075
@github-actions
Copy link
Contributor

Test Results (win32)

   34 files  ±0     34 suites  ±0   6m 35s ⏱️ + 1m 48s
4 649 tests ±0  4 576 ✅ ±0  73 💤 ±0  0 ❌ ±0 
  174 runs  ±0    171 ✅ ±0   3 💤 ±0  0 ❌ ±0 

Results for commit 1f2f51a. ± Comparison against base commit 9c79cf6.

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.

Images of trees in a non-first column disappear upon DPI change

1 participant