mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-08-30 15:33:35 +00:00
Merge branch 'master' of https://github.com/cappuccino/cappuccino
This commit is contained in:
+13
-7
@@ -3516,7 +3516,6 @@ var _CPViewGetTransform = function(/*CPView*/ fromView, /*CPView */ toView)
|
||||
}
|
||||
|
||||
view = view._superview;
|
||||
|
||||
}
|
||||
|
||||
// If we hit toView, then we're done.
|
||||
@@ -3555,8 +3554,8 @@ var _CPViewGetTransform = function(/*CPView*/ fromView, /*CPView */ toView)
|
||||
if (view._boundsTransform)
|
||||
{
|
||||
var inverseBoundsTransform = CGAffineTransformMakeIdentity();
|
||||
inverseBoundsTransform.tx -= view._inverseBoundsTransform.tx * transform2.a;
|
||||
inverseBoundsTransform.ty -= view._inverseBoundsTransform.ty * transform2.d;
|
||||
inverseBoundsTransform.tx -= view._inverseBoundsTransform.tx * transform2.a;
|
||||
inverseBoundsTransform.ty -= view._inverseBoundsTransform.ty * transform2.d;
|
||||
|
||||
CGAffineTransformConcatTo(transform2, inverseBoundsTransform, transform2);
|
||||
}
|
||||
@@ -3567,10 +3566,17 @@ var _CPViewGetTransform = function(/*CPView*/ fromView, /*CPView */ toView)
|
||||
transform2.tx = -transform2.tx;
|
||||
transform2.ty = -transform2.ty;
|
||||
|
||||
if (sameWindow)
|
||||
transform = transform2;
|
||||
else
|
||||
CGAffineTransformConcatTo(transform, transform2, transform);
|
||||
if (view === fromView)
|
||||
{
|
||||
// toView is inside of fromView
|
||||
return transform2;
|
||||
}
|
||||
|
||||
CGAffineTransformConcatTo(transform, transform2, transform);
|
||||
|
||||
return transform;
|
||||
|
||||
|
||||
|
||||
/* var views = [],
|
||||
view = toView;
|
||||
|
||||
@@ -125,4 +125,61 @@
|
||||
[self assert:nil equals:[viewA nextValidKeyView]];
|
||||
}
|
||||
|
||||
- (void)testConvertPoint_fromView_shouldChangeNothingForSameView
|
||||
{
|
||||
var tView0 = [CPView new],
|
||||
aWindow = [CPWindow new];
|
||||
|
||||
[aWindow setContentView:tView0];
|
||||
|
||||
[tView0 setFrame:CGRectMake(3, 5, 13, 17)];
|
||||
|
||||
[self assertTrue:CGPointEqualToPoint(CGPointMake(7, 11), [tView0 convertPoint:CGPointMake(7, 11) fromView:tView0])]
|
||||
}
|
||||
|
||||
- (void)testConvertPoint_fromView_shouldAddSubviewCoordinatesWhenMovingUp
|
||||
{
|
||||
var tView0 = [CPView new],
|
||||
subView0 = [CPView new],
|
||||
aWindow = [CPWindow new];
|
||||
|
||||
[aWindow setContentView:tView0];
|
||||
|
||||
[tView0 addSubview:subView0];
|
||||
[tView0 setFrame:CGRectMake(30, 50, 130, 170)];
|
||||
[subView0 setFrame:CGRectMake(3, 5, 13, 17)];
|
||||
|
||||
[self assertTrue:CGPointEqualToPoint(CGPointMake(10, 16), [tView0 convertPoint:CGPointMake(7, 11) fromView:subView0])]
|
||||
}
|
||||
|
||||
- (void)testConvertPoint_fromView_shouldWorkBetweenSiblingViews
|
||||
{
|
||||
var tView0 = [CPView new],
|
||||
subView0 = [CPView new],
|
||||
aWindow = [CPWindow new];
|
||||
|
||||
[[aWindow contentView] addSubview:tView0];
|
||||
[[aWindow contentView] addSubview:subView0];
|
||||
|
||||
[tView0 setFrame:CGRectMake(30, 50, 130, 170)];
|
||||
[subView0 setFrame:CGRectMake(3, 5, 13, 17)];
|
||||
|
||||
[self assertTrue:CGPointEqualToPoint(CGPointMake(34, 56), [subView0 convertPoint:CGPointMake(7, 11) fromView:tView0])]
|
||||
}
|
||||
|
||||
- (void)testConvertPoint_fromView_shouldSubtractSubviewCoordinatesWhenMovingDown
|
||||
{
|
||||
var tView0 = [CPView new],
|
||||
subView0 = [CPView new],
|
||||
aWindow = [CPWindow new];
|
||||
|
||||
[aWindow setContentView:tView0];
|
||||
|
||||
[tView0 addSubview:subView0];
|
||||
[tView0 setFrame:CGRectMake(30, 50, 130, 170)];
|
||||
[subView0 setFrame:CGRectMake(3, 5, 13, 17)];
|
||||
|
||||
[self assertTrue:CGPointEqualToPoint(CGPointMake(4, 6), [subView0 convertPoint:CGPointMake(7, 11) fromView:tView0])]
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
Reference in New Issue
Block a user