Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Setting a clip mask on a NSView




On Jan 26, 2008, at 8:29 PM, Jonathon Mah wrote:

Hi Tim,

On 2008-01-27, at 07:53, Timothy Wall wrote:

Is it possible to set an arbitrary clip mask on an NSView without rewriting its drawRect? The goal is to be able to clip/obscure parts of a NSView without necessarily putting anything in front of it.


You mention an "arbitrary" mask, but the next paragraph makes me think that a rectangular mask may be enough. If that's the case, you could stick your NSView inside an NSClipView, then set the clipping origin with -scrollToPoint: (it will take the size from the clip view).

Imagine I'm writing my own "mini-desktop" within a window (like windows multi-document interface). Most of the time the clipping would be sets of rectangles, but it'd be possible to have one of the "desktop" elements be non-rectangular.



Cocoa doesn't like the idea of "in front of" (overlapping views aren't supported, except in layer-backed Core Animation); the paradigm is more "inside of".

That doesn't sound promising.


If you do need arbitrary clipping (circles or the like), you could implement your own clipview-like class, but you might not save much as you'd still have to call -drawRect: and pass it a rectangle (you could do some calculations and call it multiple times with multiple rects).

So the "canonical" way to clip a given NSView is to have an ancestor do the clipping? It might be possible to insert a shim parent to the component in question.


Thanks
T.

_______________________________________________

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:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden
References: 
 >Setting a clip mask on a NSView (From: Timothy Wall <email@hidden>)
 >Re: Setting a clip mask on a NSView (From: Jonathon Mah <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.