Community
Participate
Working Groups
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)
Created attachment 287443 [details] Screen shot of Snippet 15 Screen shot
Recall fixing similar issue on Windows, please see bug 561469 Try increasing the rectangle.right/width in TreeItem#getTextBounds() method on MAC
(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.
(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)
New Gerrit change created: https://git.eclipse.org/r/c/platform/eclipse.platform.swt/+/187535
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.
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
(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)
(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.
(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.
New Gerrit change created: https://git.eclipse.org/r/c/platform/eclipse.platform.swt/+/187540
Gerrit change https://git.eclipse.org/r/c/platform/eclipse.platform.swt/+/187540 was merged to [master]. Commit: http://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/?id=0e67434ae15877bd0853a47e92ba969bfe56f507
Thanks, Niraj.
@Phil: Could you please verify the fix with latest Eclipse I-Build: https://download.eclipse.org/eclipse/downloads/drops4/I20211110-1800 ? Thanks!
(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!
Thanks Niraj, for fixing this!