Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 399551 - [GTK3] Texts not sizing properly
Summary: [GTK3] Texts not sizing properly
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 4.3   Edit
Hardware: PC Linux-GTK
: P3 normal (vote)
Target Milestone: 4.3 M6   Edit
Assignee: Platform-SWT-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 340067
  Show dependency tree
 
Reported: 2013-01-30 15:20 EST by Grant Gayed CLA
Modified: 2013-05-24 09:10 EDT (History)
2 users (show)

See Also:


Attachments
screenshot (49.60 KB, image/jpeg)
2013-01-30 15:20 EST, Grant Gayed CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Grant Gayed CLA 2013-01-30 15:20:59 EST
Created attachment 226341 [details]
screenshot

- 4.3RC5 test build, observed on Ubuntu 12.04LTS

- screenshot is attached
Comment 1 Grant Gayed CLA 2013-01-30 15:30:59 EST
Possibly a duplicate of bug 394583.
Comment 2 Anatoly Spektor CLA 2013-01-31 15:10:16 EST
Works in Fedora 18 64bit. Attaching screenshot:

http://oi47.tinypic.com/2hp10td.jpg
Comment 3 Anatoly Spektor CLA 2013-02-07 14:27:58 EST
(In reply to comment #0)
> Created attachment 226341 [details]
> screenshot
> 
> - 4.3RC5 test build, observed on Ubuntu 12.04LTS
> 
> - screenshot is attached

Hello Grant,

I was able to reproduce this problem on Fedora 18 with 64 bit using this snippet:
--------------------------------------------------------------------
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.*;
import org.eclipse.swt.widgets.*;

public class textbox_clipped {
  public static void main(String[] args) {
    Display display = new Display();
    Shell shell = new Shell(display);
    shell.setLayout(new GridLayout(1, false));
    
    
    new Text(shell, SWT.READ_ONLY | SWT.BORDER).setText("TextBox is Clipped"); // This Textbox is Clipped
    new Text(shell, SWT.READ_ONLY | SWT.BORDER); // This Textbox in GTK3 is much wider than in GTK2
    
    
    shell.open();
    while (!shell.isDisposed()) {
      if (!display.readAndDispatch()) {
        display.sleep();
      }
    }
    display.dispose();
  }
}

-----------------------------------------------------------

If you run it in GTK2 and GTK3 you will see that the first Text field is clipped to the right, and second Text field appear to be much wider in GTK3 than in GTK2.

 I think that both problems are connected, as Text.computeTrim() trims the same amount in both GTK2 and GTK3, its just the width that is bigger, and creates this "clipping" effect.

I have tried several things, but neither of them gave me the right result. I think (not sure) that the  cause of the problem is in different size calculations of GtkEntry in GTK2 and GTK3, thus by default GtkEntry in GTK3 is wider than in GTK2.


I hope this will help!


Regards,

Anatoly
Comment 4 Anatoly Spektor CLA 2013-02-07 15:42:59 EST
(In reply to comment #3)
> (In reply to comment #0)
> > Created attachment 226341 [details]
> > screenshot
> > 
> > - 4.3RC5 test build, observed on Ubuntu 12.04LTS
> > 
> > - screenshot is attached
> 
> Hello Grant,
> 
> I was able to reproduce this problem on Fedora 18 with 64 bit using this
> snippet:
> --------------------------------------------------------------------
> import org.eclipse.swt.SWT;
> import org.eclipse.swt.layout.*;
> import org.eclipse.swt.widgets.*;
> 
> public class textbox_clipped {
>   public static void main(String[] args) {
>     Display display = new Display();
>     Shell shell = new Shell(display);
>     shell.setLayout(new GridLayout(1, false));
>     
>     
>     new Text(shell, SWT.READ_ONLY | SWT.BORDER).setText("TextBox is
> Clipped"); // This Textbox is Clipped
>     new Text(shell, SWT.READ_ONLY | SWT.BORDER); // This Textbox in GTK3 is
> much wider than in GTK2
>     
>     
>     shell.open();
>     while (!shell.isDisposed()) {
>       if (!display.readAndDispatch()) {
>         display.sleep();
>       }
>     }
>     display.dispose();
>   }
> }
> 
> -----------------------------------------------------------
> 
> If you run it in GTK2 and GTK3 you will see that the first Text field is
> clipped to the right, and second Text field appear to be much wider in GTK3
> than in GTK2.
> 
>  I think that both problems are connected, as Text.computeTrim() trims the
> same amount in both GTK2 and GTK3, its just the width that is bigger, and
> creates this "clipping" effect.
> 
> I have tried several things, but neither of them gave me the right result. I
> think (not sure) that the  cause of the problem is in different size
> calculations of GtkEntry in GTK2 and GTK3, thus by default GtkEntry in GTK3
> is wider than in GTK2.
> 
> 
> I hope this will help!
> 
> 
> Regards,
> 
> Anatoly

I have got it working!

 I was right that the problem was in default sizing of GtkEntry, also there was minor issue with GtkRequisition. Please try this patch and tell me if it works for you:

http://fedorapeople.org/cgit/aspektor/public_git/eclipse.platform.swt.git/commit/?h=gtk3_textbox_clipped

Thanks, 

Anatoly
Comment 5 Grant Gayed CLA 2013-02-07 16:22:15 EST
I haven't tried it yet, but looking at the patch, why 6 chars?
Comment 6 Anatoly Spektor CLA 2013-02-07 16:58:45 EST
(In reply to comment #5)
> I haven't tried it yet, but looking at the patch, why 6 chars?

Good question, by default GTK3 makes Text too wide, so I need to set default Gtk3 Textbox smaller than it is. If I set it to 1, it is much smaller than the default GTK2 one, so I decided to make it look the same. 

If you open GTK2 and GTK3 snippet that I have provided together you will see that they look similar. I tried different char_width and the one I have chosen looks most appropriate to my mind.

Here is the screenshot:

http://oi47.tinypic.com/2ep4wvq.jpg ( GTk2 textboxes and Gtk3 textboxes)
Comment 7 Alexander Kurtakov CLA 2013-02-21 14:18:56 EST
I plan on pushing this one as it seems to improve the situation although not the best solution obviously.
Comment 8 Alexander Kurtakov CLA 2013-02-21 15:49:06 EST
Slightly modified patch(set width_chars only for SWT.SINGLE) pushed as this is clear improvement over the current state.