Bug 577055 - [Mac aarch64] Text is clipped in Tree
Summary: [Mac aarch64] Text is clipped in Tree
Status: VERIFIED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 4.22   Edit
Hardware: Macintosh Mac OS X
: P3 normal (vote)
Target Milestone: 4.22 M3   Edit
Assignee: Niraj Modi CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 572797
  Show dependency tree
 
Reported: 2021-11-04 04:50 EDT by Phil Beauvoir CLA
Modified: 2022-03-21 10:14 EDT (History)
3 users (show)

See Also:


Attachments
Screen shot of Snippet 15 (57.70 KB, image/png)
2021-11-04 04:51 EDT, Phil Beauvoir CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Phil Beauvoir CLA 2021-11-04 04:50:59 EDT
With the new patch from Bug #574932 in 4.22 the problem of extra spacing/padding has been solved. However, now text in a Tree is clipped. The item with the longest text is clipped.

See https://bugs.eclipse.org/bugs/show_bug.cgi?id=574932#c24

To test, just run Snippet 15 (https://git.eclipse.org/c/platform/eclipse.platform.swt.git/tree/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet15.java)
Comment 1 Phil Beauvoir CLA 2021-11-04 04:51:45 EDT
Created attachment 287443 [details]
Screen shot of Snippet 15

Screen shot
Comment 2 Niraj Modi CLA 2021-11-08 05:37:20 EST
Recall fixing similar issue on Windows, please see bug 561469
Try increasing the rectangle.right/width in TreeItem#getTextBounds() method on MAC
Comment 3 Phil Beauvoir CLA 2021-11-08 10:00:29 EST
(In reply to Niraj Modi from comment #2)
> Recall fixing similar issue on Windows, please see bug 561469
> Try increasing the rectangle.right/width in TreeItem#getTextBounds() method
> on MAC

I experimented with adjusting TreeItem#getTextBounds() but it doesn't get called when using a TreeViewer.

What did make a difference was increasing the NSSize "size" variable in TreeItem#calculateWidth():

	NSSize size = new NSSize();
	OS.objc_msgSendSuper_stret(size, super_struct, OS.sel_cellSize);
	if (image != null) size.width += parent.imageBounds.width + Tree.IMAGE_GAP;
//	cell.setImage (image != null ? image.handle : null);
//	NSSize size = cell.cellSize ();

	size.width += 5;  <---- HERE

Note - this was just an experiment to narrow down the problem. I don't know what additional width should be calculated.
Comment 4 Niraj Modi CLA 2021-11-09 01:11:34 EST
(In reply to Phil Beauvoir from comment #3)
> (In reply to Niraj Modi from comment #2)
> > Recall fixing similar issue on Windows, please see bug 561469
> > Try increasing the rectangle.right/width in TreeItem#getTextBounds() method
> > on MAC
> 
> I experimented with adjusting TreeItem#getTextBounds() but it doesn't get
> called when using a TreeViewer.
> 
> What did make a difference was increasing the NSSize "size" variable in
> TreeItem#calculateWidth():
> 
> 	NSSize size = new NSSize();
> 	OS.objc_msgSendSuper_stret(size, super_struct, OS.sel_cellSize);
> 	if (image != null) size.width += parent.imageBounds.width + Tree.IMAGE_GAP;
> //	cell.setImage (image != null ? image.handle : null);
> //	NSSize size = cell.cellSize ();
> 
> 	size.width += 5;  <---- HERE
> 
> Note - this was just an experiment to narrow down the problem. I don't know
> what additional width should be calculated.

Thanks Phil, was wondering if we really need 5px additional margin, on windows I could fix with 1px margin.

I don't have a MAC handy, so was checking if any of below works:
size.width += Tree.TEXT_GAP;                 <-- 2px HERE
size.width += Tree.TEXT_GAP + Tree.CELL_GAP; <-- 3px HERE

Something to experiment with:
We can also consider increasing any of these existing constant values(if not side effects seen)
Comment 5 Eclipse Genie CLA 2021-11-09 03:20:32 EST
New Gerrit change created: https://git.eclipse.org/r/c/platform/eclipse.platform.swt/+/187535
Comment 6 Phil Beauvoir CLA 2021-11-09 04:06:12 EST
Hi Niraj, I just checked your Gerrrit change on Big Sur 11.6.1 aarch64 and Tree.TEXT_GAP seems to be just the right amount needed. Thanks.

The OS check in the patch is:

if (OS.isBigSurOrLater())

As this bug doesn't affect Mac x86_64 (I tested on Monterey x86_64) is it better to check architecture as well?

Also, the extra width is applied to all TreeItems when it really is only the widest TreeItem affected.
Comment 8 Niraj Modi CLA 2021-11-09 05:06:47 EST
(In reply to Eclipse Genie from comment #7)
> Gerrit change
> https://git.eclipse.org/r/c/platform/eclipse.platform.swt/+/187535 was
> merged to [master].
> Commit:
> http://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/
> ?id=d315328f45bcc24483fe173ac87777ca8e5c9d23

We tested the patch on MAC M1 and it looks good in Eclipse/SWT, resolving now.

(In reply to Phil Beauvoir from comment #6)
> Hi Niraj, I just checked your Gerrrit change on Big Sur 11.6.1 aarch64 and
> Tree.TEXT_GAP seems to be just the right amount needed. Thanks.
> 
> The OS check in the patch is:
> 
> if (OS.isBigSurOrLater())
> 
> As this bug doesn't affect Mac x86_64 (I tested on Monterey x86_64) is it
> better to check architecture as well?
IMO, not required as we fixed bug 568383: this looks a BigSur issue and not specific to aarch64, it was fixed by changing the truncation style.

> Also, the extra width is applied to all TreeItems when it really is only the
> widest TreeItem affected.

It's not a problem as size itself return from native is not enough.
In Tree#calculateWidth() -- see we already return the width of the largest item only.
Also longest item(s) can change(can be deleted)
Comment 9 Phil Beauvoir CLA 2021-11-09 05:09:17 EST
(In reply to Niraj Modi from comment #8)
> IMO, not required as we fixed bug 568383: this looks a BigSur issue and not
> specific to aarch64, it was fixed by changing the truncation style.

I tested on x86_64 and the truncation does not occur.
Comment 10 Niraj Modi CLA 2021-11-09 07:12:12 EST
(In reply to Phil Beauvoir from comment #9)
> (In reply to Niraj Modi from comment #8)
> > IMO, not required as we fixed bug 568383: this looks a BigSur issue and not
> > specific to aarch64, it was fixed by changing the truncation style.
> 
> I tested on x86_64 and the truncation does not occur.

Ok, I propose to add check for x86_64 to avoid additional padding.
Will share a gerrit shortly.
Comment 11 Eclipse Genie CLA 2021-11-09 07:14:27 EST
New Gerrit change created: https://git.eclipse.org/r/c/platform/eclipse.platform.swt/+/187540
Comment 13 Phil Beauvoir CLA 2021-11-10 03:25:37 EST
Thanks, Niraj.
Comment 14 Niraj Modi CLA 2021-11-11 08:01:09 EST
@Phil: Could you please verify the fix with latest Eclipse I-Build:
https://download.eclipse.org/eclipse/downloads/drops4/I20211110-1800 ? Thanks!
Comment 15 Phil Beauvoir CLA 2021-11-11 08:31:27 EST
(In reply to Niraj Modi from comment #14)
> @Phil: Could you please verify the fix with latest Eclipse I-Build:
> https://download.eclipse.org/eclipse/downloads/drops4/I20211110-1800 ?
> Thanks!

Confirmed fixed in I20211110-1800.

Thanks, Niraj!
Comment 16 Lakshmi P Shanmugam CLA 2022-03-21 10:14:45 EDT
Thanks Niraj, for fixing this!