Skip to content

Commit

Permalink
Merge branch 'master' of github.com:cappuccino/cappuccino
Browse files Browse the repository at this point in the history
  • Loading branch information
aljungberg committed Feb 8, 2012
2 parents fe70a55 + 8b28041 commit eacee00
Show file tree
Hide file tree
Showing 20 changed files with 1,526 additions and 838 deletions.
20 changes: 15 additions & 5 deletions AppKit/CPArrayController.j
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,7 @@
- (BOOL)setSelectionIndexes:(CPIndexSet)indexes
{
[self _selectionWillChange]
var r = [self __setSelectionIndexes:indexes];
var r = [self __setSelectionIndexes:indexes avoidEmpty:NO];
[self _selectionDidChange];
return r;
}
Expand All @@ -583,6 +583,11 @@
@ignore
*/
- (BOOL)__setSelectionIndexes:(CPIndexSet)indexes
{
[self __setSelectionIndexes:indexes avoidEmpty:_avoidsEmptySelection];
}

- (BOOL)__setSelectionIndexes:(CPIndexSet)indexes avoidEmpty:(BOOL)avoidEmpty
{
var newIndexes = indexes;

Expand All @@ -591,7 +596,7 @@

if (![newIndexes count])
{
if (_avoidsEmptySelection && [[self arrangedObjects] count])
if (avoidEmpty && [[self arrangedObjects] count])
newIndexes = [CPIndexSet indexSetWithIndex:0];
}
else
Expand All @@ -606,7 +611,7 @@
// Remove out of bounds indexes.
[newIndexes removeIndexesInRange:CPMakeRange(objectsCount, [newIndexes lastIndex] + 1)];
// When avoiding empty selection and the deleted selection was at the bottom, select the last item.
if (![newIndexes count] && _avoidsEmptySelection && objectsCount)
if (![newIndexes count] && avoidEmpty && objectsCount)
newIndexes = [CPIndexSet indexSetWithIndex:objectsCount - 1];
}

Expand Down Expand Up @@ -647,7 +652,7 @@
[self willChangeValueForKey:@"selectionIndexes"];
[self _selectionWillChange];

var r = [self __setSelectedObjects:objects];
var r = [self __setSelectedObjects:objects avoidEmpty:NO];

[self didChangeValueForKey:@"selectionIndexes"];
[self _selectionDidChange];
Expand All @@ -659,6 +664,11 @@
@ignore
*/
- (BOOL)__setSelectedObjects:(CPArray)objects
{
[self __setSelectedObjects:objects avoidEmpty:_avoidsEmptySelection];
}

- (BOOL)__setSelectedObjects:(CPArray)objects avoidEmpty:(BOOL)avoidEmpty
{
var set = [CPIndexSet indexSet],
count = [objects count],
Expand All @@ -672,7 +682,7 @@
[set addIndex:index];
}

[self __setSelectionIndexes:set];
[self __setSelectionIndexes:set avoidEmpty:avoidEmpty];
return YES;
}

Expand Down
41 changes: 32 additions & 9 deletions AppKit/CPButton.j
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ CPRadioButton = 4; // Deprecated, use CPRadio instead.
CPMomentaryChangeButton = 5;
CPOnOffButton = 6;
CPMomentaryPushInButton = 7;
CPMomentaryPushButton = 0;
CPMomentaryLight = 7;
CPMomentaryPushButton = 0; // Deprecated, use CPMomentaryLightButton instead.
CPMomentaryLight = 7; // Deprecated, use CPMomentaryPushInButton instead.

CPNoButtonMask = 0;
CPContentsButtonMask = 1;
Expand Down Expand Up @@ -95,6 +95,7 @@ CPButtonImageOffset = 3.0;

CPString _title;
CPString _alternateTitle;
CPString _displayTitle;

CPInteger _showsStateBy;
CPInteger _highlightsBy;
Expand Down Expand Up @@ -176,6 +177,8 @@ CPButtonImageOffset = 3.0;
// Continuous button defaults.
_periodicInterval = 0.05;
_periodicDelay = 0.5;

_displayTitle = "";
}

// Setting the state
Expand Down Expand Up @@ -414,7 +417,7 @@ CPButtonImageOffset = 3.0;
[self setShowsStateBy:CPNoCellMask];
break;

case CPMomentaryChangeButton: [self setHighlightsBy:CPContentsCellMask];
case CPMomentaryChangeButton: [self setHighlightsBy:CPChangeGrayCellMask | CPContentsCellMask];
[self setShowsStateBy:CPNoCellMask];
break;

Expand All @@ -426,7 +429,7 @@ CPButtonImageOffset = 3.0;
[self setShowsStateBy:CPChangeBackgroundCellMask];
break;

case CPToggleButton: [self setHighlightsBy:CPPushInCellMask | CPContentsCellMask];
case CPToggleButton: [self setHighlightsBy:CPPushInCellMask];
[self setShowsStateBy:CPContentsCellMask];
break;

Expand Down Expand Up @@ -494,20 +497,35 @@ CPButtonImageOffset = 3.0;

- (BOOL)startTrackingAt:(CGPoint)aPoint
{
[self highlight:YES];
if (_highlightsBy !== CPToggleButton)
[self highlight:YES];

if (_highlightsBy === CPMomentaryChangeButton && [self alternateTitle])
_displayTitle = [self alternateTitle];

return [super startTrackingAt:aPoint];
}

- (void)stopTracking:(CGPoint)lastPoint at:(CGPoint)aPoint mouseIsUp:(BOOL)mouseIsUp
{
[self highlight:NO];
[self invalidateTimers];

[super stopTracking:lastPoint at:aPoint mouseIsUp:mouseIsUp];

if (mouseIsUp && CGRectContainsPoint([self bounds], aPoint))
[self setNextState];

if (_highlightsBy === CPOnOffButton && [self state] !== CPOffState)
mouseIsUp = false;

if (_highlightsBy === CPToggleButton)
if ([self state] === CPOnState && [self alternateTitle])
_displayTitle = [self alternateTitle];
else
_displayTitle = [self title];

if (_highlightsBy === CPMomentaryChangeButton)
_displayTitle = [self title];

[super stopTracking:lastPoint at:aPoint mouseIsUp:mouseIsUp];
}

- (void)invalidateTimers
Expand Down Expand Up @@ -639,9 +657,14 @@ CPButtonImageOffset = 3.0;
positioned:CPWindowAbove
relativeToEphemeralSubviewNamed:@"bezel-view"];

if ([self title] && _displayTitle === "")
{
_displayTitle = [self title];
}

if (contentView)
{
[contentView setText:([self hasThemeState:CPThemeStateHighlighted] && _alternateTitle) ? _alternateTitle : _title];
[contentView setText:_displayTitle];
[contentView setImage:[self currentValueForThemeAttribute:@"image"]];
[contentView setImageOffset:[self currentValueForThemeAttribute:@"image-offset"]];

Expand Down
5 changes: 4 additions & 1 deletion AppKit/CPControl.j
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,10 @@ var CPControlBlackColor = [CPColor blackColor];

- (void)stopTracking:(CGPoint)lastPoint at:(CGPoint)aPoint mouseIsUp:(BOOL)mouseIsUp
{
[self highlight:NO];
if ( mouseIsUp )
[self highlight:NO];
else
[self highlight:YES];
}

- (void)mouseDown:(CPEvent)anEvent
Expand Down
16 changes: 8 additions & 8 deletions AppKit/CPFont.j
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ var _CPFonts = {},
*/
+ (CPFont)fontWithName:(CPString)aName size:(float)aSize
{
return _CPCachedFont(aName, aSize, NO, NO) || [[CPFont alloc] _initWithName:aName size:aSize bold:NO italic:NO];
return [CPFont fontWithName:aName size:aSize bold:NO italic:NO];
}

/*!
Expand All @@ -154,7 +154,7 @@ var _CPFonts = {},
*/
+ (CPFont)fontWithName:(CPString)aName size:(float)aSize italic:(BOOL)italic
{
return _CPCachedFont(aName, aSize, NO, NO) || [[CPFont alloc] _initWithName:aName size:aSize bold:NO italic:italic];
return [CPFont fontWithName:aName size:aSize bold:NO italic:italic];
}

/*!
Expand All @@ -165,7 +165,7 @@ var _CPFonts = {},
*/
+ (CPFont)boldFontWithName:(CPString)aName size:(float)aSize
{
return _CPCachedFont(aName, aSize, YES, NO) || [[CPFont alloc] _initWithName:aName size:aSize bold:YES italic:NO];
return [CPFont fontWithName:aName size:aSize bold:YES italic:NO];
}

/*!
Expand All @@ -177,7 +177,7 @@ var _CPFonts = {},
*/
+ (CPFont)boldFontWithName:(CPString)aName size:(float)aSize italic:(BOOL)italic
{
return _CPCachedFont(aName, aSize, NO, NO) || [[CPFont alloc] _initWithName:aName size:aSize bold:YES italic:italic];
return [CPFont fontWithName:aName size:aSize bold:YES italic:italic];
}

/*!
Expand All @@ -187,7 +187,7 @@ var _CPFonts = {},
*/
+ (CPFont)systemFontOfSize:(CPSize)aSize
{
return _CPCachedFont(_CPFontSystemFontFace, aSize, NO, NO) || [[CPFont alloc] _initWithName:_CPFontSystemFontFace size:aSize bold:NO italic:NO];
return [CPFont fontWithName:_CPFontSystemFontFace size:aSize bold:NO italic:NO];
}

/*!
Expand All @@ -197,15 +197,15 @@ var _CPFonts = {},
*/
+ (CPFont)boldSystemFontOfSize:(CPSize)aSize
{
return _CPCachedFont(_CPFontSystemFontFace, aSize, YES, NO) || [[CPFont alloc] _initWithName:_CPFontSystemFontFace size:aSize bold:YES italic:NO];
return [CPFont fontWithName:_CPFontSystemFontFace size:aSize bold:YES italic:NO];
}

/* FIXME Font Descriptor
@ignore
*/
- (id)_initWithName:(CPString)aName size:(float)aSize bold:(BOOL)isBold
+ (CPFont)fontWithName:(CPString)aName size:(float)aSize bold:(BOOL)bold italic:(BOOL)italic
{
return [self _initWithName:aName size:aSize bold:isBold italic:NO];
return _CPCachedFont(aName, aSize, bold, italic) || [[CPFont alloc] _initWithName:aName size:aSize bold:bold italic:italic];
}

- (id)_initWithName:(CPString)aName size:(float)aSize bold:(BOOL)isBold italic:(BOOL)isItalic
Expand Down
7 changes: 4 additions & 3 deletions AppKit/CPObjectController.j
Original file line number Diff line number Diff line change
Expand Up @@ -663,7 +663,8 @@ var CPObjectControllerContentKey = @"CPObjectControllerCo

- (id)_controllerMarkerForValues:(CPArray)theValues
{
var count = [theValues count];
var count = [theValues count],
value;

if (!count)
value = CPNoSelectionMarker;
Expand Down Expand Up @@ -693,8 +694,8 @@ var CPObjectControllerContentKey = @"CPObjectControllerCo

- (id)valueForKeyPath:(CPString)theKeyPath
{
var values = [[_controller selectedObjects] valueForKeyPath:theKeyPath];
value = [self _controllerMarkerForValues:values];
var values = [[_controller selectedObjects] valueForKeyPath:theKeyPath],
value = [self _controllerMarkerForValues:values];

[_cachedValues setObject:value forKey:theKeyPath];

Expand Down
2 changes: 2 additions & 0 deletions AppKit/CPScrollView.j
Original file line number Diff line number Diff line change
Expand Up @@ -817,6 +817,8 @@ var CPScrollerStyleGlobal = CPScrollerStyleOverlay,
}

[self reflectScrolledClipView:_contentView];
[documentHeaderView setNeedsLayout];
[documentHeaderView setNeedsDisplay:YES];
}

/* @ignore */
Expand Down
1 change: 0 additions & 1 deletion AppKit/CPTableColumn.j
Original file line number Diff line number Diff line change
Expand Up @@ -734,7 +734,6 @@ var CPTableColumnIdentifierKey = @"CPTableColumnIdentifierKey",
[self setIdentifier:[aCoder decodeObjectForKey:CPTableColumnIdentifierKey]];
[self setHeaderView:[aCoder decodeObjectForKey:CPTableColumnHeaderViewKey]];
[self setDataView:[aCoder decodeObjectForKey:CPTableColumnDataViewKey]];
[self setHeaderView:[aCoder decodeObjectForKey:CPTableColumnHeaderViewKey]];

_resizingMask = [aCoder decodeIntForKey:CPTableColumnResizingMaskKey];
_isHidden = [aCoder decodeBoolForKey:CPTableColumnIsHiddenKey];
Expand Down
14 changes: 14 additions & 0 deletions AppKit/CPTableView.j
Original file line number Diff line number Diff line change
Expand Up @@ -1513,6 +1513,8 @@ NOT YET IMPLEMENTED

if ([scrollView isKindOfClass:[CPScrollView class]] && [scrollView documentView] === self)
[scrollView _updateCornerAndHeaderView];

[self setNeedsLayout];
}

// Complexity:
Expand Down Expand Up @@ -3501,8 +3503,20 @@ Your delegate can implement this method to avoid subclassing the tableview to ad
{
[super setNeedsDisplay:aFlag];
[_tableDrawView setNeedsDisplay:aFlag];

[[self headerView] setNeedsDisplay:YES];
}

/*!
@ignore
*/
- (void)setNeedsLayout
{
[super setNeedsLayout];
[[self headerView] setNeedsLayout];
}


/*!
@ignore
*/
Expand Down
12 changes: 12 additions & 0 deletions Foundation/CPObject.j
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,18 @@ CPLog(@"Got some class: %@", inst);
return objj_msgSend(self, aSelector, anObject, anotherObject);
}

/*!
Sends the specified message to the reciever, with any number of arguments.
@param aSelector the message to send
@param anObject... comma seperated objects to pass to the selector
@return the return value of the message
*/
- (id)performSelector:(SEL)aSelector withObjects:(id)anObject, ...
{
var params = [self, aSelector].concat(Array.prototype.slice.apply(arguments, [3]));
return objj_msgSend.apply(this, params);
}

- (id)forwardingTargetForSelector:(SEL)aSelector
{
return nil;
Expand Down
2 changes: 1 addition & 1 deletion Foundation/CPPredicate/CPCompoundPredicate.j
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ var CPCompoundPredicateType;

switch (_type)
{
case CPNotPredicateType: result += "NOT %s" + [args objectAtIndex:0];
case CPNotPredicateType: result += "NOT " + [args objectAtIndex:0];
break;

case CPAndPredicateType: result += [args objectAtIndex:0];
Expand Down

0 comments on commit eacee00

Please sign in to comment.