Bug 471313 - [win32] Height of controls in toolbar is incorrect when wrap is enabled and redraw is disabled
Summary: [win32] Height of controls in toolbar is incorrect when wrap is enabled and r...
Status: NEW
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 4.5   Edit
Hardware: PC Windows 7
: P3 normal with 21 votes (vote)
Target Milestone: ---   Edit
Assignee: Platform-SWT-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords: usability
: 465732 466609 471326 516021 517775 (view as bug list)
Depends on:
Blocks:
 
Reported: 2015-06-29 08:22 EDT by Mattias Andersson CLA
Modified: 2023-03-24 12:44 EDT (History)
27 users (show)

See Also:


Attachments
screenshot (2.53 KB, image/png)
2015-06-29 08:22 EDT, Mattias Andersson CLA
no flags Details
What the rendering is on Linux or MacOSX (1.84 KB, image/png)
2022-03-02 05:00 EST, Julien HENRY CLA
no flags Details
The rendering on Windows without workaround (1.16 KB, image/png)
2022-03-02 05:01 EST, Julien HENRY CLA
no flags Details
The rendering on Windows HiDPI with workaround (2.27 KB, image/png)
2022-03-02 05:03 EST, Julien HENRY CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Mattias Andersson CLA 2015-06-29 08:22:06 EDT
Created attachment 254800 [details]
screenshot

I have a simple menu contribution extension that contributes a tool bar to the Trim. The toolbar has a single control that displays an Icon. However the toolbar is cropped and is placed lower than other toolbars. It does not look like the control is to blame but rather the complete toolbar (see attachment). 

The provided example works well in Luna. This affects tools such as https://code.google.com/a/eclipselabs.org/p/workspacemechanic.  


Example:

<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
   <extension
         id="test.ext.1"
         point="org.eclipse.ui.menus">
      <menuContribution
            allPopups="false"
            locationURI="toolbar:org.eclipse.ui.trim.status">
         <toolbar
               id="test.toolbar.1"
               label="Test toolbar">
            <control
                  class="test.MyWorkbenchWindowControlContribution"
               id="test.toolbar.ctrl.1">
            </control>
         </toolbar>
      </menuContribution>
   </extension>
</plugin>




public class MyWorkbenchWindowControlContribution extends WorkbenchWindowControlContribution {

	@Override
	protected Control createControl(Composite parent) {

		Composite comp = new Composite(parent, SWT.NONE);

		FillLayout layout = new FillLayout();
		comp.setLayout(layout);

		Label control = new Label(comp, SWT.CENTER);
		control.setEnabled(true);

		Image image = PlatformUI.getWorkbench().getSharedImages()
				.getImage(org.eclipse.ui.ide.IDE.SharedImages.IMG_OBJ_PROJECT);
		control.setImage(image);
		return comp;
	}
Comment 1 Mattias Andersson CLA 2015-06-30 13:20:15 EDT
Works as expected on -os macosx -ws cocoa -arch x86_64
Comment 2 Sam Davis CLA 2015-07-14 17:37:29 EDT
I am seeing the same thing. Trims contributed as menuContributions in Mars do not show up correctly on Windows.
Comment 3 Sam Davis CLA 2015-07-14 19:55:54 EDT
The toolbar gets created with the correct height if you contribute a command to it as its first child. This is why the Mylyn active task trim works correctly (org.eclipse.mylyn.internal.tasks.ui.TaskTrimWidget).
Comment 4 Mattias Andersson CLA 2015-07-17 05:25:04 EDT
Yes, the icon is positioned correctly if a command is contributed to the toolbar. The command must have a label to display some text.
Comment 5 Christoph Kaser CLA 2015-08-03 05:26:53 EDT
I have the same problem on Windows 8.1 - apparently the toolbar height is set to 7 pixels if there is no command in it. I did not find any workaround other than adding a "dummy" command that functions as "label".
Comment 6 Jonathan Dumont CLA 2015-08-07 16:45:57 EDT
Hi,

I have the same problem on Windows 10. Our contributions contain Text field and the fact that as they are cropped as a real impact...

I will try the workaround until a better solution.

Regards
Comment 7 Eric Moffatt CLA 2015-08-17 15:45:04 EDT
You may want to check the Windows forums...AFAIK this is baked in to the windows toolbars (i.e. I've never been able to find a fix...;-).
Comment 8 Sam Davis CLA 2015-08-18 12:35:45 EDT
This works correctly in Eclipse 3.8 (and I think also in 4.2).
Comment 9 Jonathan Dumont CLA 2015-08-18 14:57:01 EDT
I confirm that it's working with a Luna RCP application on windows 10, and not with a Mars RCP application, on the same OS.

Moreover, the workaround which consists on adding a command in the toolbar is working.
Comment 10 Andrei Neshcheret CLA 2015-08-27 06:49:04 EDT
Confirm, the control contribution not worked on windows 7 with eclipse mars rcp application.
Comment 11 Lars Vogel CLA 2016-04-20 12:14:33 EDT
Mass move to 4.7 as M7 is approaching. Please move back in case you are planning to fix it for Neon.
Comment 12 Maarten Verburg CLA 2016-06-06 09:00:38 EDT
After also running into this issue on Eclipse Mars I've used the workaround described in https://bugs.eclipse.org/bugs/show_bug.cgi?id=471313

It boils down to:

public class MyWorkbenchWindowControlContribution extends WorkbenchWindowControlContribution {

	@Override
	protected Control createControl(Composite parent) {
            parent.getParent().setRedraw(true);
            ....
        }

	@Override
	public boolean isDynamic() {
		return true;
	}
Comment 13 Josef Lehner CLA 2016-07-26 14:36:15 EDT
(In reply to Maarten Verburg from comment #12)

Thank you Maarten for posting the workaround, it worked on Windows 7 and Neon.
Comment 14 Andrey Loskutov CLA 2017-05-02 03:04:35 EDT
*** Bug 466609 has been marked as a duplicate of this bug. ***
Comment 15 Andrey Loskutov CLA 2017-05-02 03:04:59 EDT
*** Bug 471326 has been marked as a duplicate of this bug. ***
Comment 16 Andrey Loskutov CLA 2017-05-02 03:07:05 EDT
If someone has a patch, we have only few days left to integrate it into 4.7.

I haven't tried this, but there seem to be a reproducer application in bug 471326 (see https://bugs.eclipse.org/bugs/attachment.cgi?id=254802).
Comment 17 Andrey Loskutov CLA 2017-05-02 03:11:18 EDT
*** Bug 516021 has been marked as a duplicate of this bug. ***
Comment 18 Johan Ansems CLA 2017-12-19 05:30:26 EST
Encountered the same issue here on windows 10.
in 4.4.2 this was still going fine.
in 4.6.1 this issue occurred.

This workaround from Maarten Verburg seems to solve the problem for now.
Thanks!
Comment 19 Shinji Kashihara CLA 2018-02-04 21:06:45 EST
This problem is occurring on the HiDPI environment.

> Labels are cut off in Windows when at 200% scale on HiDPI.
> https://github.com/cypher256/eclipse-encoding-plugin/issues/10
Comment 20 Rocus Halbasch CLA 2018-02-05 09:54:11 EST
The workaround does not fix the problem in the HiDPI environment.
Comment 21 Lars Vogel CLA 2020-06-10 07:33:54 EDT
Rolf, can you have a look?
Comment 22 Rolf Theunissen CLA 2020-06-10 09:25:23 EDT
*** Bug 517775 has been marked as a duplicate of this bug. ***
Comment 23 Rolf Theunissen CLA 2020-06-10 09:25:51 EDT
*** Bug 465732 has been marked as a duplicate of this bug. ***
Comment 24 Rolf Theunissen CLA 2020-06-10 09:30:59 EDT
(In reply to Lars Vogel from comment #21)
> Rolf, can you have a look?

Lars, I had a look, but probably the issue is in SWT as the 'fix' doesn't make sense to me.

The following change resolves the issue, in ToolBarManger#update, change the finally the code below. The duplication is not a mistake, it does fix it.

} finally {
	toolBar.setRedraw(true);
	toolBar.setRedraw(true);
}
Comment 25 Lars Vogel CLA 2020-06-10 09:37:00 EDT
(In reply to Rolf Theunissen from comment #24)
> (In reply to Lars Vogel from comment #21)
> > Rolf, can you have a look?
> 
> Lars, I had a look, but probably the issue is in SWT as the 'fix' doesn't
> make sense to me.
> 
> The following change resolves the issue, in ToolBarManger#update, change the
> finally the code below. The duplication is not a mistake, it does fix it.
> 
> } finally {
> 	toolBar.setRedraw(true);
> 	toolBar.setRedraw(true);
> }

That looks weird. Please move to SWT.
Comment 26 Rolf Theunissen CLA 2020-08-16 14:52:17 EDT
This bug is caused/uncovered the by changes in Bug 457214.

On windows it seems that the current setRedraw calls in ToolBarManager can be removed all together. Especially after Bug 90757 is fixed, which should reduce flickering.
Comment 27 Eclipse Genie CLA 2020-08-16 15:05:15 EDT
New Gerrit change created: https://git.eclipse.org/r/c/platform/eclipse.platform.ui/+/167774
Comment 28 Rolf Theunissen CLA 2020-08-23 11:29:53 EDT
The issue occurs in SWT toolbar when there are only separators with controls, the style of the toolbar is wrapped, and redraw is disabled.
These conditions are met in ToolBarManager.

The following SWT code reproduces the issue.

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

  ToolBar tb1 = new ToolBar (shell, SWT.WRAP);

  tb1.setRedraw(false);

  for (int i = 0; i < 4; i++) {
    Button b = new Button(tb1, SWT.PUSH);
    b.setText("Button" + i);
    b.pack();

    ToolItem ti = new ToolItem (tb1, SWT.SEPARATOR);
    ti.setWidth (b.getSize().x);
    ti.setControl (b);
  }

  tb1.setRedraw(true);

  shell.pack ();
  shell.open ();

  while (!shell.isDisposed ()) {
    if (!display.readAndDispatch ()) display.sleep ();
  }
  display.dispose ();
}
Comment 29 Julien HENRY CLA 2022-03-02 04:58:18 EST
Just to confirm the bug is still there with 2021-12.

On Windows, a control in the status bar is truncated.

We tried the workaround of #12 and it is improving the situation on normal screens. On HiDPI screen it is better, but still truncated. I will attach screenshots.
Comment 30 Julien HENRY CLA 2022-03-02 05:00:08 EST
Created attachment 288148 [details]
What the rendering is on Linux or MacOSX
Comment 31 Julien HENRY CLA 2022-03-02 05:01:52 EST
Created attachment 288149 [details]
The rendering on Windows without workaround
Comment 32 Julien HENRY CLA 2022-03-02 05:03:12 EST
Created attachment 288150 [details]
The rendering on Windows HiDPI with workaround