Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 318376 - Tree with background image draws incorrectly on new TreeItem
Summary: Tree with background image draws incorrectly on new TreeItem
Status: CLOSED WONTFIX
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 3.6   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Platform-SWT-Inbox CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords:
Depends on:
Blocks:
 
Reported: 2010-06-29 15:44 EDT by ArronM CLA
Modified: 2022-01-10 15:28 EST (History)
0 users

See Also:


Attachments
What happens after clicking "Add Row" once (47.69 KB, image/png)
2010-06-29 15:46 EDT, ArronM CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description ArronM CLA 2010-06-29 15:44:12 EDT
Build Identifier: SWT3650

Given a tree with setBackgroundImage set, the whole table isn't not repainted on a "new TreeItem(..)". Only the area with the rows plus one row height is invalidated.

See snippet below.  Click the Add Row button and the circle will shift down (must be a Windows optimization thing).  Workaround is to call redraw() on adding a row ("Add Row With Redraw" button), but it has an ugly flicker to it.


Reproducible: Always

Steps to Reproduce:
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.*;

public class testTableBackground
{

	public static void main(String[] args) {
		Display display = new Display();
		Shell shellMain = new Shell(display, SWT.SHELL_TRIM);
		GridLayout l = new GridLayout();
		l.marginHeight = l.marginWidth = 10;
		shellMain.setLayout(l);

		final Tree tree = new Tree(shellMain, SWT.BORDER | SWT.VIRTUAL
				| SWT.FULL_SELECTION);
		GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
		tree.setLayoutData(gridData);

		new TreeColumn(tree, SWT.RIGHT);

		tree.setHeaderVisible(true);
		tree.getColumn(0).setWidth(300);

		int size = 200;
		Image image = new Image(display, size, size);
		GC gc = new GC(image);
		gc.setForeground(display.getSystemColor(SWT.COLOR_GRAY));
		gc.drawOval(0, 0, size, size);
		gc.dispose();
		tree.setBackgroundImage(image);

		Button button = new Button(shellMain, SWT.PUSH);
		button.setText("Add Row");
		button.addListener(SWT.Selection, new Listener() {
			public void handleEvent(Event event) {
				new TreeItem(tree, SWT.NONE).setText("row");
			}
		});

		Button button2 = new Button(shellMain, SWT.PUSH);
		button2.setText("Add Row And Redraw");
		button2.addListener(SWT.Selection, new Listener() {
			public void handleEvent(Event event) {
				new TreeItem(tree, SWT.NONE).setText("row");
				tree.redraw();
			}
		});

		////////////////

		shellMain.setSize(400, 600);
		shellMain.open();

		while (!shellMain.isDisposed()) {
			try {
				if (!display.readAndDispatch())
					display.sleep();
			} catch (Throwable t) {
				t.printStackTrace();
			}
		}
		display.dispose();
	}
Comment 1 ArronM CLA 2010-06-29 15:46:14 EDT
Created attachment 173040 [details]
What happens after clicking "Add Row" once
Comment 2 ArronM CLA 2010-06-29 15:54:53 EDT
Wish I could edit comments and remove the double negative of "isn't not".  Just mentally ignore the "not" please :)
Comment 3 Eclipse Webmaster CLA 2019-09-06 16:09:56 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.
Comment 4 Eclipse Genie CLA 2022-01-10 15:28:23 EST
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. As such, we're closing this bug.

If you have further information on the current state of the bug, please add it and reopen this bug. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.