]
Eric Williams resolved ERT-761.
-------------------------------
Resolution: Done
[GTK] Extra space to the right of ToolItems without text
[EBZ#543895]
---------------------------------------------------------------------
Key: ERT-761
URL:
https://issues.jboss.org/browse/ERT-761
Project: Eclipse Release Train
Issue Type: Task
Components: Platform
Reporter: Friendly Jira Robot
Assignee: Eric Williams
Priority: Major
Labels: SWT, bzira
Created attachment 277336
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();
}
}