mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-11-14 02:33:50 +00:00
Merge branch 'master' of git@github.com:280north/cappuccino
This commit is contained in:
commit
5eb7be054e
11 files changed
+178
-35
No files matched your search
+10
-6
@@ -76,7 +76,7 @@ ACTUAL_FRAME_RATE = 0;
|
||||
*/
|
||||
@implementation CPAnimation : CPObject
|
||||
{
|
||||
CPTimeInterval _startTime;
|
||||
CPTimeInterval _lastTime;
|
||||
CPTimeInterval _duration;
|
||||
|
||||
CPAnimationCurve _animationCurve;
|
||||
@@ -101,6 +101,7 @@ ACTUAL_FRAME_RATE = 0;
|
||||
|
||||
if (self)
|
||||
{
|
||||
_progress = 0.0;
|
||||
_duration = MAX(0.0, aDuration);
|
||||
_animationCurve = anAnimationCurve;
|
||||
_frameRate = 60.0;
|
||||
@@ -217,9 +218,11 @@ ACTUAL_FRAME_RATE = 0;
|
||||
if (_timer || _delegate && [_delegate respondsToSelector:@selector(animationShouldStart)] && ![_delegate animationShouldStart:self])
|
||||
return;
|
||||
|
||||
_progress = 0.0;
|
||||
if (_progress === 1.0)
|
||||
_progress = 0.0;
|
||||
|
||||
ACTUAL_FRAME_RATE = 0;
|
||||
_startTime = new Date();
|
||||
_lastTime = new Date();
|
||||
|
||||
_timer = [CPTimer scheduledTimerWithTimeInterval:0.0 target:self selector:@selector(animationTimerDidFire:) userInfo:nil repeats:YES];
|
||||
}
|
||||
@@ -229,8 +232,10 @@ ACTUAL_FRAME_RATE = 0;
|
||||
*/
|
||||
- (void)animationTimerDidFire:(CPTimer)aTimer
|
||||
{
|
||||
var elapsed = new Date() - _startTime,
|
||||
progress = MIN(1.0, 1.0 - (_duration - elapsed / 1000.0) / _duration);
|
||||
var currentTime = new Date(),
|
||||
progress = MIN(1.0, [self currentProgress] + (currentTime - _lastTime) / (_duration * 1000.0));
|
||||
|
||||
_lastTime = currentTime;
|
||||
|
||||
++ACTUAL_FRAME_RATE;
|
||||
|
||||
@@ -244,7 +249,6 @@ ACTUAL_FRAME_RATE = 0;
|
||||
if ([_delegate respondsToSelector:@selector(animationDidEnd:)])
|
||||
[_delegate animationDidEnd:self];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*!
|
||||
|
||||
@@ -328,7 +328,7 @@
|
||||
// either proportioned out to the views (if their minSize != maxSize) or used as
|
||||
// margin
|
||||
var itemSize = CGSizeMakeCopy(_minItemSize);
|
||||
|
||||
|
||||
_numberOfColumns = MAX(1.0, FLOOR(width / itemSize.width));
|
||||
|
||||
if (_maxNumberOfColumns > 0)
|
||||
@@ -340,6 +340,10 @@
|
||||
if (remaining > 0 && itemSize.width < _maxItemSize.width)
|
||||
itemSize.width = MIN(_maxItemSize.width, itemSize.width + FLOOR(remaining / _numberOfColumns));
|
||||
|
||||
// When we ONE column and a non-integral width, the FLOORing above can cause the item width to be smaller than the total width.
|
||||
if (_maxNumberOfColumns == 1 && itemSize.width < _maxItemSize.width && itemSize.width < width)
|
||||
itemSize.width = MIN(_maxItemSize.width, width);
|
||||
|
||||
if (!CGSizeEqualToSize(_itemSize, itemSize))
|
||||
{
|
||||
_itemSize = itemSize;
|
||||
@@ -515,6 +519,7 @@
|
||||
frame = [view frame];
|
||||
|
||||
[view setFrameSize:_itemSize];
|
||||
[view setAlphaValue:0.7];
|
||||
|
||||
[self dragView:view
|
||||
at:[[_items[[_selectionIndexes firstIndex]] view] frame].origin
|
||||
|
||||
@@ -49,8 +49,9 @@ CPJavascriptRemedialKeySupport = 1 << 15;
|
||||
CPJavaScriptShadowFeature = 1 << 20;
|
||||
|
||||
CPJavaScriptNegativeMouseWheelValues = 1 << 22;
|
||||
CPJavaScriptMouseWheelValues_8_15 = 1 << 23
|
||||
|
||||
CPOpacityRequiresFilterFeature = 1 << 23;
|
||||
CPOpacityRequiresFilterFeature = 1 << 24;
|
||||
|
||||
var USER_AGENT = "",
|
||||
PLATFORM_ENGINE = CPUnknownBrowserEngine,
|
||||
@@ -114,10 +115,16 @@ else if (USER_AGENT.indexOf("Gecko") != -1) // Must follow KHTML check.
|
||||
PLATFORM_FEATURES |= CPJavaScriptCanvasDrawFeature;
|
||||
|
||||
var index = USER_AGENT.indexOf("Firefox"),
|
||||
version = (index == -1) ? 2.0 : parseFloat(USER_AGENT.substring(index+"Firefox".length+1));
|
||||
version = (index == -1) ? 2.0 : parseFloat(USER_AGENT.substring(index + "Firefox".length + 1));
|
||||
|
||||
if (version >= 3.0)
|
||||
PLATFORM_FEATURES |= CPCSSRGBAFeature;
|
||||
|
||||
var geckoIndex = USER_AGENT.indexOf("Gecko"),
|
||||
geckoVersion = (geckoIndex === -1) ? 0.0 : parseFloat(USER_AGENT.substring(geckoIndex + "Gecko".length + 1, USER_AGENT.indexOf(' ', geckoIndex)));
|
||||
|
||||
if (version < 20061028)
|
||||
PLATFORM_FEATURES |= CPJavaScriptMouseWheelValues_8_15;
|
||||
}
|
||||
|
||||
// Feature Specific Checks
|
||||
|
||||
@@ -152,6 +152,16 @@ var CPDragServerUpdateDragging = function(anEvent)
|
||||
return CPDragServerPasteboard;
|
||||
}
|
||||
|
||||
- (CPImage)draggedImage
|
||||
{
|
||||
return [CPDragServerView image];
|
||||
}
|
||||
|
||||
- (CPView)draggedView
|
||||
{
|
||||
return CPDragServerView;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation CPDragServer : CPObject
|
||||
|
||||
@@ -71,6 +71,9 @@ var CPCibObjectDataKey = @"CPCibObjectDataKey";
|
||||
[CPMenu setMenuBarVisible:YES];
|
||||
}
|
||||
|
||||
if (topLevelObjects)
|
||||
[topLevelObjects addObjectsFromArray:[objectData topLevelObjects]];
|
||||
|
||||
/*
|
||||
// [objectData establishConnectionsWithOwner:owner topLevelObjects:topLevelObjects];
|
||||
// [objectData cibInstantiateWithOwner:owner topLevelObjects:topLevelObjects];
|
||||
|
||||
@@ -34,6 +34,9 @@ var _CPCibCustomObjectClassName = @"_CPCibCustomObjectClassName";
|
||||
|
||||
if (!theClass)
|
||||
CPLog("Unknown class \"" + _className + "\" in cib file");
|
||||
|
||||
if (theClass === [CPApplication class])
|
||||
return [CPApplication sharedApplication];
|
||||
|
||||
return [[theClass alloc] init];
|
||||
}
|
||||
|
||||
@@ -59,8 +59,6 @@ var CPDOMWindowGetFrame,
|
||||
CPTimeInterval _lastMouseUp;
|
||||
CPTimeInterval _lastMouseDown;
|
||||
|
||||
CPPoint _currentMousePosition;
|
||||
|
||||
JSObject _charCodes;
|
||||
unsigned _keyCode;
|
||||
|
||||
@@ -542,8 +540,6 @@ var CTRL_KEY_CODE = 17;
|
||||
event = [CPEvent mouseEventWithType:_mouseIsDown ? CPLeftMouseDragged : CPMouseMoved
|
||||
location:location modifierFlags:modifierFlags timestamp:timestamp
|
||||
windowNumber:windowNumber context:nil eventNumber:-1 clickCount:1 pressure:0];
|
||||
|
||||
_currentMousePosition = _CGPointMake(aDOMEvent.clientX, aDOMEvent.clientY);
|
||||
|
||||
break;
|
||||
}
|
||||
@@ -720,10 +716,32 @@ var CTRL_KEY_CODE = 17;
|
||||
|
||||
try
|
||||
{
|
||||
if (CPFeatureIsCompatible(CPJavaScriptMouseWheelValues_8_15))
|
||||
{
|
||||
var x = 0.0,
|
||||
y = 0.0,
|
||||
element = aDOMEvent.target;
|
||||
|
||||
while (element.nodeType !== 1)
|
||||
element = element.parentNode;
|
||||
|
||||
if (element.offsetParent)
|
||||
{
|
||||
do
|
||||
{
|
||||
x += element.offsetLeft;
|
||||
y += element.offsetTop;
|
||||
|
||||
} while (element = element.offsetParent);
|
||||
}
|
||||
|
||||
var location = _CGPointMake((x + ((aDOMEvent.clientX - 8) / 15)), (y + ((aDOMEvent.clientY - 8) / 15)));}
|
||||
else
|
||||
var location = _CGPointMake(aDOMEvent.clientX, aDOMEvent.clientY);
|
||||
|
||||
var deltaX = 0.0,
|
||||
deltaY = 0.0,
|
||||
windowNumber = 0,
|
||||
location = CGPointMake(_currentMousePosition.x, _currentMousePosition.y),
|
||||
timestamp = aDOMEvent.timeStamp ? aDOMEvent.timeStamp : new Date(),
|
||||
modifierFlags = (aDOMEvent.shiftKey ? CPShiftKeyMask : 0) |
|
||||
(aDOMEvent.ctrlKey ? CPControlKeyMask : 0) |
|
||||
@@ -898,7 +916,3 @@ var CPDOMEventStop = function(aDOMEvent)
|
||||
CPSharedDOMWindowBridge._DOMFocusElement.blur();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
*/
|
||||
@@ -47,13 +47,15 @@
|
||||
|
||||
function CP_NSMapClassName(aClassName)
|
||||
{
|
||||
if (aClassName == @"NSView")
|
||||
return "CPView";
|
||||
switch (aClassName)
|
||||
{
|
||||
case @"NSApplication": return @"CPApplication";
|
||||
case @"NSObject": return @"CPObject";
|
||||
case @"NSView": return @"CPView";
|
||||
case @"NSWindow": return @"CPWindow";
|
||||
|
||||
default: CPLog.warn("No class name mapping for \"" + aClassName + "\"");
|
||||
}
|
||||
|
||||
if (aClassName == @"NSWindow")
|
||||
return @"CPWindow";
|
||||
|
||||
CPLog.warn("No class name mapping for \""+aClassName+"\"");
|
||||
|
||||
return aClassName;
|
||||
}
|
||||
@@ -30,7 +30,7 @@
|
||||
self = [super init];
|
||||
|
||||
if (self){
|
||||
_className = [aCoder decodeObjectForKey:@"NSClassName"];
|
||||
_className = CP_NSMapClassName([aCoder decodeObjectForKey:@"NSClassName"]);
|
||||
print(":::"+_className);
|
||||
}
|
||||
return self;
|
||||
|
||||
+99
-9
@@ -76,16 +76,8 @@ function cibExtension(aPath)
|
||||
return aPath.substr(0, dotIndex) + ".cib";
|
||||
}
|
||||
|
||||
function main()
|
||||
function convert(inputFileName, outputFileName)
|
||||
{
|
||||
var count = arguments.length;
|
||||
|
||||
if (count < 1)
|
||||
printUsage();
|
||||
|
||||
var inputFileName = arguments[0],
|
||||
outputFileName = count < 2 ? cibExtension(inputFileName) : arguments[1];
|
||||
|
||||
// Make sure we can read the file
|
||||
if (!(new Packages.java.io.File(inputFileName)).canRead())
|
||||
{
|
||||
@@ -140,4 +132,102 @@ function main()
|
||||
writer.close();
|
||||
}
|
||||
|
||||
function readPlist(/*File*/ aFile)
|
||||
{
|
||||
var reader = new BufferedReader(new FileReader(aFile)),
|
||||
fileContents = "";
|
||||
|
||||
// Get contents of the file
|
||||
while (reader.ready())
|
||||
fileContents += reader.readLine() + '\n';
|
||||
|
||||
reader.close();
|
||||
|
||||
var data = new objj_data();
|
||||
data.string = fileContents;
|
||||
|
||||
return new CPPropertyListCreateFromData(data);
|
||||
}
|
||||
|
||||
function importFiles(filePaths, aCallback)
|
||||
{
|
||||
if (filePaths.length === 0)
|
||||
aCallback();
|
||||
else
|
||||
objj_import(new File(filePaths.shift()).getCanonicalPath(), YES, function() { importFiles(filePaths, aCallback) });
|
||||
}
|
||||
|
||||
function loadFrameworks(frameworkPaths, aCallback)
|
||||
{
|
||||
if (frameworkPaths.length === 0)
|
||||
return aCallback();
|
||||
|
||||
var frameworkPath = frameworkPaths.shift(),
|
||||
|
||||
infoPlist = new File(frameworkPath + "/Info.plist");
|
||||
|
||||
if (!infoPlist.exists())
|
||||
{
|
||||
java.lang.System.out.println("'" + frameworkPath + "' is not a framework or could not be found.");
|
||||
java.lang.System.exit(1);
|
||||
}
|
||||
|
||||
var infoDictionary = readPlist(new File(frameworkPath + "/Info.plist"));
|
||||
|
||||
if ([infoDictionary objectForKey:@"CPBundlePackageType"] !== "FMWK")
|
||||
{
|
||||
java.lang.System.out.println("'" + frameworkPath + "' is not a framework .");
|
||||
java.lang.System.exit(1);
|
||||
}
|
||||
|
||||
var files = [infoDictionary objectForKey:@"CPBundleReplacedFiles"],
|
||||
index = 0,
|
||||
count = files.length;
|
||||
|
||||
for (; index < count; ++index)
|
||||
files[index] = frameworkPath + '/' + files[index];
|
||||
|
||||
importFiles(files, function() { loadFrameworks(frameworkPaths, aCallback) });
|
||||
}
|
||||
|
||||
function main()
|
||||
{
|
||||
var count = arguments.length;
|
||||
|
||||
if (count < 1)
|
||||
printUsage();
|
||||
|
||||
var index = 0,
|
||||
|
||||
inputFileName = nil,
|
||||
outputFileName = nil,
|
||||
frameworkPaths = [];
|
||||
|
||||
for (; index < count; ++index)
|
||||
{
|
||||
switch(arguments[index])
|
||||
{
|
||||
case "-help":
|
||||
case "--help": printUsage();
|
||||
|
||||
case "-F": frameworkPaths.push(arguments[++index]);
|
||||
break;
|
||||
|
||||
default: if (inputFileName && inputFileName.length > 0)
|
||||
outputFileName = arguments[index];
|
||||
else
|
||||
inputFileName = arguments[index];
|
||||
}
|
||||
}
|
||||
|
||||
if (!outputFileName || outputFileName.length < 1)
|
||||
outputFileName = cibExtension(inputFileName);
|
||||
|
||||
if (frameworkPaths.length)
|
||||
loadFrameworks(frameworkPaths, function() { convert(inputFileName, outputFileName); });
|
||||
|
||||
else
|
||||
convert(inputFileName, outputFileName);
|
||||
}
|
||||
|
||||
main.apply(main, args);
|
||||
@@ -107,6 +107,11 @@ $ant bootstrap
|
||||
<antcall target = "build-debug" />
|
||||
<antcall target = "build-release" />
|
||||
</target>
|
||||
|
||||
<target name = "clean-all" >
|
||||
<antcall target = "clean-debug" />
|
||||
<antcall target = "clean-release" />
|
||||
</target>
|
||||
|
||||
<!-- Iterate -->
|
||||
|
||||
|
||||
Reference in new issue
Block a user