Re: wantsDefaultClipping set to NO
Re: wantsDefaultClipping set to NO
- Subject: Re: wantsDefaultClipping set to NO
- From: Leonardo <email@hidden>
- Date: Tue, 10 Dec 2013 21:24:59 +0100
- Thread-topic: wantsDefaultClipping set to NO
Thank you Kyle.
I'm taking a look at the layout. I have a question.
I don't need to auto-align the NSView. I need to let the user enter origin
and size of the view (excluding the shadow and frame) and get the view on
those coordinates and size.
Let's say I learn how to configure the layout with e.g.
setTranslatesAutoresizingMaskIntoConstraints, alignmentRectInsets,
alignmentRectForFrame, frameForAlignmentRect and such... Then which
properties should I bind to the NSStepper and NSTextFields on the UI in
order to place the view with the right origin and size?
Regards
-- Leonardo
> Da: Kyle Sluder <email@hidden>
> Data: Thu, 05 Dec 2013 16:12:16 -0800
> A: Leonardo <email@hidden>, <email@hidden>
> Oggetto: Re: wantsDefaultClipping set to NO
>
> On Thu, Dec 5, 2013, at 01:03 PM, Leonardo wrote:
>> I have to draw a NSShadow out of my NSViews' bounds.
>> So I overrided the wantsDefaultClipping methond returning NO.
>
> You can't do this. Drawing outside of your view's bounds isn't
> supported. (More specifically, you must not draw outside of the rects
> returned by -getRectsBeingDrawn:count:).
>
> If your view ever becomes layer-backed (which is not a state you can
> entirely control), it won't necessarily be drawing to a backing store
> larger than its bounds.
>
>> A) What's the purpose of the wantsDefaultClipping method?
>
> As per the View Programming Guide[1], it exists to avoid duplicating any
> work you're already doing in order to restrict your drawing within the
> valid drawable regions.
>
> [1]
> <https://developer.apple.com/library/mac/documentation/cocoa/conceptual/CocoaV
> iewsGuide/Optimizing/Optimizing.html>
>
>> C) Or should I simply enlarge the view to draw the shadow? If so, I have
>
> This is the correct approach.
>
>> to
>> change the origin and size of the view. Therefore, how can I adjust the
>> origin and size that the user enters on UI with the bound values I use in
>> the setFrameOrigin and setFrameSize ?
>
> You don't. Stop using -setFrame{,Origin,Size}: directly and start using
> auto layout. You can override -alignmentRectInsets to return the amount
> of padding on each side of your view, giving you enough room to draw
> your shadow.
>
> --Kyle Sluder
_______________________________________________
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