Re: Yosemite NSCollectionView appropriate for spreadsheet-like view?
> On 1 May 2016, at 17:06, thatsanicehatyouh...@me.com wrote: > > My guess is that since the basic unit here is NSTableRowView, all of the > columns are loaded into each row view whether they are on the screen or not. > View based table views recycle their views and I have found them to be very flexible in use. There is a lot of functionality in there. If the default behaviour of NSTableRowView is causing an issue them you can always subclass this and provide it to the NSTableView via. - (NSTableRowView *)tableView:(NSTableView *)tableView rowViewForRow:(NSInteger)row J ___ 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: Yosemite NSCollectionView appropriate for spreadsheet-like view?
Model your spread sheet on a (hypothetical 2-D)TableView. Maintain a pool of cells starting with enough to cover the view at the default size plus a bit of margin. As cells scroll off the view return them to the pool; as you need new ones get them from the pool. If the pool is empty you allocate a new one. It’s a bit complicated - you have to keep track of the scrolling in two directions and have to account for anything else that changes which cells are visible. But I’ve done it and it works. Unfortunately it was for a commercial client and I no longer have the code so I can’t share it. …Robert > > Message: 1 > Date: Tue, 03 May 2016 11:53:16 -0700 > From: Jens Alfke <j...@mooseyard.com <mailto:j...@mooseyard.com>> > To: thatsanicehatyouh...@me.com <mailto:thatsanicehatyouh...@me.com> > Cc: cocoa-dev@lists.apple.com <mailto:cocoa-dev@lists.apple.com> > Subject: Re: Yosemite NSCollectionView appropriate for > spreadsheet-like view? > Message-ID: <f62fb2ae-4f2b-4503-9d37-026336939...@mooseyard.com > <mailto:f62fb2ae-4f2b-4503-9d37-026336939...@mooseyard.com>> > Content-Type: text/plain; charset=utf-8 > > >> On May 1, 2016, at 9:06 AM, thatsanicehatyouh...@me.com >> <mailto:thatsanicehatyouh...@me.com> wrote: >> >> As I've been thinking about this problem it occurred to me that the new(ish) >> NSCollectionView might be a viable replacement in this case. Before I go >> down the rabbit hole, is it reasonable to use to create a spreadsheet-like >> view? > > No, because it eagerly creates a view for every item in the collection. So if > you have a spreadsheet with 100,000 cells, it’s going to create 100,000 > NSViews when the window opens. > > NSMatrix may work better because it uses only a single view, but IIRC it > still preallocates an NSCell for every item. Also I think it’s been > deprecated. > > I suspect you’ll need a custom view that uses cells or some other > lightweight-view design pattern to avoid consuming resources for items that > aren’t currently visible. (Of course, someone else may have already > implemented that custom view, either as open source or commercially.) > > —Jens ___ 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: Yosemite NSCollectionView appropriate for spreadsheet-like view?
> On May 3, 2016, at 12:33 PM, Alex Kacwrote: > > There is the old NSCollectionView and the new. You have to use the new > delegate methods and so on. Its the same class, but behind the scenes the new > collection view is literally the UICollectionView from iOS ported over > (syslog even says UICollectionView…). Its not *at all obvious*. Oh! I was not aware of the new API. I haven’t updated the collection-view-related code in my app in a year or two. Should definitely do some work on it soon… —Jens ___ 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: Yosemite NSCollectionView appropriate for spreadsheet-like view?
There is the old NSCollectionView and the new. You have to use the new delegate methods and so on. Its the same class, but behind the scenes the new collection view is literally the UICollectionView from iOS ported over (syslog even says UICollectionView…). Its not *at all obvious*. I know I worked with it a few months ago and it was reusing the cells. > On May 3, 2016, at 1:23 PM, Jens Alfkewrote: > > >> On May 3, 2016, at 12:08 PM, thatsanicehatyouh...@me.com wrote: >> >> I should have been more specific - my understanding was that >> NSCollectionView from 10.11 onward did not do this... which Alex Kac just >> beat me to mentioning! I was curious if anyone was aware of limitations of >> this scope with that caveat. > > I dunno — I have a Mac app using NSCollectionView, and before I sent my post, > I experimentally added some logging to the -init method of the NSView > subclass that draws the cells. I opened a window with a few hundred items > (about four or five screenfuls) and saw that all of the views got initialized > at the moment the window opened. > > This is on 10.11.4, and I built the app with Xcode 7.3, so I should be > getting whatever the latest behavior is. > > Is there some particular way I have to configure the collection view to get > the lazy-loading behavior? > > Alex Kac - El capitán ___ 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: Yosemite NSCollectionView appropriate for spreadsheet-like view?
> On May 3, 2016, at 12:08 PM, thatsanicehatyouh...@me.com wrote: > > I should have been more specific - my understanding was that NSCollectionView > from 10.11 onward did not do this... which Alex Kac just beat me to > mentioning! I was curious if anyone was aware of limitations of this scope > with that caveat. I dunno — I have a Mac app using NSCollectionView, and before I sent my post, I experimentally added some logging to the -init method of the NSView subclass that draws the cells. I opened a window with a few hundred items (about four or five screenfuls) and saw that all of the views got initialized at the moment the window opened. This is on 10.11.4, and I built the app with Xcode 7.3, so I should be getting whatever the latest behavior is. Is there some particular way I have to configure the collection view to get the lazy-loading behavior? —Jens ___ 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: Yosemite NSCollectionView appropriate for spreadsheet-like view?
On May 3, 2016, at 2:53 PM, Jens Alfkewrote: > No, because it eagerly creates a view for every item in the collection. So if > you have a spreadsheet with 100,000 cells, it’s going to create 100,000 > NSViews when the window opens. I should have been more specific - my understanding was that NSCollectionView from 10.11 onward did not do this... which Alex Kac just beat me to mentioning! I was curious if anyone was aware of limitations of this scope with that caveat. I will note that I found this by Matt Ball which looks interesting: https://github.com/mattball/mbtablegrid/ While seven years old (and a bit glitchy) it does compile. Tommy van der Vorst forked it a while back and has updated it, so for anyone looking this is a great starting point. Well, actually pretty complete as it's used in a shipping product. https://github.com/pixelspark/mbtablegrid Cheers, Demitri ___ 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: Yosemite NSCollectionView appropriate for spreadsheet-like view?
10.11 CollectionView reuses views and doesn’t create 100,000 cells. So that could be appropriate. > On May 3, 2016, at 12:53 PM, Jens Alfkewrote: > > >> On May 1, 2016, at 9:06 AM, thatsanicehatyouh...@me.com wrote: >> >> As I've been thinking about this problem it occurred to me that the new(ish) >> NSCollectionView might be a viable replacement in this case. Before I go >> down the rabbit hole, is it reasonable to use to create a spreadsheet-like >> view? > > No, because it eagerly creates a view for every item in the collection. So if > you have a spreadsheet with 100,000 cells, it’s going to create 100,000 > NSViews when the window opens. > > NSMatrix may work better because it uses only a single view, but IIRC it > still preallocates an NSCell for every item. Also I think it’s been > deprecated. > > I suspect you’ll need a custom view that uses cells or some other > lightweight-view design pattern to avoid consuming resources for items that > aren’t currently visible. (Of course, someone else may have already > implemented that custom view, either as open source or commercially.) > > —Jens > ___ > > 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/alex%40webis.net > > This email sent to a...@webis.net Alex Kac - El capitán ___ 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: Yosemite NSCollectionView appropriate for spreadsheet-like view?
> On May 1, 2016, at 9:06 AM, thatsanicehatyouh...@me.com wrote: > > As I've been thinking about this problem it occurred to me that the new(ish) > NSCollectionView might be a viable replacement in this case. Before I go down > the rabbit hole, is it reasonable to use to create a spreadsheet-like view? No, because it eagerly creates a view for every item in the collection. So if you have a spreadsheet with 100,000 cells, it’s going to create 100,000 NSViews when the window opens. NSMatrix may work better because it uses only a single view, but IIRC it still preallocates an NSCell for every item. Also I think it’s been deprecated. I suspect you’ll need a custom view that uses cells or some other lightweight-view design pattern to avoid consuming resources for items that aren’t currently visible. (Of course, someone else may have already implemented that custom view, either as open source or commercially.) —Jens ___ 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
Yosemite NSCollectionView appropriate for spreadsheet-like view?
Hi, I have an NSTableView that may sometimes be called upon to display very large amounts of data. I can handle this in the vertical aspect - while my data source may have many thousands of rows, I only load batches of 500 at a time, and NSTableView doesn't slow down for rows not displayed. This is not true for columns, however. My performance/responsiveness is great below some number of columns (~15), but increase this much more (e.g. 200) and the performance lags. My guess is that since the basic unit here is NSTableRowView, all of the columns are loaded into each row view whether they are on the screen or not. As I've been thinking about this problem it occurred to me that the new(ish) NSCollectionView might be a viable replacement in this case. Before I go down the rabbit hole, is it reasonable to use to create a spreadsheet-like view? What I'd like from this view is basically what you'd find in a spreadsheet - horizontal and vertical headers that scroll, editable cells, discontiguous selection, and high performance regardless of the number of data points. (As a note; I am aware that displaying tens of thousands of cells in a view isn't immediately useful from a UI point of view and I have two preferred views as an alternate, but sometimes you just want to access the raw values.) Cheers, Demitri ___ 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