NSCollectionView issues

2009-10-16 Thread Half Activist

Hi,
	I'm using a NSCollectionView to display a stack of items (a table)  
but since what's display is far too complex to be laid out  
programmatically I went for the NSCollectionView. And it's been all  
problems from the beginning.
	First of all with setContent that never worked no matter what I  
did...it only works if I bind the content to an nsarraycontroller.


	Now, when I add a new item in this table i want to be able to  
scroll it to the displayed area of the view, but the  
frameForItemAtIndex: method only appeared in 10.6, so I decided to use  
the subviews and get the frame this way, and now what did I discover:  
Suppose I have N items and therefore N subviews in the  
NSCollectionView, after changing the array that now contains N + 1  
items, the nscollectionview has after the update N + N + 1 subviews!

So, accessing subviews is not an option either.

If anyone knows how to do fix these bugs, and how to disable the  
animation, i'd be really glad. I'm considering writing an homebrew  
nscollectionview.


regards.
___

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: NSCollectionView issues

2009-10-16 Thread Jim Turner
10.5's collection view is, safe to say, kind of a train wreck. I've
had to work around quite a few things.  Your problem is solvable by
asking the NSCollectionViewItem created for your new table element for
its view and to have that view scrollRectToVisible: for its bounds.

If you need to get the ViewItem for a specific index (available via
NSCollectionView's itemAtIndex: under 10.6), you'll need to go into
slightly undocumented land and look at the collection view's
_targetItems ivar. It contains the list of NSCollectionViewItems
currently displayed in the collection view.  Make sure you
conditionalize this for 10.6 as _targetItems isn't there anymore.

Hope that helps

-- 
Jim
http://nukethemfromorbit.com


On Fri, Oct 16, 2009 at 9:32 AM, Half Activist halfactiv...@gmail.com wrote:
 Hi,
        I'm using a NSCollectionView to display a stack of items (a table)
 but since what's display is far too complex to be laid out programmatically
 I went for the NSCollectionView. And it's been all problems from the
 beginning.
        First of all with setContent that never worked no matter what I
 did...it only works if I bind the content to an nsarraycontroller.

        Now, when I add a new item in this table i want to be able to
 scroll it to the displayed area of the view, but the frameForItemAtIndex:
 method only appeared in 10.6, so I decided to use the subviews and get the
 frame this way, and now what did I discover: Suppose I have N items and
 therefore N subviews in the NSCollectionView, after changing the array that
 now contains N + 1 items, the nscollectionview has after the update N + N +
 1 subviews!
 So, accessing subviews is not an option either.

 If anyone knows how to do fix these bugs, and how to disable the animation,
 i'd be really glad. I'm considering writing an homebrew nscollectionview.

 regards.
 ___

 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/jturner.lists%40gmail.com

 This email sent to jturner.li...@gmail.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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: NSCollectionView issues

2009-10-16 Thread I. Savant

On Oct 16, 2009, at 10:32 AM, Half Activist wrote:

	I'm using a NSCollectionView to display a stack of items (a table)  
but since what's display is far too complex to be laid out  
programmatically I went for the NSCollectionView. And it's been all  
problems from the beginning.


  Yes, depending on what you need from it, its convenience can be  
outweighed by its limitations.



	First of all with setContent that never worked no matter what I  
did...it only works if I bind the content to an nsarraycontroller.


  Okay ... what have you tried? Can't help if you don't say what you  
did.



	Now, when I add a new item in this table i want to be able to  
scroll it to the displayed area of the view,


  Can you rephrase this? The displayed area of the view is  
ambiguous, but generally the displayed area is displayed because the  
scroll vie is already scrolled to that area. :-)


  Did you mean you want to scroll to the currently-selected (or newly- 
added) collection view item (or some UI element within that view item)?



Suppose I have N items and therefore N subviews in the  
NSCollectionView, after changing the array that now contains N + 1  
items, the nscollectionview has after the update N + N + 1 subviews!

So, accessing subviews is not an option either.


  I haven't heard of this problem but then again, I had dismissed  
NSCollectionView early on as not being up to the tasks for which I'd  
hoped it'd be useful, so my experience with it is limited.


  Again, what did you try? How did you go about this? I find it odd  
that it doesn't scroll to the selection (if that's what you were  
doing), but I imagine if you ask the array controller for the  
*arranged* index of the object just inserted (whole other question -  
ask it if it's required), then ask the collection view for the - 
itemAtIndex:, you can ask that item for its -view, then use the  
scrolling methods as needed.



If anyone knows how to do fix these bugs, and how to disable the  
animation, i'd be really glad.


  I don't think there's any (public API) way to disable the  
animation. Why do you want to do that?




I'm considering writing an homebrew nscollectionview.


  Depending on your needs, this could be easier. If you only need one  
column, it's *almost* trivial. Especially if, like NSCollectionView,  
the size of each view is the same.


  If they can vary in vertical size, you can even use the same  
prototype view approach by caching at least the height of the items  
for the current view width, which lets you quickly size the whole view  
and work out the rect for the desired item (or the items for the  
desired rect). This can *greatly* improve performance for lots of  
irregularly-sized items.


  Of course there is more than one way to approach this but building  
a basic one-column layout view like this is fairly simple. Even adding  
drag-and-drop to this isn't too difficult for a moderately-experienced  
Cocoa developer.


--
I.S.




___

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: NSCollectionView issues

2009-10-16 Thread I. Savant

On Oct 16, 2009, at 11:42 AM, Jim Turner wrote:


If you need to get the ViewItem for a specific index (available via
NSCollectionView's itemAtIndex: under 10.6)


  Bah - I failed to notice -itemAtIndex: is also 10.6-only.

  I mostly agree with the train wreck sentiment. The 10.5  
implementation seemed useful only for its most common demonstration:  
image thumbnails.


--
I.S.




___

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