Re: Where to noteHeightOfRowsWithIndexesChanged

2010-06-16 Thread Tony P

Thanks for all the responses folks.

On 15 Jun 2010, at 7:22 pm, Corbin Dunn wrote:

Do the height calculations in the bounds change, and then call the  
"noteHeight.." method all in the same run loop stack; that will  
probably fix your problem.


Beautiful, works like a dream. Many, many thanks for that, you're a  
superstar!


Even though it is fast, however, a table with 200,000 rows is  
excessive. There is no way a user can realistically use all those  
rows without some sort of filtering/searching. I would consider re- 
doing your UI to have a "more results" button, akin to the Finder  
spotlight search results.


It does have a search, and I would agree, but arbitrary browsing is  
required (even from the search which just scrolls to the results).  
Unfortunately it's a PC->Mac port and you'll have to drag me through  
hot coals before I'll be happy with a Mac version that seems somehow  
inferior to the PC version. It's an iPhone version next though, so  
I'll definitely have to re-think the UI for that.


Thanks again,

Tony Pollard


On 15 Jun 2010, at 7:22 pm, Corbin Dunn wrote:



On Jun 15, 2010, at 10:55 AM, Jens Alfke wrote:



On Jun 15, 2010, at 10:51 AM, Jerry Krinock wrote:


I send noteHeightOfRowsWithIndexesChanged: after updating the  
contents of the array controller to which a table is bound, but I  
still see little artifacts sometimes.  It's in a rarely-used  
utility view so I've let it slide. But under the conditions you've  
mentioned,


If you can reproduce this, please log a bug.



There are usually about 200,000 rows, so calculating the actual  
height for all rows is not an option (since it takes about 19  
seconds).


you may have exceeded the capabilities of NSTableView's variable  
heights


I agree. Variable row heights were a late addition to NSTableView  
(added in 10.3 or 10.4?) and I wouldn’t be surprised if they’re not  
optimized for huge numbers of rows.


The table view is optimized for a huge number of rows -- the  
implementation in 10.3-10.6 uses a sparse array of row heights, and  
attempts to lump together equal row heights into a single bucket.  
This makes it quite fast at computations. Having a lot of non-equal  
row heights will be more expensive (there is no way around that) as  
each rowRect computation needs to figure out where to be.


Even though it is fast, however, a table with 200,000 rows is  
excessive. There is no way a user can realistically use all those  
rows without some sort of filtering/searching. I would consider re- 
doing your UI to have a "more results" button, akin to the Finder  
spotlight search results.


With respect to:

The tableview has variable height rows, and because of a relatively  
slow data source, resizing and user control of fonts, etc, I don't  
know the row height in advance. I'm caching the row height, and  
returning a single-line height if the row is not visible (and the  
height is not yet known). If the row is visible I calculate the  
actual height and return that (via the NSTableView heightOfRow  
delegate).


This almost works, but I've not found a good place to put  
noteHeightOfRowsWithIndexesChanged. I get either overlapping rows  
or some blank rows during scroll. I've tried  
NSViewBoundsDidChangeNotification. I've even tried putting it in  
the heightOfRow delegate (which I know must be wrong), with some re- 
entrancy control which has given the best results so far (but still  
displays blank rows sometimes). There are usually about 200,000  
rows, so calculating the actual height for all rows is not an  
option (since it takes about 1


You need to always return the *same* height until you call  
noteHeightOfRowsWithIndexesChanged. After calling that method, the  
said indexes can return a new height. Not doing this will cause the  
types of problems that you see, as the table may (or may not) cache  
every row height, and expects the same result to be returned for the  
same row every time (until it was told it changed).


Sending the node in some sort of bounds changed notification should  
be fine -- the problem you are encountering is probably because you  
are breaking the above rule mentioned. Do the height calculations in  
the bounds change, and then call the "noteHeight.." method all in  
the same run loop stack; that will probably fix your problem.


corbin

___

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:
http://lists.apple.com/mailman/options/cocoa-dev/tonyp%40neutral.co.uk

This email sent to to...@neutral.co.uk


___

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/

Where to noteHeightOfRowsWithIndexesChanged

2010-06-15 Thread Tony P
Where's the best place to put noteHeightOfRowsWithIndexesChanged to  
keep a tableview display correct whilst scrolling?


The tableview has variable height rows, and because of a relatively  
slow data source, resizing and user control of fonts, etc, I don't  
know the row height in advance. I'm caching the row height, and  
returning a single-line height if the row is not visible (and the  
height is not yet known). If the row is visible I calculate the actual  
height and return that (via the NSTableView heightOfRow delegate).


This almost works, but I've not found a good place to put  
noteHeightOfRowsWithIndexesChanged. I get either overlapping rows or  
some blank rows during scroll. I've tried  
NSViewBoundsDidChangeNotification. I've even tried putting it in the  
heightOfRow delegate (which I know must be wrong), with some re- 
entrancy control which has given the best results so far (but still  
displays blank rows sometimes). There are usually about 200,000 rows,  
so calculating the actual height for all rows is not an option (since  
it takes about 19 seconds).


Any ideas anyone?

Tony
___

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: Single-click words in NSTableView / NSTextFieldCell

2010-04-09 Thread Tony P
Thanks for that Corbin. That's fine and dandy, except I'm still stuck  
in identifying the "link" word. There are multiple "link" words or  
phrases in each cell, so I don't know which one has been hit without  
some kind of characterIndexForPoint functionality. Or perhaps I can't  
see the wood for the trees?


Tony


On 8 Apr 2010, at 5:34 pm, Corbin Dunn wrote:

On Apr 8, 2010, at 8:17 AM, Tony P wrote:


Hi Folks,

I'm trying to implement single-clicking for multiple words/phrases  
within an NSTableView / NSTextFieldCell, which seems surprisingly  
tricky. I've tried using NSAttributedString (in the hope I can use  
a special NSURLProtocol to intercept the hyperlink), but it takes  
four clicks to get there (row select, cell select, edit, and link- 
click). I've tried numerous tricks but to no avail.


I can over-ride hitTestForEvent (see the "Hyperlinks in Table  
Views" thread) so the other alternative would be some way of  
getting characterIndexForPoint for the NSTextFieldCell, but that  
doesn't seem to exist. I'm hoping I don't need to do something  
wacky with an off-screen view.


How can I get the NSTextFieldCell to react with just one click? Or  
is there a way to get characterIndexForPoint for the NSTextFieldCell?


You'll have to implement the logic in an NSTableView subclass.  
Override -mouseDown:, grab the cell at the mouse location, look at  
the cell's contents to see if you hit a link, and if so, do your  
link stuff. If not, call super for the default selection/tracking/ 
editing behavior to take place.


corbin




___

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Single-click words in NSTableView / NSTextFieldCell

2010-04-08 Thread Tony P

Hi Folks,

I'm trying to implement single-clicking for multiple words/phrases  
within an NSTableView / NSTextFieldCell, which seems surprisingly  
tricky. I've tried using NSAttributedString (in the hope I can use a  
special NSURLProtocol to intercept the hyperlink), but it takes four  
clicks to get there (row select, cell select, edit, and link-click).  
I've tried numerous tricks but to no avail.


I can over-ride hitTestForEvent (see the "Hyperlinks in Table Views"  
thread) so the other alternative would be some way of getting  
characterIndexForPoint for the NSTextFieldCell, but that doesn't seem  
to exist. I'm hoping I don't need to do something wacky with an off- 
screen view.


How can I get the NSTextFieldCell to react with just one click? Or is  
there a way to get characterIndexForPoint for the NSTextFieldCell?


Tony Pollard
___

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Centering scrollRowToVisible on NSTableView

2010-04-01 Thread Tony P
I'm trying to vertically center a NSTableView row (variable height)  
using scrollRowToVisible. The default behaviour seems to be displaying  
at the next-to-last row within the view. After much research, the only  
way I can see to do this is to calculate row heights for subsequent  
rows and adjust the call to scrollRowToVisible accordingly. However,  
I've got a feeling that there might  be something much simpler?


Tony Pollard

___

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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