Re: NSTableColumn width computation doesn't work correctly on macOS 11

2021-06-25 Thread Rob Petrovec via Cocoa-dev


> On Jun 25, 2021, at 2:40 PM, Andreas Falkenhahn via Cocoa-dev 
>  wrote:
> 
> On 25.06.2021 at 18:54 Carl Hoefs wrote:
> 
>> So I think it's safe to say that something has changed, and you're not 
>> fighting fantoms...
> 
> Do you think this should be reported to Apple or will nobody care because I'm 
> using deprecated APIs?
It wouldn’t hurt, but I doubt it will get much attention. if any, other 
than a reply saying to switch to non-deprecated API.

—Rob


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: NSTableColumn width computation doesn't work correctly on macOS 11

2021-06-25 Thread Andreas Falkenhahn via Cocoa-dev
On 25.06.2021 at 18:54 Carl Hoefs wrote:

> So I think it's safe to say that something has changed, and you're not 
> fighting fantoms...

Do you think this should be reported to Apple or will nobody care because I'm 
using deprecated APIs?

-- 
Best regards,
 Andreas Falkenhahnmailto:andr...@falkenhahn.com

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: NSTableColumn width computation doesn't work correctly on macOS 11

2021-06-25 Thread Rob Petrovec via Cocoa-dev
You are using deprecated cell based table views/API. I would advise switching 
to view based API (available in macOS 10.7 and newer).  Cell based was 
deprecated in 10.10 back in 2014.

With that said, I would create an NSTextFieldCell subclass (if you haven’t 
already) and stuff it into the text field for the row being truncated.  Then 
override:
- (NSSize)cellSizeForBounds:(NSRect)rect;
- (NSRect)imageRectForBounds:(NSRect)rect;
- (NSRect)titleRectForBounds:(NSRect)rect;

and see what they return on 10.13 & 11. -cellSize calls -cellSizeForBounds: 
which calls the other two methods to calculate the ideal size of the text field 
(including measuring width of the text).  Maybe that will give you some 
insight.  Good luck.

—Rob


> On Jun 25, 2021, at 8:22 AM, Andreas Falkenhahn via Cocoa-dev 
>  wrote:
> 
> I'm manually calculating the minimum size of my NSTableColumn to avoid text 
> ellipsization. The calculation looks like this:
> 
>   NSCell *cell = [m_view preparedCellAtColumn:m_column row:row];
> 
>   int width = ceil([cell cellSize].width);
> 
>   if(m_column == [m_view outlineTableColumn]) {
>  width += [m_view indentationPerLevel] * [m_view levelForRow:row];
>  width += m_expander;
>   }
> 
> The m_expander value is calculated like this:
> 
>   // assume that row 0 has an expander
>   NSRect rc = [m_view frameOfOutlineCellAtRow:0];
>   m_expander = ceil(rc.origin.x + rc.size.width);
> 
> This works nicely on 10.13. See here: https://imgur.com/w8uT4gu 
> 
> On macOS 11, however, the calculation is not correct and the text gets 
> ellipsized, see here: https://imgur.com/HiOBVjh 
> 
> Debugging has shown that m_expander is missing 4 pixels on macOS 11. On macOS 
> 10.13 rc.origin.x is 6 and rc.size.width is 12. On macOS 11, rc.origin.x is 2 
> and rc.size.width is 12. However, this seems to be correct because you can 
> see that the space to the left of the expander is smaller on macOS 11 than on 
> macOS 10.13 so the values look correct. All other values are identical 
> between 10.13 and 11. The column width computed by 10.13 is 169 and the 
> column width computed by macOS 11 is 165.
> 
> Still, as you can see, the overall column width calculation is not correct on 
> macOS 11 because the text gets ellipsized. Anybody got an idea what the 
> problem here is?
> 
> -- 
> Best regards,
> Andreas Falkenhahn  mailto:andr...@falkenhahn.com
> 
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> https://lists.apple.com/mailman/options/cocoa-dev/petrock%40mac.com
> 
> This email sent to petr...@mac.com

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


NSTableColumn width computation doesn't work correctly on macOS 11

2021-06-25 Thread Andreas Falkenhahn via Cocoa-dev
I'm manually calculating the minimum size of my NSTableColumn to avoid text 
ellipsization. The calculation looks like this:

   NSCell *cell = [m_view preparedCellAtColumn:m_column row:row];

   int width = ceil([cell cellSize].width);

   if(m_column == [m_view outlineTableColumn]) {
  width += [m_view indentationPerLevel] * [m_view levelForRow:row];
  width += m_expander;
   }

The m_expander value is calculated like this:

   // assume that row 0 has an expander
   NSRect rc = [m_view frameOfOutlineCellAtRow:0];
   m_expander = ceil(rc.origin.x + rc.size.width);

This works nicely on 10.13. See here: https://imgur.com/w8uT4gu 

On macOS 11, however, the calculation is not correct and the text gets 
ellipsized, see here: https://imgur.com/HiOBVjh 

Debugging has shown that m_expander is missing 4 pixels on macOS 11. On macOS 
10.13 rc.origin.x is 6 and rc.size.width is 12. On macOS 11, rc.origin.x is 2 
and rc.size.width is 12. However, this seems to be correct because you can see 
that the space to the left of the expander is smaller on macOS 11 than on macOS 
10.13 so the values look correct. All other values are identical between 10.13 
and 11. The column width computed by 10.13 is 169 and the column width computed 
by macOS 11 is 165.

Still, as you can see, the overall column width calculation is not correct on 
macOS 11 because the text gets ellipsized. Anybody got an idea what the problem 
here is?

-- 
Best regards,
 Andreas Falkenhahn  mailto:andr...@falkenhahn.com

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com