mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-09-03 09:23:40 +00:00
Deploying to gh-pages from @ cappuccino/cappuccino@fc91326a5f 🚀
This commit is contained in:
@@ -50847,6 +50847,54 @@ class_addMethods(meta_class, [new objj_method(sel_getUid("animation"), function
|
||||
|
||||
,["id","CPString"])]);
|
||||
}
|
||||
p;18;CAAnimationGroup.jt;2371;@STATIC;1.0;I;20;Foundation/CPArray.ji;13;CAAnimation.jt;2309;objj_executeFile("Foundation/CPArray.j", NO);objj_executeFile("CAAnimation.j", YES);
|
||||
{var the_class = objj_allocateClassPair(CAAnimation, "CAAnimationGroup"),
|
||||
meta_class = the_class.isa;class_addIvars(the_class, [new objj_ivar("_animations", "CPArray")]);objj_registerClassPair(the_class);
|
||||
class_addMethods(the_class, [new objj_method(sel_getUid("init"), function $CAAnimationGroup__init(self, _cmd)
|
||||
{
|
||||
if (self = (objj_getClass("CAAnimationGroup").super_class.method_dtable["init"] || _objj_forward)(self, "init"))
|
||||
{
|
||||
self._animations = [];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
,["id"]), new objj_method(sel_getUid("setAnimations:"), function $CAAnimationGroup__setAnimations_(self, _cmd, anArray)
|
||||
{
|
||||
if (self._animations === anArray)
|
||||
return;
|
||||
self._animations = anArray;
|
||||
}
|
||||
|
||||
,["void","CPArray"]), new objj_method(sel_getUid("animations"), function $CAAnimationGroup__animations(self, _cmd)
|
||||
{
|
||||
return self._animations;
|
||||
}
|
||||
|
||||
,["CPArray"]), new objj_method(sel_getUid("runActionForKey:object:arguments:"), function $CAAnimationGroup__runActionForKey_object_arguments_(self, _cmd, aKey, anObject, arguments)
|
||||
{
|
||||
var count = ((___r1 = self._animations), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["count"] || _objj_forward)(___r1, "count")),
|
||||
i = 0;
|
||||
for (; i < count; i++)
|
||||
{
|
||||
var animation = ((___r1 = self._animations), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["objectAtIndex:"] || _objj_forward)(___r1, "objectAtIndex:", i));
|
||||
if ((animation == null ? animation : (animation.isa.method_msgSend["respondsToSelector:"] || _objj_forward)(animation, "respondsToSelector:", sel_getUid("runActionForKey:object:arguments:"))))
|
||||
{
|
||||
(animation == null ? animation : (animation.isa.method_msgSend["runActionForKey:object:arguments:"] || _objj_forward)(animation, "runActionForKey:object:arguments:", aKey, anObject, arguments));
|
||||
}
|
||||
}
|
||||
var ___r1;
|
||||
}
|
||||
|
||||
,["void","CPString","id","CPDictionary"])]);
|
||||
class_addMethods(meta_class, [new objj_method(sel_getUid("group"), function $CAAnimationGroup__group(self, _cmd)
|
||||
{
|
||||
return ((___r1 = (self.isa.method_msgSend["alloc"] || _objj_forward)(self, "alloc")), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["init"] || _objj_forward)(___r1, "init"));
|
||||
var ___r1;
|
||||
}
|
||||
|
||||
,["id"])]);
|
||||
}
|
||||
p;16;CABackingStore.jt;1095;@STATIC;1.0;i;12;CGGeometry.ji;17;CPCompatibility.jt;1037;objj_executeFile("CGGeometry.j", YES);objj_executeFile("CPCompatibility.j", YES);CABackingStoreGetContext = function(aBackingStore)
|
||||
{
|
||||
return aBackingStore.context;
|
||||
@@ -51041,7 +51089,7 @@ class_addMethods(the_class, [new objj_method(sel_getUid("values"), function $CAK
|
||||
|
||||
,["id"])]);
|
||||
}
|
||||
p;9;CALayer.jt;35104;@STATIC;1.0;I;21;Foundation/CPObject.jI;22;Foundation/CPRunLoop.ji;16;CABackingStore.ji;11;CGContext.ji;12;CGGeometry.ji;9;CPColor.ji;8;CPView.jt;34952;objj_executeFile("Foundation/CPObject.j", NO);objj_executeFile("Foundation/CPRunLoop.j", NO);objj_executeFile("CABackingStore.j", YES);objj_executeFile("CGContext.j", YES);objj_executeFile("CGGeometry.j", YES);objj_executeFile("CPColor.j", YES);objj_executeFile("CPView.j", YES);var CALayerGeometryBoundsMask = 1,
|
||||
p;9;CALayer.jt;45341;@STATIC;1.0;I;21;Foundation/CPObject.jI;22;Foundation/CPRunLoop.ji;16;CABackingStore.ji;11;CGContext.ji;12;CGGeometry.ji;9;CPColor.ji;8;CPView.jt;45189;objj_executeFile("Foundation/CPObject.j", NO);objj_executeFile("Foundation/CPRunLoop.j", NO);objj_executeFile("CABackingStore.j", YES);objj_executeFile("CGContext.j", YES);objj_executeFile("CGGeometry.j", YES);objj_executeFile("CPColor.j", YES);objj_executeFile("CPView.j", YES);var CALayerGeometryBoundsMask = 1,
|
||||
CALayerGeometryPositionMask = 2,
|
||||
CALayerGeometryAnchorPointMask = 4,
|
||||
CALayerGeometryAffineTransformMask = 8,
|
||||
@@ -51056,7 +51104,7 @@ var CALayerFrameOriginUpdateMask = 1,
|
||||
var CALayerRegisteredRunLoopUpdates = nil;
|
||||
|
||||
{var the_class = objj_allocateClassPair(CPObject, "CALayer"),
|
||||
meta_class = the_class.isa;class_addIvars(the_class, [new objj_ivar("_frame", "CGRect"), new objj_ivar("_bounds", "CGRect"), new objj_ivar("_position", "CGPoint"), new objj_ivar("_zPosition", "unsigned"), new objj_ivar("_anchorPoint", "CGPoint"), new objj_ivar("_affineTransform", "CGAffineTransform"), new objj_ivar("_sublayerTransform", "CGAffineTransform"), new objj_ivar("_sublayerTransformForSublayers", "CGAffineTransform"), new objj_ivar("_backingStoreFrame", "CGRect"), new objj_ivar("_standardBackingStoreFrame", "CGRect"), new objj_ivar("_hasSublayerTransform", "BOOL"), new objj_ivar("_hasCustomBackingStoreFrame", "BOOL"), new objj_ivar("_opacity", "float"), new objj_ivar("_isHidden", "BOOL"), new objj_ivar("_masksToBounds", "BOOL"), new objj_ivar("_backgroundColor", "CPColor"), new objj_ivar("_superlayer", "CALayer"), new objj_ivar("_sublayers", "CPMutableArray"), new objj_ivar("_runLoopUpdateMask", "unsigned"), new objj_ivar("_needsDisplayOnBoundsChange", "BOOL"), new objj_ivar("_delegate", "id"), new objj_ivar("_delegateRespondsToDisplayLayerSelector", "BOOL"), new objj_ivar("_delegateRespondsToDrawLayerInContextSelector", "BOOL"), new objj_ivar("_DOMElement", "DOMElement"), new objj_ivar("_DOMContentsElement", "DOMElement"), new objj_ivar("_contents", "id"), new objj_ivar("_context", "CGContext"), new objj_ivar("_owningView", "CPView"), new objj_ivar("_transformToLayer", "CGAffineTransform"), new objj_ivar("_transformFromLayer", "CGAffineTransform")]);objj_registerClassPair(the_class);
|
||||
meta_class = the_class.isa;class_addIvars(the_class, [new objj_ivar("_frame", "CGRect"), new objj_ivar("_bounds", "CGRect"), new objj_ivar("_position", "CGPoint"), new objj_ivar("_zPosition", "unsigned"), new objj_ivar("_anchorPoint", "CGPoint"), new objj_ivar("_affineTransform", "CGAffineTransform"), new objj_ivar("_sublayerTransform", "CGAffineTransform"), new objj_ivar("_sublayerTransformForSublayers", "CGAffineTransform"), new objj_ivar("_backingStoreFrame", "CGRect"), new objj_ivar("_standardBackingStoreFrame", "CGRect"), new objj_ivar("_hasSublayerTransform", "BOOL"), new objj_ivar("_hasCustomBackingStoreFrame", "BOOL"), new objj_ivar("_opacity", "float"), new objj_ivar("_isHidden", "BOOL"), new objj_ivar("_masksToBounds", "BOOL"), new objj_ivar("_backgroundColor", "CPColor"), new objj_ivar("_superlayer", "CALayer"), new objj_ivar("_sublayers", "CPMutableArray"), new objj_ivar("_runLoopUpdateMask", "unsigned"), new objj_ivar("_needsDisplayOnBoundsChange", "BOOL"), new objj_ivar("_delegate", "id"), new objj_ivar("_delegateRespondsToDisplayLayerSelector", "BOOL"), new objj_ivar("_delegateRespondsToDrawLayerInContextSelector", "BOOL"), new objj_ivar("_DOMElement", "DOMElement"), new objj_ivar("_DOMContentsElement", "DOMElement"), new objj_ivar("_contents", "id"), new objj_ivar("_context", "CGContext"), new objj_ivar("_owningView", "CPView"), new objj_ivar("_transformToLayer", "CGAffineTransform"), new objj_ivar("_transformFromLayer", "CGAffineTransform"), new objj_ivar("_activeAnimations", "CPMutableDictionary")]);objj_registerClassPair(the_class);
|
||||
class_addMethods(the_class, [new objj_method(sel_getUid("init"), function $CALayer__init(self, _cmd)
|
||||
{
|
||||
self = (objj_getClass("CALayer").super_class.method_dtable["init"] || _objj_forward)(self, "init");
|
||||
@@ -51077,6 +51125,7 @@ class_addMethods(the_class, [new objj_method(sel_getUid("init"), function $CALay
|
||||
self._isHidden = NO;
|
||||
self._masksToBounds = NO;
|
||||
self._sublayers = [];
|
||||
self._activeAnimations = (CPMutableDictionary.isa.method_msgSend["dictionary"] || _objj_forward)(CPMutableDictionary, "dictionary");
|
||||
self._DOMElement = document.createElement("div");
|
||||
self._DOMElement.style.overflow = "visible";
|
||||
self._DOMElement.style.position = "absolute";
|
||||
@@ -51549,7 +51598,166 @@ class_addMethods(the_class, [new objj_method(sel_getUid("init"), function $CALay
|
||||
return self._delegate;
|
||||
}
|
||||
|
||||
,["id"]), new objj_method(sel_getUid("_setOwningView:"), function $CALayer___setOwningView_(self, _cmd, anOwningView)
|
||||
,["id"]), new objj_method(sel_getUid("addAnimation:forKey:"), function $CALayer__addAnimation_forKey_(self, _cmd, anim, key)
|
||||
{
|
||||
if (!anim)
|
||||
return;
|
||||
if ((anim == null ? anim : (anim.isa.method_msgSend["respondsToSelector:"] || _objj_forward)(anim, "respondsToSelector:", sel_getUid("animations"))) && (anim == null ? anim : (anim.isa.method_msgSend["animations"] || _objj_forward)(anim, "animations")))
|
||||
{
|
||||
var animations = (anim == null ? anim : (anim.isa.method_msgSend["animations"] || _objj_forward)(anim, "animations")),
|
||||
count = (animations == null ? animations : (animations.isa.method_msgSend["count"] || _objj_forward)(animations, "count")),
|
||||
i = 0;
|
||||
for (; i < count; i++)
|
||||
{
|
||||
var child = (animations == null ? animations : (animations.isa.method_msgSend["objectAtIndex:"] || _objj_forward)(animations, "objectAtIndex:", i));
|
||||
(self.isa.method_msgSend["addAnimation:forKey:"] || _objj_forward)(self, "addAnimation:forKey:", child, nil);
|
||||
}
|
||||
return;
|
||||
}
|
||||
var keyPath = key;
|
||||
if ((anim == null ? anim : (anim.isa.method_msgSend["respondsToSelector:"] || _objj_forward)(anim, "respondsToSelector:", sel_getUid("keyPath"))) && (anim == null ? anim : (anim.isa.method_msgSend["keyPath"] || _objj_forward)(anim, "keyPath")))
|
||||
keyPath = (anim == null ? anim : (anim.isa.method_msgSend["keyPath"] || _objj_forward)(anim, "keyPath"));
|
||||
if (!keyPath)
|
||||
return;
|
||||
var startValue = (anim == null ? anim : (anim.isa.method_msgSend["respondsToSelector:"] || _objj_forward)(anim, "respondsToSelector:", sel_getUid("fromValue"))) ? (anim == null ? anim : (anim.isa.method_msgSend["fromValue"] || _objj_forward)(anim, "fromValue")) : nil;
|
||||
if (startValue == nil)
|
||||
{
|
||||
try {
|
||||
startValue = (self.isa.method_msgSend["valueForKey:"] || _objj_forward)(self, "valueForKey:", keyPath);
|
||||
}
|
||||
catch(e) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
var endValue = (anim == null ? anim : (anim.isa.method_msgSend["respondsToSelector:"] || _objj_forward)(anim, "respondsToSelector:", sel_getUid("toValue"))) ? (anim == null ? anim : (anim.isa.method_msgSend["toValue"] || _objj_forward)(anim, "toValue")) : nil;
|
||||
if (endValue == nil)
|
||||
return;
|
||||
var duration = (anim == null ? anim : (anim.isa.method_msgSend["respondsToSelector:"] || _objj_forward)(anim, "respondsToSelector:", sel_getUid("duration"))) ? (anim == null ? anim : (anim.isa.method_msgSend["duration"] || _objj_forward)(anim, "duration")) : 0.25;
|
||||
var timingFunction = (anim == null ? anim : (anim.isa.method_msgSend["respondsToSelector:"] || _objj_forward)(anim, "respondsToSelector:", sel_getUid("timingFunction"))) ? (anim == null ? anim : (anim.isa.method_msgSend["timingFunction"] || _objj_forward)(anim, "timingFunction")) : (CAMediaTimingFunction == null ? CAMediaTimingFunction : (CAMediaTimingFunction.isa.method_msgSend["functionWithName:"] || _objj_forward)(CAMediaTimingFunction, "functionWithName:", kCAMediaTimingFunctionEaseInEaseOut));
|
||||
var context = {"animation": anim, "keyPath": keyPath, "startValue": startValue, "endValue": endValue, "duration": duration * 1000.0, "timingFunction": timingFunction, "startTime": null, "requestId": null};
|
||||
var _self = self;
|
||||
var renderLoop = function(timestamp)
|
||||
{
|
||||
if ((_self == null ? _self : (_self.isa.method_msgSend["_renderAnimationStep:timestamp:"] || _objj_forward)(_self, "_renderAnimationStep:timestamp:", context, timestamp)))
|
||||
context.requestId = window.requestAnimationFrame(renderLoop);
|
||||
else
|
||||
context.requestId = null;
|
||||
};
|
||||
var storageKey = key && key.length > 0 ? key : keyPath;
|
||||
(self.isa.method_msgSend["removeAnimationForKey:"] || _objj_forward)(self, "removeAnimationForKey:", storageKey);
|
||||
context.requestId = window.requestAnimationFrame(renderLoop);
|
||||
((___r1 = self._activeAnimations), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["setObject:forKey:"] || _objj_forward)(___r1, "setObject:forKey:", context, storageKey));
|
||||
var ___r1;
|
||||
}
|
||||
|
||||
,["void","CAAnimation","CPString"]), new objj_method(sel_getUid("removeAnimationForKey:"), function $CALayer__removeAnimationForKey_(self, _cmd, key)
|
||||
{
|
||||
var context = ((___r1 = self._activeAnimations), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["objectForKey:"] || _objj_forward)(___r1, "objectForKey:", key));
|
||||
if (context)
|
||||
{
|
||||
if (context.requestId !== null)
|
||||
window.cancelAnimationFrame(context.requestId);
|
||||
((___r1 = self._activeAnimations), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["removeObjectForKey:"] || _objj_forward)(___r1, "removeObjectForKey:", key));
|
||||
}
|
||||
var ___r1;
|
||||
}
|
||||
|
||||
,["void","CPString"]), new objj_method(sel_getUid("removeAllAnimations"), function $CALayer__removeAllAnimations(self, _cmd)
|
||||
{
|
||||
var keys = ((___r1 = self._activeAnimations), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["allKeys"] || _objj_forward)(___r1, "allKeys")),
|
||||
count = (keys == null ? keys : (keys.isa.method_msgSend["count"] || _objj_forward)(keys, "count"));
|
||||
while (count--)
|
||||
(self.isa.method_msgSend["removeAnimationForKey:"] || _objj_forward)(self, "removeAnimationForKey:", (keys == null ? keys : (keys.isa.method_msgSend["objectAtIndex:"] || _objj_forward)(keys, "objectAtIndex:", count)));
|
||||
var ___r1;
|
||||
}
|
||||
|
||||
,["void"]), new objj_method(sel_getUid("_solveBezier:forTimingFunction:"), function $CALayer___solveBezier_forTimingFunction_(self, _cmd, t, tf)
|
||||
{
|
||||
if (!tf)
|
||||
return t;
|
||||
if (tf === (CAMediaTimingFunction == null ? CAMediaTimingFunction : (CAMediaTimingFunction.isa.method_msgSend["functionWithName:"] || _objj_forward)(CAMediaTimingFunction, "functionWithName:", kCAMediaTimingFunctionLinear)))
|
||||
return t;
|
||||
var points = (tf == null ? tf : (tf.isa.method_msgSend["controlPoints"] || _objj_forward)(tf, "controlPoints"));
|
||||
var p1x = points[0],
|
||||
p1y = points[1],
|
||||
p2x = points[2],
|
||||
p2y = points[3];
|
||||
var cx = 3.0 * p1x;
|
||||
var bx = 3.0 * (p2x - p1x) - cx;
|
||||
var ax = 1.0 - cx - bx;
|
||||
var cy = 3.0 * p1y;
|
||||
var by = 3.0 * (p2y - p1y) - cy;
|
||||
var ay = 1.0 - cy - by;
|
||||
var sampleT = t;
|
||||
for (var i = 0; i < 5; i++)
|
||||
{
|
||||
var x = ((ax * sampleT + bx) * sampleT + cx) * sampleT - t;
|
||||
if (Math.abs(x) < 1e-3)
|
||||
break;
|
||||
var d = (3.0 * ax * sampleT + 2.0 * bx) * sampleT + cx;
|
||||
if (Math.abs(d) < 1e-6)
|
||||
break;
|
||||
sampleT = sampleT - x / d;
|
||||
}
|
||||
return ((ay * sampleT + by) * sampleT + cy) * sampleT;
|
||||
}
|
||||
|
||||
,["float","float","CAMediaTimingFunction"]), new objj_method(sel_getUid("_renderAnimationStep:timestamp:"), function $CALayer___renderAnimationStep_timestamp_(self, _cmd, context, timestamp)
|
||||
{
|
||||
if (context.startTime === null)
|
||||
context.startTime = timestamp;
|
||||
var elapsed = timestamp - context.startTime,
|
||||
linearProgress = elapsed / context.duration;
|
||||
if (linearProgress > 1.0)
|
||||
linearProgress = 1.0;
|
||||
var progress = (self.isa.method_msgSend["_solveBezier:forTimingFunction:"] || _objj_forward)(self, "_solveBezier:forTimingFunction:", linearProgress, context.timingFunction);
|
||||
var start = context.startValue,
|
||||
end = context.endValue,
|
||||
current = nil;
|
||||
if (typeof start === "number")
|
||||
{
|
||||
current = start + (end - start) * progress;
|
||||
}
|
||||
else if (start && start.x !== undefined && start.y !== undefined)
|
||||
{
|
||||
current = CGPointMake(start.x + (end.x - start.x) * progress, start.y + (end.y - start.y) * progress);
|
||||
}
|
||||
else if (start && start.width !== undefined && start.height !== undefined)
|
||||
{
|
||||
current = CGSizeMake(start.width + (end.width - start.width) * progress, start.height + (end.height - start.height) * progress);
|
||||
}
|
||||
else if (start && start.origin !== undefined && start.size !== undefined)
|
||||
{
|
||||
current = CGRectMake(start.origin.x + (end.origin.x - start.origin.x) * progress, start.origin.y + (end.origin.y - start.origin.y) * progress, start.size.width + (end.size.width - start.size.width) * progress, start.size.height + (end.size.height - start.size.height) * progress);
|
||||
}
|
||||
if (current !== nil)
|
||||
(self.isa.method_msgSend["setValue:forKey:"] || _objj_forward)(self, "setValue:forKey:", current, context.keyPath);
|
||||
if (linearProgress >= 1.0)
|
||||
{
|
||||
var anim = context.animation;
|
||||
var shouldRemove = (anim == null ? anim : (anim.isa.method_msgSend["respondsToSelector:"] || _objj_forward)(anim, "respondsToSelector:", sel_getUid("isRemovedOnCompletion"))) ? (anim == null ? anim : (anim.isa.method_msgSend["isRemovedOnCompletion"] || _objj_forward)(anim, "isRemovedOnCompletion")) : YES;
|
||||
if (shouldRemove)
|
||||
{
|
||||
var keys = ((___r1 = self._activeAnimations), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["allKeys"] || _objj_forward)(___r1, "allKeys"));
|
||||
for (var i = 0; i < keys.length; i++)
|
||||
{
|
||||
if (((___r1 = self._activeAnimations), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["objectForKey:"] || _objj_forward)(___r1, "objectForKey:", keys[i])) === context)
|
||||
{
|
||||
((___r1 = self._activeAnimations), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["removeObjectForKey:"] || _objj_forward)(___r1, "removeObjectForKey:", keys[i]));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
var delegate = (anim == null ? anim : (anim.isa.method_msgSend["delegate"] || _objj_forward)(anim, "delegate"));
|
||||
if (delegate && (delegate == null ? delegate : (delegate.isa.method_msgSend["respondsToSelector:"] || _objj_forward)(delegate, "respondsToSelector:", sel_getUid("animationDidStop:finished:"))))
|
||||
(delegate == null ? delegate : (delegate.isa.method_msgSend["animationDidStop:finished:"] || _objj_forward)(delegate, "animationDidStop:finished:", anim, YES));
|
||||
return NO;
|
||||
}
|
||||
return YES;
|
||||
var ___r1;
|
||||
}
|
||||
|
||||
,["BOOL","JSObject","double"]), new objj_method(sel_getUid("_setOwningView:"), function $CALayer___setOwningView_(self, _cmd, anOwningView)
|
||||
{
|
||||
self._owningView = anOwningView;
|
||||
if (self._owningView)
|
||||
|
||||
@@ -48825,6 +48825,54 @@ class_addMethods(meta_class, [new objj_method(sel_getUid("animation"), function
|
||||
|
||||
,["id","CPString"])]);
|
||||
}
|
||||
p;18;CAAnimationGroup.jt;2371;@STATIC;1.0;I;20;Foundation/CPArray.ji;13;CAAnimation.jt;2309;objj_executeFile("Foundation/CPArray.j", NO);objj_executeFile("CAAnimation.j", YES);
|
||||
{var the_class = objj_allocateClassPair(CAAnimation, "CAAnimationGroup"),
|
||||
meta_class = the_class.isa;class_addIvars(the_class, [new objj_ivar("_animations", "CPArray")]);objj_registerClassPair(the_class);
|
||||
class_addMethods(the_class, [new objj_method(sel_getUid("init"), function $CAAnimationGroup__init(self, _cmd)
|
||||
{
|
||||
if (self = (objj_getClass("CAAnimationGroup").super_class.method_dtable["init"] || _objj_forward)(self, "init"))
|
||||
{
|
||||
self._animations = [];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
,["id"]), new objj_method(sel_getUid("setAnimations:"), function $CAAnimationGroup__setAnimations_(self, _cmd, anArray)
|
||||
{
|
||||
if (self._animations === anArray)
|
||||
return;
|
||||
self._animations = anArray;
|
||||
}
|
||||
|
||||
,["void","CPArray"]), new objj_method(sel_getUid("animations"), function $CAAnimationGroup__animations(self, _cmd)
|
||||
{
|
||||
return self._animations;
|
||||
}
|
||||
|
||||
,["CPArray"]), new objj_method(sel_getUid("runActionForKey:object:arguments:"), function $CAAnimationGroup__runActionForKey_object_arguments_(self, _cmd, aKey, anObject, arguments)
|
||||
{
|
||||
var count = ((___r1 = self._animations), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["count"] || _objj_forward)(___r1, "count")),
|
||||
i = 0;
|
||||
for (; i < count; i++)
|
||||
{
|
||||
var animation = ((___r1 = self._animations), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["objectAtIndex:"] || _objj_forward)(___r1, "objectAtIndex:", i));
|
||||
if ((animation == null ? animation : (animation.isa.method_msgSend["respondsToSelector:"] || _objj_forward)(animation, "respondsToSelector:", sel_getUid("runActionForKey:object:arguments:"))))
|
||||
{
|
||||
(animation == null ? animation : (animation.isa.method_msgSend["runActionForKey:object:arguments:"] || _objj_forward)(animation, "runActionForKey:object:arguments:", aKey, anObject, arguments));
|
||||
}
|
||||
}
|
||||
var ___r1;
|
||||
}
|
||||
|
||||
,["void","CPString","id","CPDictionary"])]);
|
||||
class_addMethods(meta_class, [new objj_method(sel_getUid("group"), function $CAAnimationGroup__group(self, _cmd)
|
||||
{
|
||||
return ((___r1 = (self.isa.method_msgSend["alloc"] || _objj_forward)(self, "alloc")), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["init"] || _objj_forward)(___r1, "init"));
|
||||
var ___r1;
|
||||
}
|
||||
|
||||
,["id"])]);
|
||||
}
|
||||
p;16;CABackingStore.jt;1095;@STATIC;1.0;i;12;CGGeometry.ji;17;CPCompatibility.jt;1037;objj_executeFile("CGGeometry.j", YES);objj_executeFile("CPCompatibility.j", YES);CABackingStoreGetContext = function(aBackingStore)
|
||||
{
|
||||
return aBackingStore.context;
|
||||
@@ -49019,7 +49067,7 @@ class_addMethods(the_class, [new objj_method(sel_getUid("values"), function $CAK
|
||||
|
||||
,["id"])]);
|
||||
}
|
||||
p;9;CALayer.jt;31832;@STATIC;1.0;I;21;Foundation/CPObject.jI;22;Foundation/CPRunLoop.ji;16;CABackingStore.ji;11;CGContext.ji;12;CGGeometry.ji;9;CPColor.ji;8;CPView.jt;31680;objj_executeFile("Foundation/CPObject.j", NO);objj_executeFile("Foundation/CPRunLoop.j", NO);objj_executeFile("CABackingStore.j", YES);objj_executeFile("CGContext.j", YES);objj_executeFile("CGGeometry.j", YES);objj_executeFile("CPColor.j", YES);objj_executeFile("CPView.j", YES);var CALayerGeometryBoundsMask = 1,
|
||||
p;9;CALayer.jt;42069;@STATIC;1.0;I;21;Foundation/CPObject.jI;22;Foundation/CPRunLoop.ji;16;CABackingStore.ji;11;CGContext.ji;12;CGGeometry.ji;9;CPColor.ji;8;CPView.jt;41917;objj_executeFile("Foundation/CPObject.j", NO);objj_executeFile("Foundation/CPRunLoop.j", NO);objj_executeFile("CABackingStore.j", YES);objj_executeFile("CGContext.j", YES);objj_executeFile("CGGeometry.j", YES);objj_executeFile("CPColor.j", YES);objj_executeFile("CPView.j", YES);var CALayerGeometryBoundsMask = 1,
|
||||
CALayerGeometryPositionMask = 2,
|
||||
CALayerGeometryAnchorPointMask = 4,
|
||||
CALayerGeometryAffineTransformMask = 8,
|
||||
@@ -49034,7 +49082,7 @@ var CALayerFrameOriginUpdateMask = 1,
|
||||
var CALayerRegisteredRunLoopUpdates = nil;
|
||||
|
||||
{var the_class = objj_allocateClassPair(CPObject, "CALayer"),
|
||||
meta_class = the_class.isa;class_addIvars(the_class, [new objj_ivar("_frame", "CGRect"), new objj_ivar("_bounds", "CGRect"), new objj_ivar("_position", "CGPoint"), new objj_ivar("_zPosition", "unsigned"), new objj_ivar("_anchorPoint", "CGPoint"), new objj_ivar("_affineTransform", "CGAffineTransform"), new objj_ivar("_sublayerTransform", "CGAffineTransform"), new objj_ivar("_sublayerTransformForSublayers", "CGAffineTransform"), new objj_ivar("_backingStoreFrame", "CGRect"), new objj_ivar("_standardBackingStoreFrame", "CGRect"), new objj_ivar("_hasSublayerTransform", "BOOL"), new objj_ivar("_hasCustomBackingStoreFrame", "BOOL"), new objj_ivar("_opacity", "float"), new objj_ivar("_isHidden", "BOOL"), new objj_ivar("_masksToBounds", "BOOL"), new objj_ivar("_backgroundColor", "CPColor"), new objj_ivar("_superlayer", "CALayer"), new objj_ivar("_sublayers", "CPMutableArray"), new objj_ivar("_runLoopUpdateMask", "unsigned"), new objj_ivar("_needsDisplayOnBoundsChange", "BOOL"), new objj_ivar("_delegate", "id"), new objj_ivar("_delegateRespondsToDisplayLayerSelector", "BOOL"), new objj_ivar("_delegateRespondsToDrawLayerInContextSelector", "BOOL"), new objj_ivar("_DOMElement", "DOMElement"), new objj_ivar("_DOMContentsElement", "DOMElement"), new objj_ivar("_contents", "id"), new objj_ivar("_context", "CGContext"), new objj_ivar("_owningView", "CPView"), new objj_ivar("_transformToLayer", "CGAffineTransform"), new objj_ivar("_transformFromLayer", "CGAffineTransform")]);objj_registerClassPair(the_class);
|
||||
meta_class = the_class.isa;class_addIvars(the_class, [new objj_ivar("_frame", "CGRect"), new objj_ivar("_bounds", "CGRect"), new objj_ivar("_position", "CGPoint"), new objj_ivar("_zPosition", "unsigned"), new objj_ivar("_anchorPoint", "CGPoint"), new objj_ivar("_affineTransform", "CGAffineTransform"), new objj_ivar("_sublayerTransform", "CGAffineTransform"), new objj_ivar("_sublayerTransformForSublayers", "CGAffineTransform"), new objj_ivar("_backingStoreFrame", "CGRect"), new objj_ivar("_standardBackingStoreFrame", "CGRect"), new objj_ivar("_hasSublayerTransform", "BOOL"), new objj_ivar("_hasCustomBackingStoreFrame", "BOOL"), new objj_ivar("_opacity", "float"), new objj_ivar("_isHidden", "BOOL"), new objj_ivar("_masksToBounds", "BOOL"), new objj_ivar("_backgroundColor", "CPColor"), new objj_ivar("_superlayer", "CALayer"), new objj_ivar("_sublayers", "CPMutableArray"), new objj_ivar("_runLoopUpdateMask", "unsigned"), new objj_ivar("_needsDisplayOnBoundsChange", "BOOL"), new objj_ivar("_delegate", "id"), new objj_ivar("_delegateRespondsToDisplayLayerSelector", "BOOL"), new objj_ivar("_delegateRespondsToDrawLayerInContextSelector", "BOOL"), new objj_ivar("_DOMElement", "DOMElement"), new objj_ivar("_DOMContentsElement", "DOMElement"), new objj_ivar("_contents", "id"), new objj_ivar("_context", "CGContext"), new objj_ivar("_owningView", "CPView"), new objj_ivar("_transformToLayer", "CGAffineTransform"), new objj_ivar("_transformFromLayer", "CGAffineTransform"), new objj_ivar("_activeAnimations", "CPMutableDictionary")]);objj_registerClassPair(the_class);
|
||||
class_addMethods(the_class, [new objj_method(sel_getUid("init"), function $CALayer__init(self, _cmd)
|
||||
{
|
||||
self = (objj_getClass("CALayer").super_class.method_dtable["init"] || _objj_forward)(self, "init");
|
||||
@@ -49055,6 +49103,7 @@ class_addMethods(the_class, [new objj_method(sel_getUid("init"), function $CALay
|
||||
self._isHidden = NO;
|
||||
self._masksToBounds = NO;
|
||||
self._sublayers = [];
|
||||
self._activeAnimations = (CPMutableDictionary.isa.method_msgSend["dictionary"] || _objj_forward)(CPMutableDictionary, "dictionary");
|
||||
}
|
||||
return self;
|
||||
}
|
||||
@@ -49486,7 +49535,166 @@ class_addMethods(the_class, [new objj_method(sel_getUid("init"), function $CALay
|
||||
return self._delegate;
|
||||
}
|
||||
|
||||
,["id"]), new objj_method(sel_getUid("_setOwningView:"), function $CALayer___setOwningView_(self, _cmd, anOwningView)
|
||||
,["id"]), new objj_method(sel_getUid("addAnimation:forKey:"), function $CALayer__addAnimation_forKey_(self, _cmd, anim, key)
|
||||
{
|
||||
if (!anim)
|
||||
return;
|
||||
if ((anim == null ? anim : (anim.isa.method_msgSend["respondsToSelector:"] || _objj_forward)(anim, "respondsToSelector:", sel_getUid("animations"))) && (anim == null ? anim : (anim.isa.method_msgSend["animations"] || _objj_forward)(anim, "animations")))
|
||||
{
|
||||
var animations = (anim == null ? anim : (anim.isa.method_msgSend["animations"] || _objj_forward)(anim, "animations")),
|
||||
count = (animations == null ? animations : (animations.isa.method_msgSend["count"] || _objj_forward)(animations, "count")),
|
||||
i = 0;
|
||||
for (; i < count; i++)
|
||||
{
|
||||
var child = (animations == null ? animations : (animations.isa.method_msgSend["objectAtIndex:"] || _objj_forward)(animations, "objectAtIndex:", i));
|
||||
(self.isa.method_msgSend["addAnimation:forKey:"] || _objj_forward)(self, "addAnimation:forKey:", child, nil);
|
||||
}
|
||||
return;
|
||||
}
|
||||
var keyPath = key;
|
||||
if ((anim == null ? anim : (anim.isa.method_msgSend["respondsToSelector:"] || _objj_forward)(anim, "respondsToSelector:", sel_getUid("keyPath"))) && (anim == null ? anim : (anim.isa.method_msgSend["keyPath"] || _objj_forward)(anim, "keyPath")))
|
||||
keyPath = (anim == null ? anim : (anim.isa.method_msgSend["keyPath"] || _objj_forward)(anim, "keyPath"));
|
||||
if (!keyPath)
|
||||
return;
|
||||
var startValue = (anim == null ? anim : (anim.isa.method_msgSend["respondsToSelector:"] || _objj_forward)(anim, "respondsToSelector:", sel_getUid("fromValue"))) ? (anim == null ? anim : (anim.isa.method_msgSend["fromValue"] || _objj_forward)(anim, "fromValue")) : nil;
|
||||
if (startValue == nil)
|
||||
{
|
||||
try {
|
||||
startValue = (self.isa.method_msgSend["valueForKey:"] || _objj_forward)(self, "valueForKey:", keyPath);
|
||||
}
|
||||
catch(e) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
var endValue = (anim == null ? anim : (anim.isa.method_msgSend["respondsToSelector:"] || _objj_forward)(anim, "respondsToSelector:", sel_getUid("toValue"))) ? (anim == null ? anim : (anim.isa.method_msgSend["toValue"] || _objj_forward)(anim, "toValue")) : nil;
|
||||
if (endValue == nil)
|
||||
return;
|
||||
var duration = (anim == null ? anim : (anim.isa.method_msgSend["respondsToSelector:"] || _objj_forward)(anim, "respondsToSelector:", sel_getUid("duration"))) ? (anim == null ? anim : (anim.isa.method_msgSend["duration"] || _objj_forward)(anim, "duration")) : 0.25;
|
||||
var timingFunction = (anim == null ? anim : (anim.isa.method_msgSend["respondsToSelector:"] || _objj_forward)(anim, "respondsToSelector:", sel_getUid("timingFunction"))) ? (anim == null ? anim : (anim.isa.method_msgSend["timingFunction"] || _objj_forward)(anim, "timingFunction")) : (CAMediaTimingFunction == null ? CAMediaTimingFunction : (CAMediaTimingFunction.isa.method_msgSend["functionWithName:"] || _objj_forward)(CAMediaTimingFunction, "functionWithName:", kCAMediaTimingFunctionEaseInEaseOut));
|
||||
var context = {"animation": anim, "keyPath": keyPath, "startValue": startValue, "endValue": endValue, "duration": duration * 1000.0, "timingFunction": timingFunction, "startTime": null, "requestId": null};
|
||||
var _self = self;
|
||||
var renderLoop = function(timestamp)
|
||||
{
|
||||
if ((_self == null ? _self : (_self.isa.method_msgSend["_renderAnimationStep:timestamp:"] || _objj_forward)(_self, "_renderAnimationStep:timestamp:", context, timestamp)))
|
||||
context.requestId = window.requestAnimationFrame(renderLoop);
|
||||
else
|
||||
context.requestId = null;
|
||||
};
|
||||
var storageKey = key && key.length > 0 ? key : keyPath;
|
||||
(self.isa.method_msgSend["removeAnimationForKey:"] || _objj_forward)(self, "removeAnimationForKey:", storageKey);
|
||||
context.requestId = window.requestAnimationFrame(renderLoop);
|
||||
((___r1 = self._activeAnimations), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["setObject:forKey:"] || _objj_forward)(___r1, "setObject:forKey:", context, storageKey));
|
||||
var ___r1;
|
||||
}
|
||||
|
||||
,["void","CAAnimation","CPString"]), new objj_method(sel_getUid("removeAnimationForKey:"), function $CALayer__removeAnimationForKey_(self, _cmd, key)
|
||||
{
|
||||
var context = ((___r1 = self._activeAnimations), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["objectForKey:"] || _objj_forward)(___r1, "objectForKey:", key));
|
||||
if (context)
|
||||
{
|
||||
if (context.requestId !== null)
|
||||
window.cancelAnimationFrame(context.requestId);
|
||||
((___r1 = self._activeAnimations), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["removeObjectForKey:"] || _objj_forward)(___r1, "removeObjectForKey:", key));
|
||||
}
|
||||
var ___r1;
|
||||
}
|
||||
|
||||
,["void","CPString"]), new objj_method(sel_getUid("removeAllAnimations"), function $CALayer__removeAllAnimations(self, _cmd)
|
||||
{
|
||||
var keys = ((___r1 = self._activeAnimations), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["allKeys"] || _objj_forward)(___r1, "allKeys")),
|
||||
count = (keys == null ? keys : (keys.isa.method_msgSend["count"] || _objj_forward)(keys, "count"));
|
||||
while (count--)
|
||||
(self.isa.method_msgSend["removeAnimationForKey:"] || _objj_forward)(self, "removeAnimationForKey:", (keys == null ? keys : (keys.isa.method_msgSend["objectAtIndex:"] || _objj_forward)(keys, "objectAtIndex:", count)));
|
||||
var ___r1;
|
||||
}
|
||||
|
||||
,["void"]), new objj_method(sel_getUid("_solveBezier:forTimingFunction:"), function $CALayer___solveBezier_forTimingFunction_(self, _cmd, t, tf)
|
||||
{
|
||||
if (!tf)
|
||||
return t;
|
||||
if (tf === (CAMediaTimingFunction == null ? CAMediaTimingFunction : (CAMediaTimingFunction.isa.method_msgSend["functionWithName:"] || _objj_forward)(CAMediaTimingFunction, "functionWithName:", kCAMediaTimingFunctionLinear)))
|
||||
return t;
|
||||
var points = (tf == null ? tf : (tf.isa.method_msgSend["controlPoints"] || _objj_forward)(tf, "controlPoints"));
|
||||
var p1x = points[0],
|
||||
p1y = points[1],
|
||||
p2x = points[2],
|
||||
p2y = points[3];
|
||||
var cx = 3.0 * p1x;
|
||||
var bx = 3.0 * (p2x - p1x) - cx;
|
||||
var ax = 1.0 - cx - bx;
|
||||
var cy = 3.0 * p1y;
|
||||
var by = 3.0 * (p2y - p1y) - cy;
|
||||
var ay = 1.0 - cy - by;
|
||||
var sampleT = t;
|
||||
for (var i = 0; i < 5; i++)
|
||||
{
|
||||
var x = ((ax * sampleT + bx) * sampleT + cx) * sampleT - t;
|
||||
if (Math.abs(x) < 1e-3)
|
||||
break;
|
||||
var d = (3.0 * ax * sampleT + 2.0 * bx) * sampleT + cx;
|
||||
if (Math.abs(d) < 1e-6)
|
||||
break;
|
||||
sampleT = sampleT - x / d;
|
||||
}
|
||||
return ((ay * sampleT + by) * sampleT + cy) * sampleT;
|
||||
}
|
||||
|
||||
,["float","float","CAMediaTimingFunction"]), new objj_method(sel_getUid("_renderAnimationStep:timestamp:"), function $CALayer___renderAnimationStep_timestamp_(self, _cmd, context, timestamp)
|
||||
{
|
||||
if (context.startTime === null)
|
||||
context.startTime = timestamp;
|
||||
var elapsed = timestamp - context.startTime,
|
||||
linearProgress = elapsed / context.duration;
|
||||
if (linearProgress > 1.0)
|
||||
linearProgress = 1.0;
|
||||
var progress = (self.isa.method_msgSend["_solveBezier:forTimingFunction:"] || _objj_forward)(self, "_solveBezier:forTimingFunction:", linearProgress, context.timingFunction);
|
||||
var start = context.startValue,
|
||||
end = context.endValue,
|
||||
current = nil;
|
||||
if (typeof start === "number")
|
||||
{
|
||||
current = start + (end - start) * progress;
|
||||
}
|
||||
else if (start && start.x !== undefined && start.y !== undefined)
|
||||
{
|
||||
current = CGPointMake(start.x + (end.x - start.x) * progress, start.y + (end.y - start.y) * progress);
|
||||
}
|
||||
else if (start && start.width !== undefined && start.height !== undefined)
|
||||
{
|
||||
current = CGSizeMake(start.width + (end.width - start.width) * progress, start.height + (end.height - start.height) * progress);
|
||||
}
|
||||
else if (start && start.origin !== undefined && start.size !== undefined)
|
||||
{
|
||||
current = CGRectMake(start.origin.x + (end.origin.x - start.origin.x) * progress, start.origin.y + (end.origin.y - start.origin.y) * progress, start.size.width + (end.size.width - start.size.width) * progress, start.size.height + (end.size.height - start.size.height) * progress);
|
||||
}
|
||||
if (current !== nil)
|
||||
(self.isa.method_msgSend["setValue:forKey:"] || _objj_forward)(self, "setValue:forKey:", current, context.keyPath);
|
||||
if (linearProgress >= 1.0)
|
||||
{
|
||||
var anim = context.animation;
|
||||
var shouldRemove = (anim == null ? anim : (anim.isa.method_msgSend["respondsToSelector:"] || _objj_forward)(anim, "respondsToSelector:", sel_getUid("isRemovedOnCompletion"))) ? (anim == null ? anim : (anim.isa.method_msgSend["isRemovedOnCompletion"] || _objj_forward)(anim, "isRemovedOnCompletion")) : YES;
|
||||
if (shouldRemove)
|
||||
{
|
||||
var keys = ((___r1 = self._activeAnimations), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["allKeys"] || _objj_forward)(___r1, "allKeys"));
|
||||
for (var i = 0; i < keys.length; i++)
|
||||
{
|
||||
if (((___r1 = self._activeAnimations), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["objectForKey:"] || _objj_forward)(___r1, "objectForKey:", keys[i])) === context)
|
||||
{
|
||||
((___r1 = self._activeAnimations), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["removeObjectForKey:"] || _objj_forward)(___r1, "removeObjectForKey:", keys[i]));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
var delegate = (anim == null ? anim : (anim.isa.method_msgSend["delegate"] || _objj_forward)(anim, "delegate"));
|
||||
if (delegate && (delegate == null ? delegate : (delegate.isa.method_msgSend["respondsToSelector:"] || _objj_forward)(delegate, "respondsToSelector:", sel_getUid("animationDidStop:finished:"))))
|
||||
(delegate == null ? delegate : (delegate.isa.method_msgSend["animationDidStop:finished:"] || _objj_forward)(delegate, "animationDidStop:finished:", anim, YES));
|
||||
return NO;
|
||||
}
|
||||
return YES;
|
||||
var ___r1;
|
||||
}
|
||||
|
||||
,["BOOL","JSObject","double"]), new objj_method(sel_getUid("_setOwningView:"), function $CALayer___setOwningView_(self, _cmd, anOwningView)
|
||||
{
|
||||
self._owningView = anOwningView;
|
||||
if (self._owningView)
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
@import <Foundation/Foundation.j>
|
||||
@import <AppKit/AppKit.j>
|
||||
@import <AppKit/CAKeyframeAnimation.j>
|
||||
@import <AppKit/CAAnimationGroup.j>
|
||||
|
||||
#define UIAssert(a) [self markTest:_cmd didPass:a];
|
||||
|
||||
@@ -403,6 +404,252 @@
|
||||
[CPAnimationContext endGrouping];
|
||||
}
|
||||
|
||||
- (void)testGroupAnimation:(id)sender
|
||||
{
|
||||
// Reset state
|
||||
[_testView setFrame:_initialTestViewFrame];
|
||||
[_testView setAlphaValue:1.0];
|
||||
[_pathView setPath:nil]; // Clear the path view as we aren't using it here
|
||||
|
||||
// FIX: Ensure the view is layer-backed.
|
||||
// Without this, [_testView layer] returns nil.
|
||||
[_testView setWantsLayer:YES];
|
||||
|
||||
var layer = [_testView layer];
|
||||
|
||||
// 1. Define the start and end positions
|
||||
// CALayer 'position' corresponds to the center of the view (anchorPoint 0.5,0.5)
|
||||
var startPos = [layer position];
|
||||
|
||||
// Safety check in case layer creation failed (though setWantsLayer:YES should ensure it)
|
||||
if (!startPos) startPos = CGPointMake(0,0);
|
||||
|
||||
var endPos = CGPointMake(startPos.x + 150, startPos.y + 50);
|
||||
|
||||
// 2. Create a Position Animation
|
||||
var moveAnim = [CABasicAnimation animationWithKeyPath:@"position"];
|
||||
[moveAnim setFromValue:startPos];
|
||||
[moveAnim setToValue:endPos];
|
||||
[moveAnim setDuration:1.0];
|
||||
|
||||
// 3. Create an Opacity Animation
|
||||
var fadeAnim = [CABasicAnimation animationWithKeyPath:@"opacity"];
|
||||
[fadeAnim setFromValue:1.0];
|
||||
[fadeAnim setToValue:0.25];
|
||||
[fadeAnim setDuration:1.0];
|
||||
|
||||
// 4. Group them
|
||||
// This tests the recursive logic in CAAnimationGroup and the timer logic in CALayer
|
||||
var group = [CAAnimationGroup group];
|
||||
[group setAnimations:[moveAnim, fadeAnim]];
|
||||
[group setDuration:1.0];
|
||||
|
||||
// 5. Run the animation on the layer
|
||||
[layer addAnimation:group forKey:@"groupTest"];
|
||||
|
||||
// 6. Verify results after the animation completes (1.0s duration + 0.1s buffer)
|
||||
[self performSelector:@selector(_verifyGroupAnimation:) withObject:endPos afterDelay:1.1];
|
||||
}
|
||||
|
||||
- (void)_verifyGroupAnimation:(CGPoint)expectedPos
|
||||
{
|
||||
var layer = [_testView layer],
|
||||
currentPos = [layer position],
|
||||
currentOpacity = [layer opacity];
|
||||
|
||||
// Allow for small floating point differences
|
||||
var posPassed = (Math.abs(currentPos.x - expectedPos.x) < 1.0 && Math.abs(currentPos.y - expectedPos.y) < 1.0);
|
||||
var opacityPassed = (Math.abs(currentOpacity - 0.25) < 0.05);
|
||||
|
||||
[self markTest:@selector(testGroupAnimation:) didPass:(posPassed && opacityPassed)];
|
||||
|
||||
// Reset for next test
|
||||
[self performSelector:@selector(cleanupAfterAnimation) withObject:nil afterDelay:0.5];
|
||||
}
|
||||
|
||||
- (void)testManualRotation:(id)sender
|
||||
{
|
||||
// 1. Cleanup previous test view
|
||||
if (_testView)
|
||||
[_testView removeFromSuperview];
|
||||
|
||||
// 2. Setup the RotatableView
|
||||
// View is 100x100, but the blue box drawn inside is 70x70 to allow room to spin.
|
||||
var frame = CGRectMake(390, 450, 100, 100);
|
||||
_testView = [[RotatableView alloc] initWithFrame:frame];
|
||||
[[theWindow contentView] addSubview:_testView];
|
||||
|
||||
// Ensure layer-backed so we have a layer to animate
|
||||
[_testView setWantsLayer:YES];
|
||||
|
||||
var layer = [_testView layer];
|
||||
[layer setDelegate:_testView];
|
||||
|
||||
// 3. Define the Animation
|
||||
var rotationAnim = [CABasicAnimation animationWithKeyPath:@"angle"];
|
||||
|
||||
// Rotate 360 degrees (2 * PI)
|
||||
[rotationAnim setFromValue:0.0];
|
||||
[rotationAnim setToValue:2 * PI];
|
||||
[rotationAnim setDuration:2.0];
|
||||
|
||||
// Use an easing function for smooth start/stop
|
||||
[rotationAnim setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];
|
||||
|
||||
// 4. Add to Layer
|
||||
[layer addAnimation:rotationAnim forKey:@"rotateTest"];
|
||||
|
||||
// 5. Verify results after animation
|
||||
[self performSelector:@selector(_verifyRotation:) withObject:nil afterDelay:2.1];
|
||||
}
|
||||
|
||||
- (void)_verifyRotation:(id)sender
|
||||
{
|
||||
var layer = [_testView layer];
|
||||
var endAngle = [layer angle];
|
||||
|
||||
// Check if we reached approx 2*PI (6.28)
|
||||
var passed = (Math.abs(endAngle - (2 * PI)) < 0.1);
|
||||
|
||||
[self markTest:@selector(testManualRotation:) didPass:passed];
|
||||
|
||||
// Reset view
|
||||
[self performSelector:@selector(cleanupAfterAnimation) withObject:nil afterDelay:0.5];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
/*
|
||||
A custom view that draws a box with a line in it.
|
||||
We draw the box smaller than the view bounds to prevent clipping during rotation.
|
||||
*/
|
||||
@implementation RotatableView : CPView
|
||||
{
|
||||
float _angle;
|
||||
}
|
||||
|
||||
- (void)initWithFrame:(CGRect)aFrame
|
||||
{
|
||||
self = [super initWithFrame:aFrame];
|
||||
_angle = 0;
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)setAngle:(float)anAngle
|
||||
{
|
||||
_angle = anAngle;
|
||||
[self display];
|
||||
}
|
||||
|
||||
- (float)angle
|
||||
{
|
||||
return _angle;
|
||||
}
|
||||
|
||||
- (void)drawRect:(CGRect)aRect
|
||||
{
|
||||
var context = [[CPGraphicsContext currentContext] graphicsPort],
|
||||
bounds = [self bounds],
|
||||
cx = CGRectGetWidth(bounds) / 2.0,
|
||||
cy = CGRectGetHeight(bounds) / 2.0;
|
||||
|
||||
// 1. Clear Context
|
||||
CGContextClearRect(context, bounds);
|
||||
|
||||
// 2. Precompute Trig
|
||||
var cosA = Math.cos(_angle),
|
||||
sinA = Math.sin(_angle);
|
||||
|
||||
/*
|
||||
Helper closure to transform a local point (x,y) relative to center
|
||||
into global view coordinates.
|
||||
*/
|
||||
var getPoint = function(localX, localY)
|
||||
{
|
||||
// Rotation Matrix:
|
||||
// x' = x*cos - y*sin
|
||||
// y' = x*sin + y*cos
|
||||
var rotX = localX * cosA - localY * sinA;
|
||||
var rotY = localX * sinA + localY * cosA;
|
||||
|
||||
// Translate back to view center
|
||||
return CGPointMake(cx + rotX, cy + rotY);
|
||||
};
|
||||
|
||||
// --- DRAW BLUE SQUARE (70x70) ---
|
||||
var s = 35.0; // half size
|
||||
|
||||
// Calculate the 4 corners manually
|
||||
var p1 = getPoint(-s, -s); // Top-Left
|
||||
var p2 = getPoint( s, -s); // Top-Right
|
||||
var p3 = getPoint( s, s); // Bottom-Right
|
||||
var p4 = getPoint(-s, s); // Bottom-Left
|
||||
|
||||
CGContextBeginPath(context);
|
||||
CGContextMoveToPoint(context, p1.x, p1.y);
|
||||
CGContextAddLineToPoint(context, p2.x, p2.y);
|
||||
CGContextAddLineToPoint(context, p3.x, p3.y);
|
||||
CGContextAddLineToPoint(context, p4.x, p4.y);
|
||||
CGContextClosePath(context);
|
||||
|
||||
[[CPColor greenColor] setFill];
|
||||
CGContextFillPath(context);
|
||||
|
||||
// --- DRAW RED MARKER (Top-Left Corner) ---
|
||||
// A 20x20 square in the top-left of the blue box
|
||||
// Local coords relative to center: x from -35 to -15, y from -35 to -15
|
||||
var r1 = getPoint(-35, -35);
|
||||
var r2 = getPoint(-15, -35);
|
||||
var r3 = getPoint(-15, -15);
|
||||
var r4 = getPoint(-35, -15);
|
||||
|
||||
CGContextBeginPath(context);
|
||||
CGContextMoveToPoint(context, r1.x, r1.y);
|
||||
CGContextAddLineToPoint(context, r2.x, r2.y);
|
||||
CGContextAddLineToPoint(context, r3.x, r3.y);
|
||||
CGContextAddLineToPoint(context, r4.x, r4.y);
|
||||
CGContextClosePath(context);
|
||||
|
||||
[[CPColor redColor] setFill];
|
||||
CGContextFillPath(context);
|
||||
|
||||
// --- DRAW WHITE POINTER LINE ---
|
||||
// Line from Center (0,0) to Right Edge (35, 0)
|
||||
var lineStart = getPoint(0, 0);
|
||||
var lineEnd = getPoint(35, 0);
|
||||
|
||||
CGContextBeginPath(context);
|
||||
CGContextMoveToPoint(context, lineStart.x, lineStart.y);
|
||||
CGContextAddLineToPoint(context, lineEnd.x, lineEnd.y);
|
||||
|
||||
[[CPColor whiteColor] setStroke];
|
||||
CGContextSetLineWidth(context, 3.0);
|
||||
CGContextStrokePath(context);
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
/*
|
||||
Category to allow CALayer to drive the 'angle' property on the view.
|
||||
*/
|
||||
@implementation CALayer (RotationTest)
|
||||
|
||||
- (void)setAngle:(float)anAngle
|
||||
{
|
||||
// Store it so [self valueForKey:@"angle"] works for animation start values
|
||||
self._angle = anAngle;
|
||||
|
||||
// Forward the value to the View (the layer's delegate) to trigger drawRect
|
||||
if (_delegate && [_delegate respondsToSelector:@selector(setAngle:)])
|
||||
[_delegate setAngle:anAngle];
|
||||
}
|
||||
|
||||
- (float)angle
|
||||
{
|
||||
return self._angle || 0.0;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
var unCamelCase = function(aString)
|
||||
|
||||
+143
-143
@@ -1,143 +1,143 @@
|
||||
1768805468896|ArrayController1|
|
||||
1768805468910|ArrayControllerInitialSelectionTest|
|
||||
1768805468923|ArrayControllerRemovingFirstTest|
|
||||
1768805468937|AttachedSheet|
|
||||
1768805468951|AttachedSheet2|
|
||||
1768805468964|Bindings|
|
||||
1768805468977|CGCanvasContext|
|
||||
1768805468991|CGPath|
|
||||
1768805469004|CPAlertTest|
|
||||
1768805469017|CPAnimatablePropertyContainerTest|
|
||||
1768805469031|CPAnimationContextTest|
|
||||
1768805469044|CPAnimationTest|
|
||||
1768805469057|CPBinder-echo-bug|
|
||||
1768805469070|CPBoxCibTest|
|
||||
1768805469084|CPBoxTest|
|
||||
1768805469097|CPBrowserTest|
|
||||
1768805469111|CPButtonKeyEquivalentDefaultTest|
|
||||
1768805469125|CPButtonTest|
|
||||
1768805469138|CPByteCountFormatter|
|
||||
1768805469151|CPCollectionViewNibTest|
|
||||
1768805469165|CPColor-CPImage-description|
|
||||
1768805469178|CPColorWellBindings|
|
||||
1768805469192|CPComboBoxTest|
|
||||
1768805469205|CPControlPerformClickExceptionTest|
|
||||
1768805469219|CPControlSize|
|
||||
1768805469232|CPCursor|
|
||||
1768805469245|CPDateFormatterTest|
|
||||
1768805469259|CPDatePickerTest|
|
||||
1768805469272|CPDictionaryControllerTest|
|
||||
1768805469285|CPDocumentControllerTest|
|
||||
1768805469299|CPFormatterTest|
|
||||
1768805469312|CPGraphicsTest|
|
||||
1768805469325|CPImageAndTextViewImageScaling|
|
||||
1768805469339|CPImageViewAlignmentScaling|
|
||||
1768805469352|CPImageViewTest|
|
||||
1768805469365|CPImageViewbindingsTest|
|
||||
1768805469378|CPLevelIndicator|
|
||||
1768805469392|CPLocalizationTest|
|
||||
1768805469405|CPLogTest|
|
||||
1768805469418|CPMenuCALayerTest|
|
||||
1768805469431|CPMenuEnabledBindingsTest|
|
||||
1768805469445|CPMenuKeyEquivalents|
|
||||
1768805469458|CPMenuRemoveAllTest|
|
||||
1768805469471|CPMenuSubmenuPlacementConstraints|
|
||||
1768805469485|CPMenuTest|
|
||||
1768805469498|CPOutlineViewCibTest|
|
||||
1768805469511|CPOutlineViewTest|
|
||||
1768805469525|CPOutlineViewViewBasedCibTest|
|
||||
1768805469538|CPPanelTest|
|
||||
1768805469551|CPPlatformWindow|
|
||||
1768805469564|CPPlattformWindowMinSize|
|
||||
1768805469577|CPPopUpButtonBindings|
|
||||
1768805469591|CPPopUpButtonTest|
|
||||
1768805469604|CPPopover|
|
||||
1768805469617|CPPredicateEditorCibTest|
|
||||
1768805469630|CPProgressIndicator|
|
||||
1768805469644|CPPropertyListSerializationTest|
|
||||
1768805469657|CPRadioBindings|
|
||||
1768805469670|CPRuleEditorCibTest|
|
||||
1768805469684|CPScrollView|
|
||||
1768805469697|CPScrollView2|
|
||||
1768805469710|CPSearchField|
|
||||
1768805469723|CPSearchFieldPredicateBinding|
|
||||
1768805469737|CPSegmentedControlBindings|
|
||||
1768805469750|CPSegmentedControlTest|
|
||||
1768805469763|CPSoundTest|
|
||||
1768805469777|CPSplitViewDivider|
|
||||
1768805469790|CPSplitViewTest|
|
||||
1768805469803|CPStackViewTest|
|
||||
1768805469816|CPStepperBindings|
|
||||
1768805469830|CPStepperNibTest|
|
||||
1768805469843|CPTabView2|
|
||||
1768805469856|CPTabViewBindings|
|
||||
1768805469869|CPTabViewNib|
|
||||
1768805469883|CPTableViewGroupRows|
|
||||
1768805469896|CPTextField|
|
||||
1768805469909|CPTextFieldEditingStyleTest|
|
||||
1768805469923|CPTextFieldHeightTest|
|
||||
1768805469936|CPTextFieldMovementsTest|
|
||||
1768805469949|CPTextFieldMultiline|
|
||||
1768805469963|CPTextView|
|
||||
1768805469976|CPTextViewCibTest|
|
||||
1768805469989|CPTextViewDelegateAndNotifications|
|
||||
1768805470002|CPTimeZone|
|
||||
1768805470016|CPTokenFieldTest|
|
||||
1768805470029|CPToolTip|
|
||||
1768805470042|CPToolbarTest|
|
||||
1768805470055|CPURLConnectionAsyncTest|
|
||||
1768805470069|CPURLConnectionSynchronousTest|
|
||||
1768805470082|CPUserDefaults|
|
||||
1768805470095|CPUserDefaultsControllerTest|
|
||||
1768805470108|CPUserNotificationTest|
|
||||
1768805470122|CPViewController|
|
||||
1768805470135|CPVisualEffectViewTest|
|
||||
1768805470148|CPWebViewTest|
|
||||
1768805470162|CPWebViewTest2|
|
||||
1768805470175|CPWindowLiveResizeTest|
|
||||
1768805470188|CPWindowMovableTest|
|
||||
1768805470202|CPWindowResizeStyle|
|
||||
1768805470215|ChildWindows|
|
||||
1768805470228|CompilationTests|
|
||||
1768805470241|ContinuouslyUpdatesValueBinding|
|
||||
1768805470255|CopyAndPaste|
|
||||
1768805470268|CrossOriginTest|
|
||||
1768805470281|FF4096Test|
|
||||
1768805470294|FontEnhancementTest|
|
||||
1768805470308|FontMetricsExplorer|
|
||||
1768805470321|KeyEquivalents|
|
||||
1768805470334|KeyViewLoopTest|
|
||||
1768805470348|KeyWindowInTheBackgroundActivation|
|
||||
1768805470361|LayoutTest|
|
||||
1768805470374|LoadTimeTest|
|
||||
1768805470388|LongBindings|
|
||||
1768805470401|MobileTest|
|
||||
1768805470414|MultipleValueBindings|
|
||||
1768805470428|NSBoxTest|
|
||||
1768805470441|NSBrowserTest|
|
||||
1768805470454|NewTextFieldBezel|
|
||||
1768805470467|Nib2CibAlignment|
|
||||
1768805470481|Nib2CibBaselineAlignementTest|
|
||||
1768805470494|Nib2CibSubviewsOrderTest|
|
||||
1768805470507|NibAppRemixed|
|
||||
1768805470520|PatternFillTest|
|
||||
1768805470534|PlatformWindows|
|
||||
1768805470547|PopUpButtonEscTest|
|
||||
1768805470560|ScalingTest|
|
||||
1768805470573|ScalingTest2|
|
||||
1768805470587|ScrollviewTheming|
|
||||
1768805470600|SheetWindowOrderFrontIssue|
|
||||
1768805470613|SimpleBindings2|
|
||||
1768805470626|SmartFoldersDemo|
|
||||
1768805470640|TableTest|
|
||||
1768805470653|ThemeBrowser|
|
||||
1768805470666|ThemeKitchenSink|
|
||||
1768805470680|TrackingArea|
|
||||
1768805470693|UndoRedoWithMenuUpdate|
|
||||
1768805470706|UserlandNSTest|
|
||||
1768805470720|layoutEphemeralSubviewTest|
|
||||
1768805470733|loadDynamicFrameworks|
|
||||
1768805470746|performKeyEquivalentTest|
|
||||
1768805470759|predicateWithFormat|
|
||||
1768805470773|resignFirstResponder-CPControlTextDidEndEditing|
|
||||
1768805470786|sizeToFitFix|
|
||||
1769366125793|ArrayController1|
|
||||
1769366125808|ArrayControllerInitialSelectionTest|
|
||||
1769366125821|ArrayControllerRemovingFirstTest|
|
||||
1769366125835|AttachedSheet|
|
||||
1769366125848|AttachedSheet2|
|
||||
1769366125862|Bindings|
|
||||
1769366125875|CGCanvasContext|
|
||||
1769366125889|CGPath|
|
||||
1769366125902|CPAlertTest|
|
||||
1769366125916|CPAnimatablePropertyContainerTest|
|
||||
1769366125929|CPAnimationContextTest|
|
||||
1769366125942|CPAnimationTest|
|
||||
1769366125956|CPBinder-echo-bug|
|
||||
1769366125969|CPBoxCibTest|
|
||||
1769366125983|CPBoxTest|
|
||||
1769366125996|CPBrowserTest|
|
||||
1769366126010|CPButtonKeyEquivalentDefaultTest|
|
||||
1769366126023|CPButtonTest|
|
||||
1769366126037|CPByteCountFormatter|
|
||||
1769366126050|CPCollectionViewNibTest|
|
||||
1769366126064|CPColor-CPImage-description|
|
||||
1769366126077|CPColorWellBindings|
|
||||
1769366126091|CPComboBoxTest|
|
||||
1769366126104|CPControlPerformClickExceptionTest|
|
||||
1769366126118|CPControlSize|
|
||||
1769366126131|CPCursor|
|
||||
1769366126144|CPDateFormatterTest|
|
||||
1769366126158|CPDatePickerTest|
|
||||
1769366126171|CPDictionaryControllerTest|
|
||||
1769366126184|CPDocumentControllerTest|
|
||||
1769366126198|CPFormatterTest|
|
||||
1769366126211|CPGraphicsTest|
|
||||
1769366126225|CPImageAndTextViewImageScaling|
|
||||
1769366126238|CPImageViewAlignmentScaling|
|
||||
1769366126252|CPImageViewTest|
|
||||
1769366126266|CPImageViewbindingsTest|
|
||||
1769366126279|CPLevelIndicator|
|
||||
1769366126293|CPLocalizationTest|
|
||||
1769366126306|CPLogTest|
|
||||
1769366126319|CPMenuCALayerTest|
|
||||
1769366126332|CPMenuEnabledBindingsTest|
|
||||
1769366126346|CPMenuKeyEquivalents|
|
||||
1769366126359|CPMenuRemoveAllTest|
|
||||
1769366126373|CPMenuSubmenuPlacementConstraints|
|
||||
1769366126386|CPMenuTest|
|
||||
1769366126399|CPOutlineViewCibTest|
|
||||
1769366126413|CPOutlineViewTest|
|
||||
1769366126426|CPOutlineViewViewBasedCibTest|
|
||||
1769366126439|CPPanelTest|
|
||||
1769366126453|CPPlatformWindow|
|
||||
1769366126466|CPPlattformWindowMinSize|
|
||||
1769366126479|CPPopUpButtonBindings|
|
||||
1769366126493|CPPopUpButtonTest|
|
||||
1769366126506|CPPopover|
|
||||
1769366126520|CPPredicateEditorCibTest|
|
||||
1769366126533|CPProgressIndicator|
|
||||
1769366126547|CPPropertyListSerializationTest|
|
||||
1769366126560|CPRadioBindings|
|
||||
1769366126573|CPRuleEditorCibTest|
|
||||
1769366126587|CPScrollView|
|
||||
1769366126600|CPScrollView2|
|
||||
1769366126614|CPSearchField|
|
||||
1769366126627|CPSearchFieldPredicateBinding|
|
||||
1769366126641|CPSegmentedControlBindings|
|
||||
1769366126654|CPSegmentedControlTest|
|
||||
1769366126667|CPSoundTest|
|
||||
1769366126681|CPSplitViewDivider|
|
||||
1769366126694|CPSplitViewTest|
|
||||
1769366126707|CPStackViewTest|
|
||||
1769366126721|CPStepperBindings|
|
||||
1769366126734|CPStepperNibTest|
|
||||
1769366126748|CPTabView2|
|
||||
1769366126761|CPTabViewBindings|
|
||||
1769366126775|CPTabViewNib|
|
||||
1769366126789|CPTableViewGroupRows|
|
||||
1769366126802|CPTextField|
|
||||
1769366126816|CPTextFieldEditingStyleTest|
|
||||
1769366126829|CPTextFieldHeightTest|
|
||||
1769366126843|CPTextFieldMovementsTest|
|
||||
1769366126856|CPTextFieldMultiline|
|
||||
1769366126870|CPTextView|
|
||||
1769366126883|CPTextViewCibTest|
|
||||
1769366126897|CPTextViewDelegateAndNotifications|
|
||||
1769366126910|CPTimeZone|
|
||||
1769366126923|CPTokenFieldTest|
|
||||
1769366126937|CPToolTip|
|
||||
1769366126950|CPToolbarTest|
|
||||
1769366126964|CPURLConnectionAsyncTest|
|
||||
1769366126977|CPURLConnectionSynchronousTest|
|
||||
1769366126991|CPUserDefaults|
|
||||
1769366127004|CPUserDefaultsControllerTest|
|
||||
1769366127017|CPUserNotificationTest|
|
||||
1769366127031|CPViewController|
|
||||
1769366127044|CPVisualEffectViewTest|
|
||||
1769366127058|CPWebViewTest|
|
||||
1769366127071|CPWebViewTest2|
|
||||
1769366127085|CPWindowLiveResizeTest|
|
||||
1769366127098|CPWindowMovableTest|
|
||||
1769366127112|CPWindowResizeStyle|
|
||||
1769366127125|ChildWindows|
|
||||
1769366127138|CompilationTests|
|
||||
1769366127152|ContinuouslyUpdatesValueBinding|
|
||||
1769366127165|CopyAndPaste|
|
||||
1769366127178|CrossOriginTest|
|
||||
1769366127192|FF4096Test|
|
||||
1769366127205|FontEnhancementTest|
|
||||
1769366127219|FontMetricsExplorer|
|
||||
1769366127232|KeyEquivalents|
|
||||
1769366127245|KeyViewLoopTest|
|
||||
1769366127259|KeyWindowInTheBackgroundActivation|
|
||||
1769366127272|LayoutTest|
|
||||
1769366127285|LoadTimeTest|
|
||||
1769366127298|LongBindings|
|
||||
1769366127312|MobileTest|
|
||||
1769366127325|MultipleValueBindings|
|
||||
1769366127338|NSBoxTest|
|
||||
1769366127352|NSBrowserTest|
|
||||
1769366127365|NewTextFieldBezel|
|
||||
1769366127378|Nib2CibAlignment|
|
||||
1769366127391|Nib2CibBaselineAlignementTest|
|
||||
1769366127405|Nib2CibSubviewsOrderTest|
|
||||
1769366127418|NibAppRemixed|
|
||||
1769366127431|PatternFillTest|
|
||||
1769366127444|PlatformWindows|
|
||||
1769366127458|PopUpButtonEscTest|
|
||||
1769366127471|ScalingTest|
|
||||
1769366127484|ScalingTest2|
|
||||
1769366127497|ScrollviewTheming|
|
||||
1769366127511|SheetWindowOrderFrontIssue|
|
||||
1769366127524|SimpleBindings2|
|
||||
1769366127538|SmartFoldersDemo|
|
||||
1769366127551|TableTest|
|
||||
1769366127564|ThemeBrowser|
|
||||
1769366127578|ThemeKitchenSink|
|
||||
1769366127591|TrackingArea|
|
||||
1769366127605|UndoRedoWithMenuUpdate|
|
||||
1769366127618|UserlandNSTest|
|
||||
1769366127631|layoutEphemeralSubviewTest|
|
||||
1769366127645|loadDynamicFrameworks|
|
||||
1769366127658|performKeyEquivalentTest|
|
||||
1769366127671|predicateWithFormat|
|
||||
1769366127685|resignFirstResponder-CPControlTextDidEndEditing|
|
||||
1769366127698|sizeToFitFix|
|
||||
|
||||
Reference in New Issue
Block a user