| Summary: | ToolItems get resized by the first ToolItem in the Toolbar | ||||||
|---|---|---|---|---|---|---|---|
| Product: | [Eclipse Project] Platform | Reporter: | Flavio Donze <flavio.donze> | ||||
| Component: | SWT | Assignee: | Project Inbox <swt-triaged> | ||||
| Status: | RESOLVED WONTFIX | QA Contact: | Felipe Heidrich <eclipse.felipe> | ||||
| Severity: | normal | ||||||
| Priority: | P3 | CC: | cgold, cocoakevin, markus.kell.r, pwebster, remy.suen, Silenio_Quarti | ||||
| Version: | 3.5 | ||||||
| Target Milestone: | --- | ||||||
| Hardware: | PC | ||||||
| OS: | Windows XP | ||||||
| Whiteboard: | |||||||
| Attachments: |
|
||||||
Do you have this problem with general uses of IToolBarManagers such as standalone JFace applications or ones that uses a workbench view's toolbar? This could be a Forms bug. Just did a test and added the actions to the workbechwindow toolbar, same result the images get resized. Don't know about standalone applications. Should I do a test? Created attachment 155605 [details]
SWT Toolbar Test
I just attached a SWT Toolbar test project. There you can see the effect, the second (Refresh.gif 16x16) is resized to size of the first image (LogoLong16.png 124x16). So this is not a Forms but SWT bug. Did some further investigations.
The problem seems to be in Toolbar.computeSize() which is called during pack().
if (count != 0) {
RECT rect = new RECT ();
OS.SendMessage (handle, OS.TB_GETITEMRECT, count - 1, rect);
width = Math.max (width, rect.right);
height = Math.max (height, rect.bottom);
}
'width' is double the size of the first icon + 14.
46 when the 16x16 icon is added first and 262 if the 124x16 icon is added first.
I guess the icons are then stretched out equally to fit this size.
In win32, all images in the toolbar are added to the same image list, for that reason they are have to have the same size: http://msdn.microsoft.com/en-us/library/bb761389(VS.85).aspx In another words, in win32 all images in the toolbar control must have the same size. Closing as wont fix (platform limitation). |
Build id: I20090611-1540 Having the following code construct, Logo.png has a width of 125px and the refresh icon 16px. When adding the logoAction first to the toolbar the refresh icon is resized to 125px and when adding the refreshAction first the logoAction is resized to 16px. FormToolkit toolkit = new FormToolkit(Display.getCurrent()); ScrolledForm form = toolkit.createScrolledForm(parent); toolkit.decorateFormHeading(form.getForm()); IToolBarManager toolBarManager = form.getToolBarManager(); toolBarManager.removeAll(); toolBarManager.update(true); Action refreshAction = new Action("Refresh", UIPlugin.getImageDescriptor(IconConstants.REFRESH)) { @Override public void run() { } }; Action logoAction = new Action("Logo", UIPlugin.getImageDescriptor("Logo.png")) { @Override public void run() { } }; toolBarManager.add(logoAction); toolBarManager.add(new Separator()); toolBarManager.add(refreshAction); form.updateToolBar();