Re: Autolayout frustrations with NSOutlineView [SOLVED, +follow-up question]
Re: Autolayout frustrations with NSOutlineView [SOLVED, +follow-up question]
- Subject: Re: Autolayout frustrations with NSOutlineView [SOLVED, +follow-up question]
- From: Graham Cox <email@hidden>
- Date: Wed, 30 Jul 2014 15:38:41 +1000
On 30 Jul 2014, at 12:42 pm, Quincey Morris <email@hidden> wrote:
> On Jul 29, 2014, at 18:52 , Graham Cox <email@hidden> wrote:
>
>> What I want is to have my enclosed custom view 'stick' to the top, left (or wherever it's scrolled to) of the clip view as long as it's larger than the clip view, but become horizontally and vertically centered in the clip view if it's smaller (e.g. when zoomed so that its frame shrinks). This is a fairly classic requirement, and has been solved in the past by having a custom clip view that can recognise the 'smaller than' situation and force its contained view to be centred.
>
> Actually, I’ve never (that I recall) taken that approach, but rather constrained the “document” view (the clip view’s child) to be at least as large as the clip view — and coincident with the clip view when they’re the same size, of course.
Unfortunately I don't think this will work for me if I understand what you're saying correctly, because my document content is in fact a drawing canvas that has a fixed size (that the user can set) but this is independent of the size and aspect ratio of the clip view. The canvas can be zoomed at will, and will often become smaller than the entire clip view, at least in one or other dimension (though both is common too).
Even if I constrained the zoom such that the canvas could never become smaller than the smaller of the clip view's sides, it would still need to be centred on the other axis to look good. Constraining it to the other axis in the first place isn't a good solution either, because it might mean there is hidden content that the user can't see when trying to get an overview of the whole document.
Also, the design of the content view is very stable and has been around for almost a decade - I don't plan to rework it for this next iteration of the app if I can help it. I could interpose another view between it and the clip view I suppose, and implement the 'smart' cenering there, but if I did that I may as well stick with a custom clip view as I have used in the past. What I'm hoping is that autolayout can solve this issue without needing the custom clip view (or another interposed view).
> There are a couple of other good reasons to draw in a clip-view-size document view, rather than a smaller view that just encloses the content:
>
> 1. If you have the ability to drag out a selection rectangle, its visible representation doesn’t stop at the edges of the central portion of the clip view.
I do have this, but I'm not sure what it would mean to the user if the rectangle extended beyond the edge of the canvas. I've always drawn it as an overlay on the canvas, so it's clipped by its edges.
> 2. IIRC, the ruler annotations stop drawing at the boundaries of the document view, which in your scenario produces blank ruler sections that can look mighty strange.
NSRulerView draws marks right up to the edges of the view even if that represents more than the actual usable interior of the canvas. The zero point remains correct, so extra negative marks are drawn to "fill in" on the left if needed.
> 3. If there’s an inner focus-ring indication of some sort for the content area, I think it looks better drawn just inside the clip view bounds, rather than the smaller content bounds. (But I had to draw a custom indication, because it was on the inside of the view instead of the outside. Now that we have more robust outer-focus-ring drawing mechanisms, I don’t think I’d bother with the custom inside-view focus ring any more.)
I don't have a focus ring of this sort, but I do draw a drop shadow for the canvas (only if it's actually going to be seen - shadows are expensive) and this is drawn in the clip view, outside of the content view. Since I classically used a custom clip view, this is handled by that. If an auto-layout solution is possible, this will become a new problem to solve.
--Graham
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden