Fixed convertPoint/rect to work across different windows.

[#193 state:resolved]

Reviewed by me.
This commit is contained in:
Francisco Ryan Tolmasky I
2009-01-03 12:14:04 -08:00
parent aabe06eb3f
commit 35fc44e183
+28 -2
View File
@@ -1844,7 +1844,10 @@ var _CPViewFullScreenModeStateMake = function(aView)
var _CPViewGetTransform = function(/*CPView*/ fromView, /*CPView */ toView)
{
var transform = CGAffineTransformMakeIdentity();
var transform = CGAffineTransformMakeIdentity(),
sameWindow = YES,
fromWindow = nil,
toWindow = nil;
if (fromView)
{
@@ -1868,8 +1871,24 @@ var _CPViewGetTransform = function(/*CPView*/ fromView, /*CPView */ toView)
}
// If we hit toView, then we're done.
if (view == toView)
if (view === toView)
return transform;
else if (fromView && toView)
{
fromWindow = [fromView window];
toWindow = [toView window];
if (fromWindow && toWindow && fromWindow !== toWindow)
{
sameWindow = NO;
var frame = [fromWindow frame];
transform.tx += _CGRectGetMinX(frame);
transform.ty += _CGRectGetMinY(frame);
}
}
}
// FIXME: For now we can do things this way, but eventually we need to do them the "hard" way.
@@ -1890,6 +1909,13 @@ var _CPViewGetTransform = function(/*CPView*/ fromView, /*CPView */ toView)
view = view._superview;
}
if (!sameWindow)
{
var frame = [toWindow frame];
transform.tx -= _CGRectGetMinX(frame);
transform.ty -= _CGRectGetMinY(frame);
}
/* var views = [],
view = toView;