[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSView boundsRotation

From: Dr . H . Nikolaus Schaller
Subject: Re: NSView boundsRotation
Date: Thu, 14 Jul 2011 12:25:42 +0200

Hi Fred,

Am 14.07.2011 um 11:02 schrieb Fred Kiefer:

> I spend some time to find out why the NSView_bounds_scale.m test is failing 
> and now I am pretty sure I have the solution, although I don't like it.

As you know: me too...

> The problem here is the boundsRotation. Apple seems to have a very specific 
> concept here. The value returned by that method (and used internally by 
> methods like

yes, the way it is implemented in AppKit is quite strange and completely 
undocumented. But we should follow it.

> setBoundsRotation:) isn't what you would expect. I think they store this 
> value directly for the NSView and adjust it only from the rotation methods. 
> That is, this value has nothing to do with the actual rotation value of the 
> current bounds transformation matrix, as we implemented it in GNUstep. The 
> important difference is when you combine a scale operation with a rotation. 
> Independent of the order of these operations Apple comes up with the same 
> rotation value, whereas GNUstep will end up with different values.

Well, Apple sometimes comes up with values depending on the order but I did not 
find enough time to to pin down this case.
Basically it appears to be

* rotate by 30 degrees
* scale non-uniformly (e.g. 0.5 in x direction and 0.7 in y direction)
* rotation remains 30 degrees
* rotate to 29 degrees; boundsRotation is 29.00000
* rotate back to 30 degrees - and you get a different value of the bounds rect 
than before @30 degrees but boundsRotation is again 30.00000

> As there is no use in saying that our results are mathematically correct, I 
> suggest that we move over to the Apple way of doing things and start storing 
> the rotation in the NSView. This saves us one expensive call to atan2() as 
> well.

exactly. mySTEP is already doing it by iVars because I never did see a rounding 
difference between setBoundsRotation and boundsRotation:


> The same change may also be needed for the frame rotation, but I will have to 
> write more test code to verify this.

frameRotation appears to be simpler since there are no scaling and translation 
modifier methods. Nevertheless, mySTEP also uses a separate iVar for that 
purpose because it is faster than any atan2().


reply via email to

[Prev in Thread] Current Thread [Next in Thread]