Re: erase then draw image?
Re: erase then draw image?
- Subject: Re: erase then draw image?
- From: matt neuburg <email@hidden>
- Date: Tue, 29 Oct 2002 11:34:45 -0800
On Sun, 27 Oct 2002 13:44:07 -0600, Brock Brandenberg <email@hidden> said:
>
Certain methods cause notifications to be sent to other
>
objects, which in turn react to the notifications and
>
cause other methods to be called. In the case of the
>
setBoundsRotation: method, it's causing the bounds of your
>
view to change size, which causes a
>
NSViewBoundsDidChangeNotification to be posted. This in
>
turn, causes the view hierarchy to go about its merry way,
>
updating and drawing all of the appropriate objects
>
affected by the changed bounds of your view.
>
But in this case, the view hierarchy was already in the
>
middle of an update because your drawRect: method was
>
being executed.
This cannot be the precise cause of the problem, though, because we get the very same sort of problems if the bounds rotation is performed once in initWithFrame instead.
Still, I am perfectly willing to believe that ultimately bounds rotation just plain doesn't work for a view that has other views in front of it. Basically your advice here is "Don't do that", and I'm perfectly willing to take it. I wish the docs were a bit clearer on this, though, since rotating bounds so that you can easily draw a rotated image into a view seems like exactly what rotation of bounds is for.
>
The proper way to do what you want is to use a transform
>
in the drawRect: method to manipulate the coordinate
>
system of the view, not the view itself
But of course in rotating the bounds I thought I *was* manipulating the coordinate system of the view. That is why I rotated the bounds - not the frame.
>
- (void)drawRect:(NSRect)rect {
>
NSAffineTransform *drawXform = [NSAffineTransform transform];
>
[drawXform rotateByDegrees:10];
>
[drawXform concat];
>
[image drawAtPoint etc.
Works perfectly. Many thanks for taking time over this - m.
matt neuburg, phd = email@hidden,
http://www.tidbits.com/matt
pantes anthropoi tou eidenai oregontai phusei
Subscribe to TidBITS! It's free and smart.
http://www.tidbits.com/
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.