Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 151322 - Link rendering in GTK2 w/ RowLayout gets cut off..
Summary: Link rendering in GTK2 w/ RowLayout gets cut off..
Status: RESOLVED NOT_ECLIPSE
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 3.2   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Felipe Heidrich CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 244499 (view as bug list)
Depends on:
Blocks:
 
Reported: 2006-07-20 15:52 EDT by Marshall Culpepper CLA
Modified: 2013-07-15 04:25 EDT (History)
7 users (show)

See Also:


Attachments
screenshot showing the truncation of the link text (188.68 KB, image/png)
2009-04-02 17:26 EDT, Scott Ellis CLA
no flags Details
c example (1.48 KB, text/plain)
2009-04-03 15:44 EDT, Felipe Heidrich CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Marshall Culpepper CLA 2006-07-20 15:52:23 EDT
I have a fairly simple use case.. I'm using a composite with a RowLayout and putting a label and a link inside that layout. Here is the offending code:

noPackagesComposite = new Composite(pageBook, SWT.NONE);
noPackagesComposite.setLayout(new RowLayout(SWT.HORIZONTAL));

new Label(noPackagesComposite, SWT.NONE).setText(PackagesUIMessages.ProjectPackagesView_noPackagesDefinedMessage);
Link createPackageLink = new Link(noPackagesComposite, SWT.NONE);

Viewing this in GTK2 causes the link to be cut off and only show part of the text. The link should say "Create a Package".

Here is the win32 (correct) rendering:
http://www.arcaner.com/pictures/screenshots/link_in_rowlayout_win32.png

And here is the gtk2 (incorrect) rendering:
http://www.arcaner.com/pictures/screenshots/link_in_rowlayout_gtk2.png

Resizing/moving/re-initializing my view does nothing for making this "snip" go away.

My initial guess is somehow the link widget is being cutoff by the RowLayout implementation, but I'm just stabbing in the dark.
Comment 1 Steve Northover CLA 2006-08-03 13:02:40 EDT
It might be a bug in Link, RowLayout or computeSize().  In any case, we'll need a stand alone snippet that shows the problem or a set of steps in Eclipse.
Comment 2 Felipe Heidrich CLA 2008-01-11 17:31:56 EST
Works for me.
Please modify the snippet so that is reproduces the bug.
import org.eclipse.swt.*;
import org.eclipse.swt.layout.*;
import org.eclipse.swt.widgets.*;

public class PR151322 {
  public static void main(String[] args) {
    Display display = new Display();
    Shell shell = new Shell(display);
    shell.setLayout(new FillLayout());
    Composite noPackagesComposite = new Composite(shell, SWT.NONE);
    noPackagesComposite.setLayout(new RowLayout(SWT.HORIZONTAL));
    Label label = new Label(noPackagesComposite, SWT.NONE);
    label.setText("No packages have been defined for this project");
    Link createPackageLink = new Link(noPackagesComposite, SWT.NONE);
    createPackageLink.setText("<a>Create a package</a>"); 
    shell.setBounds(200, 200, 300, 200);
    shell.open();
    while (!shell.isDisposed()) {
      if (!display.readAndDispatch()) display.sleep();
    }
    display.dispose();
  }
}


---------------------
Reopen this problem if you still have the problem.

Comment 3 Scott Ellis CLA 2009-04-02 16:30:30 EDT
I can repro this bug by changing the text of the link to "Watch videos"

When I do then the word "videos" gets dropped completely and does not appear in the link.




import org.eclipse.swt.*;
import org.eclipse.swt.layout.*;
import org.eclipse.swt.widgets.*;

public class PR151322 {
  public static void main(String[] args) {
    Display display = new Display();
    Shell shell = new Shell(display);
    shell.setLayout(new FillLayout());
    Composite noPackagesComposite = new Composite(shell, SWT.NONE);
    noPackagesComposite.setLayout(new RowLayout(SWT.HORIZONTAL));
    Label label = new Label(noPackagesComposite, SWT.NONE);
    label.setText("No packages have been defined for this project");
    Link createPackageLink = new Link(noPackagesComposite, SWT.NONE);
    createPackageLink.setText("<a>Watch videos</a>"); 
    shell.setBounds(200, 200, 300, 200);
    shell.open();
    while (!shell.isDisposed()) {
      if (!display.readAndDispatch()) display.sleep();
    }
    display.dispose();
  }
}
Comment 4 Scott Ellis CLA 2009-04-02 16:31:54 EDT
Note I don't think it has anything to do with RowLayout because I am struggling with the same issue using GridLayout
Comment 5 Scott Ellis CLA 2009-04-02 16:46:20 EDT
Note also: If I change the link text to "watch videos" with a lower case "w" then the link is rendered correctly with no truncation so that make me think there is a probably a bug in computing the size of variable width upper/lower case characters.

Can someone please reopen this?
Thanks
Comment 6 Steve Northover CLA 2009-04-02 16:57:58 EDT
Felipe, can you confirmt that changing the text shows the bug?  If so, please reopen.

Scott, don't worry about reopening a bug if you are seeing a problem.  The only time reopening a bug is an issue would be if we got into some sort of revert war.
Comment 7 Steve Northover CLA 2009-04-02 16:58:19 EDT
... and I reopened it.
Comment 8 Scott Ellis CLA 2009-04-02 17:06:18 EDT
For other folks having this issue I was able to workaround it for now by adding some whitespace to the end of the string before calling Link.setText()
Comment 9 Felipe Heidrich CLA 2009-04-02 17:09:03 EDT
Works for me (SWT=HEAD, Linux=Fedora Core 10)


Can you attach a screenshot of the problem ?
Comment 10 Scott Ellis CLA 2009-04-02 17:16:07 EDT
I am on RH EL5 x86_64

gtk2-2.10.4-16.el5
Comment 11 Scott Ellis CLA 2009-04-02 17:26:04 EDT
Created attachment 130770 [details]
screenshot showing the truncation of the link text
Comment 12 Scott Ellis CLA 2009-04-02 17:34:54 EDT
Strangely, when I use the link text of the original submitter ("Create a Package") the link rendering works fine with no truncation (i.e. I do not see the link truncation that the original submitter did).

For me:

"Watch videos" gets truncated

"watch videos" does not

Vary strange...
Comment 13 Scott Ellis CLA 2009-04-02 18:13:58 EDT
Note: https://bugs.eclipse.org/bugs/show_bug.cgi?id=244499 is probably a dupe of this one
Comment 14 Felipe Heidrich CLA 2009-04-03 11:04:28 EDT
*** Bug 244499 has been marked as a duplicate of this bug. ***
Comment 15 Felipe Heidrich CLA 2009-04-03 15:40:14 EDT
I can see this problem on RH EL5 (64 and 32 bits).

This is rounding problem deep down in pango. I have c example that has the same problem.

The same works on my Fedora 10, I believe this has being fixed in newer version of gtk/pango.

The string that fails on RH EL5 has different size on fedora, so the testing is not 100% the same. But I tested with many different inputs for text and font, and the problem didn't happen at all on fedora 10 and ubuntu 8.4.



Comment 16 Felipe Heidrich CLA 2009-04-03 15:44:49 EDT
Created attachment 130878 [details]
c example

This example shows that the problem can happen to a simple gtk app.
Feel free to use this example to report a bug against gtk. But again, I believe this is fixed already.
Comment 17 Felipe Heidrich CLA 2009-04-03 15:45:50 EDT
closing not eclipse.
Comment 18 Markus Keller CLA 2013-07-11 10:56:10 EDT
See bug 393602 for follow-ups.