Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 321974

Summary: False presentation of a control contributed through the org.eclipse.ui.menu extension point
Product: [Eclipse Project] Platform Reporter: Adam Lukaszewski <adam.lukaszewski>
Component: SWTAssignee: Scott Kovatch <skovatch>
Status: RESOLVED FIXED QA Contact: Silenio Quarti <Silenio_Quarti>
Severity: normal    
Priority: P3 CC: eclipse.felipe, prakash, skovatch
Version: 3.6   
Target Milestone: 3.7 M2   
Hardware: PC   
OS: Mac OS X   
Whiteboard:
Attachments:
Description Flags
Test project
none
Ubuntu 10.04 screenshot
none
MAC OS X 10.6 screenshot
none
Windows Vista screenshot
none
Snippet should demonstrate the alignment problem
none
Fix none

Description Adam Lukaszewski CLA 2010-08-06 07:43:52 EDT
Build Identifier: 20100617-1415

Hello Eclipse-Team,

I have found the following bug. By using the implemented extension point named org.eclipse.ui.menus I have added a custom control. The visual presentation of this control in my toolbar under windows vista as well as ubuntu 10.04 is fine (see screenshots). Under MAC OS X 10.6 the visual presentation seems not to be correct. Obviously there is a mismatch with the position of the control.

For better understanding I have added 3 screenshots and an example project. Any suggestions or workarounds would be very helpful.

Kind regards,
Adam

Reproducible: Always

Steps to Reproduce:
1. import toolbar_control.zip
2. Start project
3. See bug :)
Comment 1 Adam Lukaszewski CLA 2010-08-06 07:44:21 EDT
Created attachment 176023 [details]
Test project
Comment 2 Adam Lukaszewski CLA 2010-08-06 07:44:49 EDT
Created attachment 176024 [details]
Ubuntu 10.04 screenshot
Comment 3 Adam Lukaszewski CLA 2010-08-06 07:45:13 EDT
Created attachment 176025 [details]
MAC OS X 10.6 screenshot
Comment 4 Adam Lukaszewski CLA 2010-08-06 07:45:38 EDT
Created attachment 176026 [details]
Windows Vista screenshot
Comment 5 Prakash Rangaraj CLA 2010-08-06 08:49:47 EDT
You have set the FormData and set it on the button. However, you have not set any layoutdata for the composite itself - and I don't think its possible, as the Composite's parent is ToolBar & you can't set a layout on it.

    I think the bug has to do with the default positioning of items in the Toolbar on Mac. Assigning to SWT for comments.
Comment 6 Adam Lukaszewski CLA 2010-08-09 04:19:31 EDT
Hello,

I don't think that the problem results from the layout that I've set. Even when you add only a button or another control you will see this mismatch in presentation. Anyway I have very often used the toolbar to add a parent composite for additional other controls without any problems.  

"I think the bug has to do with the default positioning of items in the
Toolbar on Mac. Assigning to SWT for comments."

I agree with you...

Best regards,
Adam
Comment 7 Adam Lukaszewski CLA 2010-08-20 04:51:43 EDT
Does anyone have an idea?

regards
Comment 8 Felipe Heidrich CLA 2010-08-20 10:03:02 EDT
Can you write a SWT snippet that reproduces the problem ?

Are you using cocoa or carbon ?
Comment 9 Scott Kovatch CLA 2010-08-20 11:58:19 EDT
I verified it does happen on Cocoa, but I don't have any immediate suggestions as to what to do about it. The attached test project will work fine for verification.
Comment 10 Adam Lukaszewski CLA 2010-08-20 12:12:30 EDT
Hi,

I have prepared a more compact test case for you (see attachment). Hopefully the snippet will show exactly the same problem as for the plugin-application. The fact is that I have no possibility to  instantaneously test the appearance of the toolbar on a MAC. I stumbled upon this problem while I a friend has started my application on his MAC. I have already asked him whether he can test the snippet for me and for some more information about his environment. I will provide the information as soon as possible!

Thanks for your effort.

Cheers, 
Adam
Comment 11 Adam Lukaszewski CLA 2010-08-20 12:13:56 EDT
Created attachment 177108 [details]
Snippet should demonstrate the alignment problem
Comment 12 Scott Kovatch CLA 2010-08-20 13:58:23 EDT
(In reply to comment #11)
> Created an attachment (id=177108) [details]
> Snippet should demonstrate the alignment problem

In this case the FormLayout is tripping you up. By default they have a top and left margin of 5, so the buttons in the second composite are shifted right and down 5 pixels. Setting the width to 100 forces the second button onto the next line of the layout so you can't see it.

I don't think this is related to the original problem, though. On the Mac the dark red Composite is being placed at 37 pixels from the top of the window and the button is being placed at 0, 0 within the Composite, so the button isn't the problem. Not sure about the Composite yet, though.
Comment 13 Scott Kovatch CLA 2010-08-20 16:00:29 EDT
Created attachment 177140 [details]
Fix
Comment 14 Scott Kovatch CLA 2010-08-20 16:01:16 EDT
Found the problem, but I'm not sure of the fix. On Cocoa ToolBars are emulated, in that they are just NSButtons inside NSViews laid out in a row. When the items are of different sizes, ToolBar.layoutHorizontal() centers each item vertically relative to the tallest item in the toolbar. Win32 has a real toolbar control, so it behaves differently in this case. Looks like GTK has a toolbar control, too.

Patch attached, but needs more testing.
Comment 15 Scott Kovatch CLA 2010-08-27 12:48:14 EDT
Fixed > 20100827, using attached patch.