Skip to content

Commit

Permalink
Bug 340225 - tooltip shows a lot of blank space
Browse files Browse the repository at this point in the history
Change-Id: I60c7aaf1c75766d85519e78ea2a7a51cefa0843c
Signed-off-by: Philippe NOEL <philippe.noel@st.com>
  • Loading branch information
PhilippeNoel committed Sep 15, 2017
1 parent d96da04 commit e924f41
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import org.eclipse.swt.graphics.FontData;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Label;

Expand Down Expand Up @@ -58,8 +59,15 @@ protected Composite createToolTipArea(Event event, Composite parent) {
}

private void createDescription(Composite parent) {
// Compute width hint for description label
// width hint = icon width + label width + margin between them
Control icon = parent.getChildren()[0];
int iconWidth = icon.computeSize(SWT.DEFAULT, SWT.DEFAULT).x;
Control label = parent.getChildren()[1];
int labelWidth = label.computeSize(SWT.DEFAULT, SWT.DEFAULT).x;
int wHint = iconWidth + 5 + labelWidth;
Label descriptionLabel = new Label(parent, SWT.WRAP);
GridDataFactory.fillDefaults().grab(true, false).span(2, 1).hint(100, SWT.DEFAULT).applyTo(descriptionLabel);
GridDataFactory.fillDefaults().grab(true, false).span(2, 1).hint(wHint, SWT.DEFAULT).applyTo(descriptionLabel);
descriptionLabel.setBackground(null);
String description = catalogDescriptor.getDescription() == null ? "" : TextUtil.escapeText(catalogDescriptor.getDescription()); //$NON-NLS-1$
descriptionLabel.setText(description);
Expand Down

0 comments on commit e924f41

Please sign in to comment.