Hello everyone.

I have an NSSplitView with dynamic contents (views can be added and deleted in 
runtime). Views can also be collapsed by the user, or programmatically at 
certain situations.

My problem is this. Each of my views has a minimum size and a maximum size, 
that must be met anytime, or the content gets flawed. 

Implementing

- (CGFloat)splitView:(NSSplitView *)splitView 
constrainMinCoordinate:(CGFloat)proposedMinimumPosition 
ofSubviewAt:(NSInteger)dividerIndex;
- (CGFloat)splitView:(NSSplitView *)splitView 
constrainMaxCoordinate:(CGFloat)proposedMaximumPosition 
ofSubviewAt:(NSInteger)dividerIndex;

I was able to achieve that -- When the user drags the dividers between subviews 
of the NSSplitView.

However, when the NSSplitView itself is resized (following a resize of its 
window or superview), the normal behavior of NSSplitView is not to respect my 
provided constraints. It calls on the internal implementation of the delegate 
method

- (void)splitView:(NSSplitView *)splitView 
resizeSubviewsWithOldSize:(NSSize)oldSize;

Which in turn calls the internal implementation of 

- (void)adjustSubviews;

who tries to adjust the frames of subviews of the splitter, maintaining their 
proportions, but NEGLECTING the min/max size constraints supplied by the 
delegate.

I Implemented my own logic into the splitView:resizeSubviewsWithOldSize: 
delegate method, trying to maintain both proportional scaling AND min/max 
constraints, but I reach a situation where the overall splitView is too small 
to show all of the subviews --- even in their minimal sizes. 

At that point, I need to COLLAPSE one of the subviews, to keep the constraints. 
However I must do this  from WITHIN the splitView:resizeSubviewsWithOldSize: 
implementation, which sets up the frames for all subviews! Meaning --- to so 
manipulate the subview I want to collapse, that NSSplitView will "Understand" 
that it is collapsed. when the method returns.

In other words, I need to imitate what adjustSubviews does and what NSSplitView 
does, to collapse a subview. 
It is not fully documented --- how NSSplitView actually collapses a sub-view, 
but there are several hints. 

1. I know a collapsed subView gets hidden. (isHidden == YES).
2. I know the the collapsed subview usually remains with its original frame, 
despite NSSplitView documentation saying --- 

"Collapsed subviews are hidden but retained by the split view. Collapsing of a 
subview will not change its bounds, but may set its frame to zero pixels high 
(in horizontal split views) or zero pixels wide (vertical)."

3. The above insinuates, that NSSplitView sets up Bounds transform on its 
subviews --- but this s nowhere in the  documentation, and it is not explained 
what happens if the subview already had its special transform then NSSplitView 
wants to collapses it.

4. There is NO API to programmatically collapse a subview of the NSSplitView. 
It is almost ridiculous not to have such API. I tries several ways, and the one 
that most closely works for me is to set the subview's divider position past 
its min/max position, to get to to collapse --- however, Here (in resizing the 
SplitView) I cannot use this.

Can anyone enlighten me on the subject? Did anyone ever shed his eyes on 
Apple's implementation of adjustSubViews, or other parts of NSSplitView?

I really need an advice here.

Thanks (and sorry for the lengthy question).

Motti Shneor.
_______________________________________________

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

Reply via email to