Skip to content

Commit

Permalink
Merge branch master
Browse files Browse the repository at this point in the history
  • Loading branch information
thewalkingtoast committed Jun 23, 2012
2 parents 253d749 + d39849b commit 84c8427
Show file tree
Hide file tree
Showing 109 changed files with 10,193 additions and 2,150 deletions.
2 changes: 1 addition & 1 deletion AppKit/CPAnimation.j
Expand Up @@ -307,7 +307,7 @@ ACTUAL_FRAME_RATE = 0;

if ([_delegate respondsToSelector:@selector(animation:valueForProgress:)])
return [_delegate animation:self valueForProgress:t];

if (_animationCurve == CPAnimationLinear)
return t;

Expand Down
19 changes: 9 additions & 10 deletions AppKit/CPApplication.j
Expand Up @@ -219,28 +219,22 @@ CPRunContinuesResponse = -1002;
// At this point we clear the window.status to eliminate Safari's "Cancelled" error message
// The message shouldn't be displayed, because only an XHR is cancelled, but it is a usability issue.
// We do it here so that applications can change it in willFinish or didFinishLaunching
#if PLATFORM(DOM)
window.status = " ";
#endif

// We also want to set the default cursor on the body, so that buttons and things don't have an iBeam
[[CPCursor arrowCursor] set];

var bundle = [CPBundle mainBundle],
types = [bundle objectForInfoDictionaryKey:@"CPBundleDocumentTypes"];

if ([types count] > 0)
_documentController = [CPDocumentController sharedDocumentController];

var delegateClassName = [bundle objectForInfoDictionaryKey:@"CPApplicationDelegateClass"];
delegateClassName = [bundle objectForInfoDictionaryKey:@"CPApplicationDelegateClass"];

if (delegateClassName)
{
var delegateClass = objj_getClass(delegateClassName);

if (delegateClass)
if ([_documentController class] == delegateClass)
[self setDelegate:_documentController];
else
[self setDelegate:[[delegateClass alloc] init]];
[self setDelegate:[[delegateClass alloc] init]];
}

var defaultCenter = [CPNotificationCenter defaultCenter];
Expand All @@ -249,6 +243,11 @@ CPRunContinuesResponse = -1002;
postNotificationName:CPApplicationWillFinishLaunchingNotification
object:self];

var types = [bundle objectForInfoDictionaryKey:@"CPBundleDocumentTypes"];

if ([types count] > 0)
_documentController = [CPDocumentController sharedDocumentController];

var needsUntitled = !!_documentController,
URLStrings = window.cpOpeningURLStrings && window.cpOpeningURLStrings(),
index = 0,
Expand Down
11 changes: 10 additions & 1 deletion AppKit/CPArrayController.j
Expand Up @@ -584,7 +584,7 @@
*/
- (BOOL)__setSelectionIndexes:(CPIndexSet)indexes
{
[self __setSelectionIndexes:indexes avoidEmpty:_avoidsEmptySelection];
return [self __setSelectionIndexes:indexes avoidEmpty:_avoidsEmptySelection];
}

- (BOOL)__setSelectionIndexes:(CPIndexSet)indexes avoidEmpty:(BOOL)avoidEmpty
Expand Down Expand Up @@ -920,6 +920,15 @@
[self removeObjectsAtArrangedObjectIndexes:_selectionIndexes];
}

/*!
Removes the object at the specified index in the controller's arranged objects from the content array.
@param int index - index of the object to remove.
*/
- (void)removeObjectAtArrangedObjectIndex:(int)index
{
[self removeObjectsAtArrangedObjectIndexes:[CPIndexSet indexSetWithIndex:index]];
}

/*!
Removes the objects at the specified indexes in the controller's arranged objects from the content array.
@param CPIndexSet indexes - indexes of the objects to remove.
Expand Down
2 changes: 2 additions & 0 deletions AppKit/CPButton.j
Expand Up @@ -180,6 +180,8 @@ CPButtonImageOffset = 3.0;
// Continuous button defaults.
_periodicInterval = 0.05;
_periodicDelay = 0.5;

_imageDimsWhenDisabled = YES;
}

// Setting the state
Expand Down
2 changes: 1 addition & 1 deletion AppKit/CPControl.j
Expand Up @@ -535,7 +535,7 @@ var CPControlBlackColor = [CPColor blackColor];
// Cocoa raises an invalid parameter assertion and returns if you pass nil.
if (aString === nil || aString === undefined)
{
CPLog.warn("nil sent to CPControl -setStringValue");
CPLog.warn("nil or undefined sent to CPControl -setStringValue");
return;
}

Expand Down
8 changes: 6 additions & 2 deletions AppKit/CPCookie.j
Expand Up @@ -111,8 +111,12 @@
for (var i = 0; i < ca.length; i++)
{
var c = ca[i];
while (c.charAt(0) == ' ') c = c.substring(1, c.length);
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);

while (c.charAt(0) == ' ')
c = c.substring(1, c.length);

if (c.indexOf(nameEQ) == 0)
return c.substring(nameEQ.length, c.length);
}
#endif
return "";
Expand Down
2 changes: 1 addition & 1 deletion AppKit/CPEvent.j
Expand Up @@ -634,7 +634,7 @@ var _CPEventPeriodicEventPeriod = 0,

function _CPEventFirePeriodEvent()
{
[CPApp sendEvent:[CPEvent otherEventWithType:CPPeriodic location:_CGPointMakeZero() modifierFlags:0 timestamp:0 windowNumber:0 context:nil subtype:0 data1:0 data2:0]];
[CPApp sendEvent:[CPEvent otherEventWithType:CPPeriodic location:_CGPointMakeZero() modifierFlags:0 timestamp:[CPEvent currentTimestamp] windowNumber:0 context:nil subtype:0 data1:0 data2:0]];
}

var CPEventClass = [CPEvent class];
Expand Down
7 changes: 5 additions & 2 deletions AppKit/CPGraphics.j
Expand Up @@ -70,7 +70,10 @@ function CPDrawColorTiledRects(
if (_CGRectIsEmpty(slice))
continue;

var minX, maxX, minY, maxY;
var minX,
maxX,
minY,
maxY;

if (side == CPMinXEdge || side == CPMaxXEdge)
{
Expand Down Expand Up @@ -105,4 +108,4 @@ function CPDrawColorTiledRects(
CGContextRestoreGState(context);

return resultRect;
}
}
45 changes: 45 additions & 0 deletions AppKit/CPImage.j
Expand Up @@ -158,6 +158,20 @@ function CPAppKitImage(aFilename, aSize)
return self;
}

/*!
Initializes the receiver with the specified data. The method loads the data into memory.
@param someData the CPData object representing the image
@return the initialized image
*/
- (id)initWithData:(CPData)someData
{
var base64 = [someData base64],
type = [base64 hasPrefix:@"/9j/4AAQSkZJRgABAQEASABIAAD/"] ? @"jpg" : @"png",
dataURL = "data:image/" + type + ";base64," + base64;

return [self initWithContentsOfFile:dataURL];
}

/*!
Returns the path of the file associated with this image.
*/
Expand All @@ -166,6 +180,37 @@ function CPAppKitImage(aFilename, aSize)
return _filename;
}

/*!
Returns the data associated with this image.
@discussion Returns nil if the reciever was not initialized with -initWithData: and the browser does not support the canvas feature;
*/
- (CPData)data
{
#if PLATFORM(DOM)
var dataURL;

if ([_filename hasPrefix:@"data:image"])
dataURL = _filename;
else if (CPFeatureIsCompatible(CPHTMLCanvasFeature))
{
var canvas = document.createElement("canvas"),
ctx = canvas.getContext("2d");

canvas.width = _image.width,
canvas.height = _image.height;

ctx.drawImage(_image, 0, 0);

dataURL = canvas.toDataURL("image/png");
}
else
return nil;

var base64 = dataURL.replace(/^data:image\/png;base64,/, "");
return [CPData dataWithBase64:base64];
#endif
}

/*!
Sets the size of the image.
@param the size of the image
Expand Down
14 changes: 10 additions & 4 deletions AppKit/CPImageView.j
Expand Up @@ -66,7 +66,7 @@ var CPImageViewEmptyPlaceholderImage = nil;

+ (Class)_binderClassForBinding:(CPString)theBinding
{
if (theBinding === CPValueBinding || theBinding === CPValueURLBinding || theBinding === CPValuePathBinding)
if (theBinding === CPValueBinding || theBinding === CPValueURLBinding || theBinding === CPValuePathBinding || theBinding === CPDataBinding)
return [CPImageViewValueBinder class];

return [super _binderClassForBinding:theBinding];
Expand Down Expand Up @@ -466,10 +466,16 @@ var CPImageViewEmptyPlaceholderImage = nil;

- (void)setValue:(id)aValue forBinding:(CPString)aBinding
{
if (aBinding === CPValueURLBinding || aBinding === CPValuePathBinding)
aValue = [[CPImage alloc] initWithContentsOfFile:aValue];
var image;

[_source setImage:aValue];
if (aBinding === CPDataBinding)
image = [[CPImage alloc] initWithData:aValue];
else if (aBinding === CPValueURLBinding || aBinding === CPValuePathBinding)
image = [[CPImage alloc] initWithContentsOfFile:aValue];
else if (aBinding === CPValueBinding)
image = aValue;

[_source setImage:image];
}

@end
Expand Down
1 change: 1 addition & 0 deletions AppKit/CPKeyBinding.j
Expand Up @@ -28,6 +28,7 @@
CPStandardKeyBindings = {
@"@.": @"cancelOperation:",

@"@a": @"selectAll:",
@"^a": @"moveToBeginningOfParagraph:",
@"^$a": @"moveToBeginningOfParagraphAndModifySelection:",
@"^b": @"moveBackward:",
Expand Down
2 changes: 1 addition & 1 deletion AppKit/CPLevelIndicator.j
Expand Up @@ -253,7 +253,7 @@ var _CPLevelIndicatorBezelColor = nil,

var location = [self convertPoint:[anEvent locationInWindow] fromView:nil],
bounds = [self bounds],
oldValue = [self doubleValue];
oldValue = [self doubleValue],
newValue = oldValue;

// Moving the mouse outside of the widget to the left sets it
Expand Down
27 changes: 18 additions & 9 deletions AppKit/CPMenu/_CPMenuManager.j
Expand Up @@ -137,10 +137,7 @@ var STICKY_TIME_INTERVAL = 0.5,
// Periodic events don't have a valid location.
var globalLocation = type === CPPeriodic ? _lastGlobalLocation : [anEvent globalLocation];

// Remember this for the next periodic event.
_lastGlobalLocation = globalLocation;

if (!_lastGlobalLocation)
if (!globalLocation)
return;

// Find which menu window the mouse is currently on top of
Expand All @@ -152,6 +149,14 @@ var STICKY_TIME_INTERVAL = 0.5,
activeItemIndex = activeMenuContainer ? [activeMenuContainer itemIndexAtPoint:menuLocation] : CPNotFound,
activeItem = activeItemIndex !== CPNotFound ? [activeMenu itemAtIndex:activeItemIndex] : nil;

// unhighlight when mouse is moved off the menu
if (_lastGlobalLocation && CGRectContainsPoint([activeMenuContainer globalFrame], _lastGlobalLocation)
&& !CGRectContainsPoint([activeMenuContainer globalFrame], globalLocation))
[activeMenu _highlightItemAtIndex:CPNotFound];

// Remember this for the next periodic event.
_lastGlobalLocation = globalLocation;

// If the item isn't enabled its as if we clicked on nothing.
if (![activeItem isEnabled] || [activeItem _isMenuBarButton])
{
Expand All @@ -161,7 +166,7 @@ var STICKY_TIME_INTERVAL = 0.5,

var mouseOverMenuView = [activeItem view];

if (type === CPScrollWheel)
if (type === CPScrollWheel && ![activeMenuContainer isMenuBar])
[activeMenuContainer scrollByDelta:[anEvent deltaY]];

if (type === CPPeriodic)
Expand Down Expand Up @@ -211,7 +216,8 @@ var STICKY_TIME_INTERVAL = 0.5,
_lastMouseOverMenuView = nil;
}

[activeMenu _highlightItemAtIndex:activeItemIndex];
if (activeItemIndex != CPNotFound)
[activeMenu _highlightItemAtIndex:activeItemIndex];

if (type === CPMouseMoved || type === CPLeftMouseDragged || type === CPLeftMouseDown || type === CPPeriodic)
{
Expand Down Expand Up @@ -485,7 +491,7 @@ var STICKY_TIME_INTERVAL = 0.5,
{
if (!_keyBuffer)
{
_startTime = [CPDate date];
_startTime = [anEvent timestamp];
_keyBuffer = character;

[CPEvent stopPeriodicEvents];
Expand Down Expand Up @@ -522,7 +528,7 @@ var STICKY_TIME_INTERVAL = 0.5,
_keyBuffer = Nil;
}
else
_startTime = [CPDate date];
_startTime = [CPEvent currentTimestamp];
}

- (void)scrollToBeginningOfDocument:(CPMenu)menu
Expand Down Expand Up @@ -666,8 +672,11 @@ var STICKY_TIME_INTERVAL = 0.5,
var index = menu._highlightedIndex - 1;

if (index < 0)
{
if (index != CPNotFound)
[menu _highlightItemAtIndex:[menu numberOfItems] - 1];
return;

}
[menu _highlightItemAtIndex:index];

var item = [menu highlightedItem];
Expand Down
2 changes: 0 additions & 2 deletions AppKit/CPMenu/_CPMenuWindow.j
Expand Up @@ -110,8 +110,6 @@ var STICKY_TIME_INTERVAL = 500,
[_moreBelowView setFrameSize:[_CPMenuWindowMoreBelowImage size]];

[contentView addSubview:_moreBelowView];

[self setShadowStyle:CPWindowShadowStyleMenu];
}

return self;
Expand Down
3 changes: 2 additions & 1 deletion AppKit/CPRuleEditor/CPPredicateEditorRowTemplate.j
Expand Up @@ -185,7 +185,8 @@ CPTransformableAttributeType = 1800;
if (![[self operators] containsObject:[predicate predicateOperatorType]])
return 0;

if (!_rightIsWildcard && ![[self rightExpressions] containsObject:[predicate rightExpression]]) return 0;
if (!_rightIsWildcard && ![[self rightExpressions] containsObject:[predicate rightExpression]])
return 0;

return 1;
}
Expand Down
2 changes: 1 addition & 1 deletion AppKit/CPSplitView.j
Expand Up @@ -1065,7 +1065,7 @@ The sum of the views and the sum of the dividers should be equal to the size of
*/
- (void)_autosave
{
if (!_shouldAutosave || !autosaveName)
if (!_shouldAutosave || !_autosaveName)
return;

var userDefaults = [CPUserDefaults standardUserDefaults],
Expand Down

0 comments on commit 84c8427

Please sign in to comment.