Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 338346 - Items not always re-rendered correctly upon scroll
Summary: Items not always re-rendered correctly upon scroll
Status: CLOSED INVALID
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Nebula (show other bugs)
Version: unspecified   Edit
Hardware: PC All
: P3 major (vote)
Target Milestone: ---   Edit
Assignee: Nicolas Richeton CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-02-27 13:20 EST by Nils Lorentzen CLA
Modified: 2021-07-05 11:39 EDT (History)
1 user (show)

See Also:


Attachments
Test application to reproduce (5.40 KB, text/x-java)
2011-02-27 13:21 EST, Nils Lorentzen CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Nils Lorentzen CLA 2011-02-27 13:20:20 EST
Build Identifier: SWT x86-3.6.1.v3665c

Issue occurs when using DefaultGalleryGroupRenderer and a line of items is scrolled so that the upper or lower edge is at or just outside upper/lower edge of widget area.

Then scroll in the direction where the item edge is close to clientarea, eg. up.
The item is moved down bu the very top of the item is not redrawn probably.

The error lies somewhere in interaction with AbstractGridGroupRenderer.getVisibleItems() called from DefaultGalleryGroupRenderer.draw().

When computing first and last item in clip area, getVisibleItems() subtracts minMargin between group header and first item like so:

int lastLine = (clipY - y - offset + clipHeight - minMargin) / (itemHeight + minMargin);

However, "offset" above has been already accounted for on the ouside through 

DefaultGalleryGroupRenderer.getGroupOffset()

protected int getGroupOffset(GalleryItem item) {
  if (item.getParentItem() != null) {
    return 0;
  }

  return getGroupHeight(item) + minMargin;
}

So minMargin between group header and first line is counted twice and this messes up redrawing when an item is at the edge.

One will probably not notice this when showing plain images but I had custom paint listener that rendered a border around images.

Fix for this case seems to be to do 

int[] indexes = getVisibleItems(group, x, y, clipX, clipY,
               clipWidth, clipHeight, groupOffset - minMargin);

in DefaultGalleryGroupRenderer.draw().

BUT I am not sure whether it should really be fixed in getVisibleItems() instead.

That could in turn break NoGroupRenderer and 3rdparty subclasses of AbstractGridGroupRenderer. I am not trying to make a generic fix since I'm not sure whether first margin is supposed to be part of group offset or not.



Reproducible: Sometimes

Steps to Reproduce:
1.In attached app, scroll an stop up or down, or use arrows
2.Look for items not properly redrawn when scrolled out
3. Might take a few attempts since it occurs only when items overlap a few pixels with clientarea edge.
Comment 1 Nils Lorentzen CLA 2011-02-27 13:21:46 EST
Created attachment 189897 [details]
Test application to reproduce
Comment 2 Wim Jongman CLA 2019-12-12 15:58:51 EST
This bug does not have a target milestone assigned and is automatically closed as part of the 2.3.0 release cleanup.

It could be that this bug is accidentally closed for which we apologize.

If this bug is still relevant, please re-open and set a target milestone.