Bug 543895 - [GTK] Extra space to the right of ToolItems without text
Summary: [GTK] Extra space to the right of ToolItems without text
Status: VERIFIED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 4.10   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: 4.14 M1   Edit
Assignee: Eric Williams CLA
QA Contact:
URL:
Whiteboard: RHT
Keywords: triaged
Depends on:
Blocks:
 
Reported: 2019-01-28 07:29 EST by Andreu B CLA
Modified: 2019-10-08 13:34 EDT (History)
2 users (show)

See Also:


Attachments
screenshot showing the issue (4.50 KB, image/png)
2019-01-28 07:29 EST, Andreu B CLA
no flags Details
Sample image (657 bytes, image/jpeg)
2019-01-28 10:32 EST, Andreu B CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Andreu B CLA 2019-01-28 07:29:50 EST
Created attachment 277336 [details]
screenshot showing the issue

I'm not sure whether this is a bug or expected behavior.

Take a look at the snippet below. It has two ToolBars, both created with the style SWT.FLAT | SWT.RIGHT, and each toolbar has three PUSH items.

In the first toolbar, all items have an image, and none have any text. In all items the image is centered in the item.

In the second toolbar, all items have an image, and only one of them has text. The other items in this toolbar (which don't have any text) are wider that those on the first toolbar and the image is aligned left (looks like there's some extra space right after the image).

I would expect all items without text to look equal, and with the image centered, regardless of the presence of items with text in the same toolbar.

import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.ToolBar;
import org.eclipse.swt.widgets.ToolItem;

public class ToolItemsExtraSpace {

    public static void main(String[] args) {

        Display d = new Display();

        Shell s = new Shell(d);
        s.setLayout(new GridLayout());

        Image img = new Image(d, "/home/andreu/Downloads/save.png");

        ToolBar bar_1 = new ToolBar(s, SWT.FLAT | SWT.RIGHT);

        ToolItem ti_1_1 = new ToolItem(bar_1, SWT.PUSH);
        ti_1_1.setImage(img);

        ToolItem ti_1_2 = new ToolItem(bar_1, SWT.PUSH);
        ti_1_2.setImage(img);

        ToolItem ti_1_3 = new ToolItem(bar_1, SWT.PUSH);
        ti_1_3.setImage(img);

        new Label(s, SWT.SEPARATOR | SWT.HORIZONTAL);


        ToolBar bar_2 = new ToolBar(s, SWT.FLAT | SWT.RIGHT);

        ToolItem ti_2_1 = new ToolItem(bar_2, SWT.PUSH);
        ti_2_1.setImage(img);

        ToolItem ti_2_2 = new ToolItem(bar_2, SWT.PUSH);
        ti_2_2.setImage(img);

        ToolItem ti_2_3 = new ToolItem(bar_2, SWT.PUSH);
        ti_2_3.setImage(img);
        ti_2_3.setText("foo");

        s.open();
        while (!s.isDisposed()) {
            if (!d.readAndDispatch()) {
                d.sleep();
            }
        }
        d.dispose();
    }
}
Comment 1 Eric Williams CLA 2019-01-28 10:26:18 EST
Can you please attach the "save.png" file used to reproduce the issue?
Comment 2 Andreu B CLA 2019-01-28 10:32:40 EST
Created attachment 277341 [details]
Sample image
Comment 3 Andreu B CLA 2019-01-28 10:33:45 EST
Sure, just attached the image. It's a simple 16x16 icon from Fatcow (https://www.fatcow.com/free-icons)
Comment 4 Eric Williams CLA 2019-01-28 10:45:14 EST
(In reply to Andreu B from comment #3)
> Sure, just attached the image. It's a simple 16x16 icon from Fatcow
> (https://www.fatcow.com/free-icons)

Okay, I can reproduce the issue on Fedora 29, GTK3.24.3, SWT from master as of today. Do you think this bug is related to bug 395296?
Comment 5 Andreu B CLA 2019-04-03 07:29:20 EDT
On the surface, it doesn't look like the same bug to me. However I can't say if it has the same root cause or not; I'm not familiar enough with the internals of SWT.
Comment 6 Christian Pontesegger CLA 2019-08-20 06:09:26 EDT
I also experience this issue using a 2019-06 target platform. It is sufficient to populate a view toolbar with a mixture of icons and text buttons to see this behavior. Remove the text buttons and the icons do not show the extra space anymore.
Comment 7 Eric Williams CLA 2019-08-20 09:14:12 EDT
Please try with 4.13 M1, I believe this bug is fixed.
Comment 8 Eric Williams CLA 2019-09-17 12:02:51 EDT
(In reply to Eric Williams from comment #7)
> Please try with 4.13 M1, I believe this bug is fixed.

Ping, any update?
Comment 9 Christian Pontesegger CLA 2019-09-17 13:52:46 EDT
I will check with the 2019-09 release
Comment 10 Christian Pontesegger CLA 2019-09-25 10:37:38 EDT
I still see this issue with a 2019-09 target platform
Comment 11 Eclipse Genie CLA 2019-09-26 11:31:27 EDT
New Gerrit change created: https://git.eclipse.org/r/150203
Comment 13 Eric Williams CLA 2019-09-26 13:34:41 EDT
(In reply to Eclipse Genie from comment #12)
> Gerrit change https://git.eclipse.org/r/150203 was merged to [master].
> Commit:
> http://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/
> ?id=512c60182d2ecd4943eec96919606ab7de737c56

In master now.
Comment 14 Eric Williams CLA 2019-10-08 13:34:30 EDT
Verified in I20191008-0600.