Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Sluggish scrolling of Table widget with custom controls (GTK)(Table with a couple of hundred TableItems scrolls unresponsively on Linux)
icon5.gif  Sluggish scrolling of Table widget with custom controls (GTK) [message #539239] Thu, 10 June 2010 03:08 Go to next message
Albert Pikus is currently offline Albert Pikus
Messages: 70
Registered: October 2009
Member
Hi, everybody,

I have noticed that scrolling of Table widget with custom controls (e.g. check buttons) is very unresponsive on Linux. At first I thought that I made some mistake, but this behavior is easy to reproduce with the following snippet:

http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.swt.sni ppets/src/org/eclipse/swt/snippets/Snippet126.java?view=co

Just increase the number of table items to, say, 200 (in the original snippet there are only 12 TableItems), and scrolling performance degrades awfully.

This problem appears only on Linux; I was able to reproduce it on Ubuntu 10.04 LTS, with both 32- and 64-bit SWT). On Windows 7 and Mac OS X 10.6 there are no such problems (although it can be noticed, that custom controls on top of TableItems lag a little bit when Table is scrolled).

Any advise or hint how to solve this issue would be greatly appreciated.


Greetings from Slovenia,

Albert
Re: Sluggish scrolling of Table widget with custom controls (GTK) [message #539259 is a reply to message #539239] Thu, 10 June 2010 04:12 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas Schindl
Messages: 5296
Registered: July 2009
Senior Member
Hi,

Using Widgets inside a Table is IMHO a very bad idea you should think of
other solutions presented here.

http://wiki.eclipse.org/Tables_And_Trees_And_NativeControls
a solution for CheckBoxes is available at
http://wiki.eclipse.org/JFaceSnippets#Snippet061FakedNativeC ellEditor

Tom

Am 10.06.10 09:08, schrieb Albert:
> Hi, everybody,
>
> I have noticed that scrolling of Table widget with custom controls (e.g.
> check buttons) is very unresponsive on Linux. At first I thought that I
> made some mistake, but this behavior is easy to reproduce with the
> following snippet:
>
> http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.swt.sni ppets/src/org/eclipse/swt/snippets/Snippet126.java?view=co
>
>
> Just increase the number of table items to, say, 200 (in the original
> snippet there are only 12 TableItems), and scrolling performance
> degrades awfully.
>
> This problem appears only on Linux; I was able to reproduce it on Ubuntu
> 10.04 LTS, with both 32- and 64-bit SWT). On Windows 7 and Mac OS X 10.6
> there are no such problems (although it can be noticed, that custom
> controls on top of TableItems lag a little bit when Table is scrolled).
>
> Any advise or hint how to solve this issue would be greatly appreciated.
>
>
> Greetings from Slovenia,
>
> Albert
>
Re: Sluggish scrolling of Table widget with custom controls (GTK) [message #539512 is a reply to message #539259] Fri, 11 June 2010 03:09 Go to previous messageGo to next message
Albert Pikus is currently offline Albert Pikus
Messages: 70
Registered: October 2009
Member
Hi,

thank you for your reply and for the code you provided. I don't have any experience with JFace, my application uses SWT exclusively.

You must be right that using Widgets on top of TableItems is not such a good idea, so it seems that I'll have to dig into JFace if I want to achieve some decent user experience.


Kind regards,

Albert


Tom Schindl wrote on Thu, 10 June 2010 04:12
Hi,

Using Widgets inside a Table is IMHO a very bad idea you should think of
other solutions presented here.

http://wiki.eclipse.org/Tables_And_Trees_And_NativeControls
a solution for CheckBoxes is available at
http://wiki.eclipse.org/JFaceSnippets#Snippet061FakedNativeC ellEditor

Tom


[Updated on: Fri, 11 June 2010 03:12]

Report message to a moderator

Re: Sluggish scrolling of Table widget with custom controls (GTK) [message #539626 is a reply to message #539259] Fri, 11 June 2010 10:34 Go to previous messageGo to next message
Albert Pikus is currently offline Albert Pikus
Messages: 70
Registered: October 2009
Member
Hi, Tom,

I tested the snippet you provided with 1000 root items on Linux. When Table is scrolling, performance is good, but there seem to be other Linux-specific issues:

* checkboxes that should appear checked are not drawn at all at snippet startup - they appear only after the area where they are supposed to be drawn is clicked.

* another issue is not related to your snippet specifically, I'm experiencing this problem with SWT-only Table also; when checkbox is clicked, it is surrounded with ugly selection artifacts (a part of selection around the checkbox can be seen). My solution to this problem is more like a hack:

Button dummyButton = new Button(table, SWT.CHECK);
dummyButton.pack();
dummyButton.setVisible(false);
        
int editorMinimumWidth;

if (runningOnLinux())
{	
    editorMinimumWidth = dummyButton.getSize().x - 5;
}
else
{
    editorMinimumWidth = dummyButton.getSize().x;
}

// ... and later, when creating TableEditor:

TableEditor editor = new TableEditor(table);            
editor.minimumWidth = editorMinimumWidth;


This does the trick, but there is no guarantee that it will work with every possible DE for Linux.

This was tested on 32-bit Ubuntu 10.04 LTS with GTK 2.0 and Gnome 2.30.0.

Thanks again for your help, it is much appreciated.


Best regards,

Albert


Tom Schindl wrote on Thu, 10 June 2010 04:12
Hi,

Using Widgets inside a Table is IMHO a very bad idea you should think of
other solutions presented here.

http://wiki.eclipse.org/Tables_And_Trees_And_NativeControls
a solution for CheckBoxes is available at
http://wiki.eclipse.org/JFaceSnippets#Snippet061FakedNativeC ellEditor

Tom



Re: Sluggish scrolling of Table widget with custom controls (GTK) [message #539905 is a reply to message #539239] Mon, 14 June 2010 05:18 Go to previous messageGo to next message
Albert Pikus is currently offline Albert Pikus
Messages: 70
Registered: October 2009
Member
It's even worse: on Linux sometimes controls are displayed upon snippet startup, and sometimes not, randomly.

I'm attaching two screenshots, the first one displaying Table when controls are not drawn at snippet startup:

http://i49.tinypic.com/14o2c02.png


The second one showing check box displacement when check box (or cell hosting a check box) is clicked:

http://i48.tinypic.com/nzr5sl.png


Best regards,

Albert
Re: Sluggish scrolling of Table widget with custom controls (GTK) [message #540139 is a reply to message #539239] Tue, 15 June 2010 03:02 Go to previous messageGo to next message
Albert Pikus is currently offline Albert Pikus
Messages: 70
Registered: October 2009
Member
This behavior on Linux is really confusing; the whole problem is that checked-state screen shot sometimes just isn't captured right - instead of checkbox in checked state, only "helper" shell is captured, with default background.

As said before, this happens randomly, so it's really hard to fix anything...

Any ideas, why buttons aren't captured correctly every time?


Best regards,

Albert
Re: Sluggish scrolling of Table widget with custom controls (GTK) [message #540141 is a reply to message #540139] Tue, 15 June 2010 03:06 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas Schindl
Messages: 5296
Registered: July 2009
Senior Member
The only thing I can imaging is that this is a timing issue to when the
screenshot is take.

a) Given an improved version in
https://bugs.eclipse.org/bugs/show_bug.cgi?id=301705 a try
b) somehow way for some milliseconds to take the screenshot to see if
the problem is going a way

What's your version of SWT?

Tom

Am 15.06.10 09:02, schrieb Albert:
> This behavior on Linux is really confusing; the whole problem is that
> checked-state screen shot sometimes just isn't captured right - instead
> of checkbox in checked state, only "helper" shell is captured, with
> default background.
>
> As said before, this happens randomly, so it's really hard to fix
> anything...
> Any ideas, why buttons aren't captured correctly every time?
>
>
> Best regards,
>
> Albert
>
Re: Sluggish scrolling of Table widget with custom controls (GTK) [message #540145 is a reply to message #540141] Tue, 15 June 2010 03:42 Go to previous messageGo to next message
Albert Pikus is currently offline Albert Pikus
Messages: 70
Registered: October 2009
Member
Hi,

I thought of this too, so I tried the following:


if (JFaceResources.getImageRegistry().getDescriptor(CHECKED_KEY) == null)
{
    JFaceResources.getImageRegistry().put(UNCHECK_KEY, makeShot(viewer.getControl(), false));
                
    try
    {
       Thread.sleep(100);					
    }
    catch (InterruptedException e)
    {					
        e.printStackTrace();
    }
                
    JFaceResources.getImageRegistry().put(CHECKED_KEY, makeShot(viewer.getControl(), true));
}



But this sleep seems not to be helpful, no matter what (still reasonable) sleep interval I set. But if i create "helper" shell with the following style bits, button's checked state seems to be captured correctly (at least I haven't yet managed to get wrong checked-state button screenshot):

Shell shell = new Shell(control.getShell(), SWT.NO_TRIM | SWT.APPLICATION_MODAL | SWT.ON_TOP);


There is also another problem: when clicking on the checkbox image (not just inside the cell where this image is hosted, but precisely on the image), element's state inside the method

protected void setValue(Object element, Object value)
{
    ((File) element).read = ((Boolean) value).booleanValue();
    v.update(element, null);
}


just isn't updated. When clicking inside a cell, but outside the checkbox image, method setValue updates element correctly.

EDIT: I'm using 32-bit SWT 3.5.2 for gtk-linux.

I'll take a look at improved version you provided, thank you.

Best regards,

Albert


Quote:

The only thing I can imaging is that this is a timing issue to when the
screenshot is take.

a) Given an improved version in
https://bugs.eclipse.org/bugs/show_bug.cgi?id=301705 a try
b) somehow way for some milliseconds to take the screenshot to see if
the problem is going a way

What's your version of SWT?

Tom


[Updated on: Tue, 15 June 2010 03:52]

Report message to a moderator

Re: Sluggish scrolling of Table widget with custom controls (GTK) [message #540160 is a reply to message #539239] Tue, 15 June 2010 04:24 Go to previous messageGo to next message
Albert Pikus is currently offline Albert Pikus
Messages: 70
Registered: October 2009
Member
I've read through posts on Eclipse Bugzilla and I don't know if I should try this patch at all, because there seem to be problems with it on Mac OS X and Windows XP. This is not acceptable for me, since my application has to work on all OSes. I seem to be stuck here, there is just no proper solution to this issue.


Best regards,

Albert
Re: Sluggish scrolling of Table widget with custom controls (GTK) [message #540161 is a reply to message #540145] Tue, 15 June 2010 04:01 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas Schindl
Messages: 5296
Registered: July 2009
Senior Member
You are stopping the display thread which won't help.

Tom

Am 15.06.10 09:42, schrieb Albert:
> Hi,
>
> I thought of this too, so I tried the following:
>
>
>
> if (JFaceResources.getImageRegistry().getDescriptor(CHECKED_KEY ) == null)
> {
> JFaceResources.getImageRegistry().put(UNCHECK_KEY,
> makeShot(viewer.getControl(), false));
> try
> {
> Thread.sleep(100);
> }
> catch (InterruptedException e)
> {
> e.printStackTrace();
> }
> JFaceResources.getImageRegistry().put(CHECKED_KEY,
> makeShot(viewer.getControl(), true));
> }
>
>
>
> But this sleep seems not to be helpful, no matter what (still
> reasonable) sleep interval I set. But if i create "helper" shell with
> the following style bits, captured state seems to be captured correctly
> (at least I haven't yet managed to get wrong checked-state button
> screenshot):
>
>
> Shell shell = new Shell(control.getShell(), SWT.NO_TRIM |
> SWT.APPLICATION_MODAL | SWT.ON_TOP);
>
>
> There are also other problems: when clicking on the checkbox image (not
> just inside the cell where this image is hosted, but precisely on the
> image), element's state inside the method
>
>
> protected void setValue(Object element, Object value)
> {
> ((File) element).read = ((Boolean) value).booleanValue();
> v.update(element, null);
> }
>
>
> just isn't updated. When clicking inside a cell, but outside the
> checkbox image, method setValue updates element correctly.
>
> I'll take a look at improved version you provided, thank you.
>
>
> Best regards,
>
> Albert
>
> Quote:
>> The only thing I can imaging is that this is a timing issue to when the
>> screenshot is take.
>>
>> a) Given an improved version in
>> https://bugs.eclipse.org/bugs/show_bug.cgi?id=301705 a try
>> b) somehow way for some milliseconds to take the screenshot to see if
>> the problem is going a way
>>
>> What's your version of SWT?
>>
>> Tom
>
>
Re: Sluggish scrolling of Table widget with custom controls (GTK) [message #540167 is a reply to message #540161] Tue, 15 June 2010 04:41 Go to previous messageGo to next message
Albert Pikus is currently offline Albert Pikus
Messages: 70
Registered: October 2009
Member
You are right, this cannot work. However, as mentioned above, creating helper Shell with
Shell shell = new Shell(control.getShell(), SWT.NO_TRIM | SWT.APPLICATION_MODAL | SWT.ON_TOP);

works.


Best regards,

Albert


Tom Schindl wrote on Tue, 15 June 2010 04:01
You are stopping the display thread which won't help.

Tom

Am 15.06.10 09:42, schrieb Albert:
> Hi,
>
> I thought of this too, so I tried the following:
>
>
>
> if (JFaceResources.getImageRegistry().getDescriptor(CHECKED_KEY ) == null)
> {
> JFaceResources.getImageRegistry().put(UNCHECK_KEY,
> makeShot(viewer.getControl(), false));
> try
> {
> Thread.sleep(100);
> }
> catch (InterruptedException e)
> {
> e.printStackTrace();
> }
> JFaceResources.getImageRegistry().put(CHECKED_KEY,
> makeShot(viewer.getControl(), true));
> }
>
>
>
> But this sleep seems not to be helpful, no matter what (still
> reasonable) sleep interval I set. But if i create "helper" shell with
> the following style bits, captured state seems to be captured correctly
> (at least I haven't yet managed to get wrong checked-state button
> screenshot):
>
>
> Shell shell = new Shell(control.getShell(), SWT.NO_TRIM |
> SWT.APPLICATION_MODAL | SWT.ON_TOP);
>
>
> There are also other problems: when clicking on the checkbox image (not
> just inside the cell where this image is hosted, but precisely on the
> image), element's state inside the method
>
>
> protected void setValue(Object element, Object value)
> {
> ((File) element).read = ((Boolean) value).booleanValue();
> v.update(element, null);
> }
>
>
> just isn't updated. When clicking inside a cell, but outside the
> checkbox image, method setValue updates element correctly.
>
> I'll take a look at improved version you provided, thank you.
>
>
> Best regards,
>
> Albert
>
> Quote:
>> The only thing I can imaging is that this is a timing issue to when the
>> screenshot is take.
>>
>> a) Given an improved version in
>> https://bugs.eclipse.org/bugs/show_bug.cgi?id=301705 a try
>> b) somehow way for some milliseconds to take the screenshot to see if
>> the problem is going a way
>>
>> What's your version of SWT?
>>
>> Tom
>
>

Re: Sluggish scrolling of Table widget with custom controls (GTK) [message #541082 is a reply to message #540167] Fri, 18 June 2010 05:31 Go to previous message
Albert Pikus is currently offline Albert Pikus
Messages: 70
Registered: October 2009
Member
Perhaps I would be able to fix appearance on Linux, when table item is selected (i.e. find a way to hide selection edges around the button image, as can be seen from the above attached screenshots), but I have no idea how to capture selection event and accordingly update element's state (for example, set File's read property to true or false) when image of a button is clicked. I cannot expect from a user to know that clicking on a button image actually does nothing (except for just swapping button image).

Any ideas, anyone?


Greetings,

Albert
Previous Topic:creating image from text
Next Topic:Galileo Internal Web Browser
Goto Forum:
  


Current Time: Sat Aug 30 08:30:26 EDT 2014

Powered by FUDForum. Page generated in 0.02797 seconds