Skip to content

Commit

Permalink
-capp_lint
Browse files Browse the repository at this point in the history
  • Loading branch information
walisser committed Aug 4, 2012
1 parent 24ef4d4 commit bff2277
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 60 deletions.
8 changes: 4 additions & 4 deletions AppKit/CPApplication.j
Expand Up @@ -936,9 +936,9 @@ CPRunContinuesResponse = -1002;
[CPException raise:CPInternalInconsistencyException reason:@"The target window of beginSheet: cannot be a sheet"];
return;
}

[aSheet._windowView _enableSheet:YES];

// -dw- if a sheet is already visible, we skip this since it serves no purpose and causes
// orderOut: to be called on the sheet, which is not what we want.
if (![aWindow isVisible])
Expand Down Expand Up @@ -1196,8 +1196,8 @@ _CPRunModalLoop = function(anEvent)
// yet it works when there is a modal window. Maybe it starts its own modal session, but interaction with the original
// modal window seems to continue working as well. Regardless of correctness, this solution beats popovers not working
// at all from sheets.
if (theWindow == modalSession._window ||
[theWindow worksWhenModal] ||
if (theWindow == modalSession._window ||
[theWindow worksWhenModal] ||
[theWindow attachedSheet] == modalSession._window || // -dw- allow modal parent of sheet to be repositioned
([theWindow isKindOfClass:_CPAttachedWindow] && [[theWindow targetView] window] === modalSession._window))
[theWindow sendEvent:anEvent];
Expand Down
85 changes: 42 additions & 43 deletions AppKit/CPWindow/CPWindow.j
Expand Up @@ -423,7 +423,7 @@ CPTexturedBackgroundWindowMask
_isSheet = NO;
_sheetContext = nil;
_parentView = nil;

// Set up our window number.
_windowNumber = [CPApp._windows count];
CPApp._windows[_windowNumber] = self;
Expand Down Expand Up @@ -780,21 +780,21 @@ CPTexturedBackgroundWindowMask

if (_hasShadow)
{
// if the shadow would be taller/wider than the window height,
// if the shadow would be taller/wider than the window height,
// make it the same as the window height. this allows views to
// become 0,0 with no shadow on them and makes the sheet
// animation look nicer
var shadowSize = _CGSizeMake(size.width,size.height);

if (size.width >= (SHADOW_MARGIN_LEFT + SHADOW_MARGIN_RIGHT))
shadowSize.width += SHADOW_MARGIN_LEFT + SHADOW_MARGIN_RIGHT;

if (size.height >= (SHADOW_MARGIN_BOTTOM + SHADOW_MARGIN_TOP + SHADOW_DISTANCE))
shadowSize.height += SHADOW_MARGIN_BOTTOM + SHADOW_MARGIN_TOP + SHADOW_DISTANCE;

[_shadowView setFrameSize:shadowSize];
}

if (!_isAnimating)
[[CPNotificationCenter defaultCenter] postNotificationName:CPWindowDidResizeNotification object:self];
}
Expand Down Expand Up @@ -831,7 +831,7 @@ CPTexturedBackgroundWindowMask
{
[self _setClippedFrame:_CGRectMake(anOrigin.x, anOrigin.y, _CGRectGetWidth(_frame), _CGRectGetHeight(_frame)) display:YES animate:NO];

// reposition sheet
// reposition sheet
if ([self attachedSheet])
[self _setAttachedSheetFrameOrigin];
}
Expand Down Expand Up @@ -892,7 +892,7 @@ CPTexturedBackgroundWindowMask
[self._parentView _detachSheetWindow];
return;
}

#if PLATFORM(DOM)
if ([self _sharesChromeWithPlatformWindow])
[_platformWindow orderOut:self];
Expand Down Expand Up @@ -1605,7 +1605,7 @@ CPTexturedBackgroundWindowMask
{
case CPLeftMouseDown:
[_windowView mouseDown:anEvent];

// -dw- if the window is clicked, the sheet should come to front, and become key,
// and the window should be immediately behind
[self orderFront:self];
Expand All @@ -1615,7 +1615,7 @@ CPTexturedBackgroundWindowMask
[_windowView mouseMoved:anEvent];
break;
}

return;
}

Expand Down Expand Up @@ -2369,29 +2369,29 @@ CPTexturedBackgroundWindowMask
[attachedSheet setFrame:sheetFrame display:YES animate:NO];
}

/* @ignore
/* @ignore
Starting point for sheet session, called from CPApplication beginSheet:
*/
- (void)_attachSheet:(CPWindow)aSheet modalDelegate:(id)aModalDelegate
- (void)_attachSheet:(CPWindow)aSheet modalDelegate:(id)aModalDelegate
didEndSelector:(SEL)aDidEndSelector contextInfo:(id)aContextInfo
{
if (_sheetContext)
{
[CPException raise:CPInternalInconsistencyException
[CPException raise:CPInternalInconsistencyException
reason:@"The target window of beginSheet: already has a sheet, did you forget orderOut: ?"];
return;
}

var sheetFrame = [aSheet frame];
_sheetContext = {"sheet":aSheet, "modalDelegate":aModalDelegate, "endSelector":aDidEndSelector,
"contextInfo":aContextInfo, "frame":CGRectMakeCopy(sheetFrame), "returnCode":-1,

_sheetContext = {"sheet":aSheet, "modalDelegate":aModalDelegate, "endSelector":aDidEndSelector,
"contextInfo":aContextInfo, "frame":CGRectMakeCopy(sheetFrame), "returnCode":-1,
"opened": NO };

[self _attachSheetWindow];
}

/* @ignore
/* @ignore
Called to animate the sheet in. The timer seems to solve a bug where sheets would
be partially animated under certain conditions.
*/
Expand All @@ -2400,14 +2400,14 @@ CPTexturedBackgroundWindowMask
_sheetContext["isAttached"] = YES;

// it would be ideal to block here and spin an event loop, until attach is complete
[CPTimer scheduledTimerWithTimeInterval:0.0
target:self
[CPTimer scheduledTimerWithTimeInterval:0.0
target:self
selector:@selector(_sheetShouldAnimateIn:)
userInfo:nil
repeats:NO];
}

/* @ignore
/* @ignore
Called to end the sheet. Note that orderOut: is needed to animate the sheet out, as in Cocoa.
The sheet isn't completely gone until _cleanupSheetWindow gets called.
*/
Expand All @@ -2421,24 +2421,24 @@ CPTexturedBackgroundWindowMask
if (delegate != nil && endSelector != nil)
{
if (_sheetContext["isAttached"])
objj_msgSend(delegate, endSelector, _sheetContext["sheet"], _sheetContext["returnCode"],
objj_msgSend(delegate, endSelector, _sheetContext["sheet"], _sheetContext["returnCode"],
_sheetContext["contextInfo"]);
else
_sheetContext["deferDidEndSelector"] = YES;
}
}

/* @ignore
Called to animate the sheet out. If called while animating in, schedules an animate
/* @ignore
Called to animate the sheet out. If called while animating in, schedules an animate
out at completion
*/
- (void)_detachSheetWindow
{
_sheetContext["isAttached"] = NO;

// it would be ideal to block here and spin the event loop, until attach is complete
[CPTimer scheduledTimerWithTimeInterval:0.0
target:self
[CPTimer scheduledTimerWithTimeInterval:0.0
target:self
selector:@selector(_sheetShouldAnimateOut:)
userInfo:nil
repeats:NO];
Expand Down Expand Up @@ -2471,15 +2471,15 @@ CPTexturedBackgroundWindowMask

if (deferDidEnd)
{
var delegate = _sheetContext["modalDelegate"];
var delegate = _sheetContext["modalDelegate"],
selector = _sheetContext["endSelector"],
returnCode = _sheetContext["returnCode"],
contextInfo = _sheetContext["contextInfo"],
contextInfo = _sheetContext["contextInfo"];

// context must be destroyed, since didEnd might want to attach another sheet
_sheetContext = nil;
sheet._parentView = nil;

objj_msgSend(delegate, selector, sheet, returnCode, contextInfo);
}
else
Expand All @@ -2496,8 +2496,8 @@ CPTexturedBackgroundWindowMask
if (anim._window != sheet)
return;

[CPTimer scheduledTimerWithTimeInterval:0.0
target:self
[CPTimer scheduledTimerWithTimeInterval:0.0
target:self
selector:@selector(_sheetAnimationDidEnd:)
userInfo:nil
repeats:NO];
Expand All @@ -2511,10 +2511,10 @@ CPTexturedBackgroundWindowMask
_sheetContext["isClosing"])
return;

var sheet = _sheetContext["sheet"]
var sheet = _sheetContext["sheet"],
sheetFrame = [sheet frame],
frame = [self frame];

[self _setUpMasksForView:[sheet contentView]];

sheet._isSheet = YES;
Expand All @@ -2526,26 +2526,25 @@ CPTexturedBackgroundWindowMask
endFrame = CGRectMake(originx, originy, sheetFrame.size.width, sheetFrame.size.height);

[[CPNotificationCenter defaultCenter] postNotificationName:CPWindowWillBeginSheetNotification object:self];
// if sheet is attached to a modal window, the sheet runs

// if sheet is attached to a modal window, the sheet runs
// as if itself and the parent window are modal
sheet._isModal = NO;
if ([CPApp modalWindow]===self)
if ([CPApp modalWindow] === self)
{
[CPApp runModalForWindow:sheet];
sheet._isModal = YES;
}

[sheet orderFront:self];
[sheet setFrame:startFrame display:YES animate:NO];

_sheetContext["opened"] = YES;
_sheetContext["shouldClose"] = NO;
_sheetContext["isOpening"] = YES;

[sheet _setFrame:endFrame delegate:self duration:[self animationResizeTime:endFrame] curve:CPAnimationEaseOut];


// NOTE: cocoa doesn't make window key until animation is done, but a
// keypress while animating eventually gets to the window. Therefore,
// there must be a runloop specifically designed for sheets?
Expand All @@ -2565,19 +2564,19 @@ CPTexturedBackgroundWindowMask
_sheetContext["shouldClose"] = YES;
return;
}

if (_sheetContext["isClosing"])
return;

_sheetContext["opened"] = NO;
_sheetContext["frame"] = startFrame;
_sheetContext["isClosing"] = YES;

// the parent window can be orderedOut to disable the sheet animate out, as in Cocoa
if ([self isVisible])
{
endFrame.size.height = 0;
[self _setUpMasksForView:[sheet contentView]];
[self _setUpMasksForView:[sheet contentView]];
[sheet _setFrame:endFrame delegate:self duration:[self animationResizeTime:endFrame] curve:CPAnimationEaseIn];
}
else
Expand Down
17 changes: 9 additions & 8 deletions AppKit/CPWindow/_CPStandardWindowView.j
Expand Up @@ -330,13 +330,13 @@ var STANDARD_GRADIENT_HEIGHT = 41.0,

[_headView setFrameSize:CGSizeMake(width, [self toolbarMaxY])];
[_dividerView setFrame:CGRectMake(0.0, CGRectGetMaxY([_headView frame]), width, 1.0)];

var dividerMaxY = 0;
if (![_dividerView isHidden])
dividerMaxY = CGRectGetMaxY([_dividerView frame]);

[_bodyView setFrame:CGRectMake(0.0, dividerMaxY, width, CGRectGetHeight(bounds) - dividerMaxY)];

var leftOffset = 8;

if (_closeButton)
Expand All @@ -348,7 +348,7 @@ var STANDARD_GRADIENT_HEIGHT = 41.0,

var contentRect = CGRectMake(0.0, dividerMaxY, width, CGRectGetHeight([_bodyView frame]));

[[theWindow contentView] setFrame:contentRect];
[[theWindow contentView] setFrame:contentRect];
}
/*
- (void)setAnimatingToolbar:(BOOL)isAnimatingToolbar
Expand Down Expand Up @@ -415,7 +415,7 @@ var STANDARD_GRADIENT_HEIGHT = 41.0,
- (void)_enableSheet:(BOOL)enable
{
[super _enableSheet:enable];

[_headView setHidden:enable];
[_dividerView setHidden:enable];
[_closeButton setHidden:enable];
Expand All @@ -434,9 +434,10 @@ var STANDARD_GRADIENT_HEIGHT = 41.0,
var dy = CGRectGetHeight([_headView frame]) + CGRectGetHeight([_dividerView frame]);
if (enable)
dy = -dy;

var newHeight = CGRectGetMaxY(frame) + dy;
var newWidth = CGRectGetMaxX(frame);

var newHeight = CGRectGetMaxY(frame) + dy,
newWidth = CGRectGetMaxX(frame);

frame.size.height += dy;

[self setFrameSize:CGSizeMake(newWidth, newHeight)];
Expand Down
10 changes: 5 additions & 5 deletions AppKit/CPWindow/_CPWindowView.j
Expand Up @@ -41,7 +41,7 @@ var _CPWindowViewResizeIndicatorImage = nil;
CGPoint _mouseDraggedPoint;

CGRect _cachedScreenFrame;

CPView _sheetShadowView;
}

Expand Down Expand Up @@ -208,13 +208,13 @@ var _CPWindowViewResizeIndicatorImage = nil;
- (void)setFrameSize:(CGSize)newSize
{
[super setFrameSize:newSize];

// reposition sheet if the parent window resizes or moves
var theWindow = [self window];

if ([theWindow attachedSheet])
[theWindow _setAttachedSheetFrameOrigin];
}
}

- (void)setShowsResizeIndicator:(BOOL)shouldShowResizeIndicator
{
Expand Down Expand Up @@ -386,7 +386,7 @@ var _CPWindowViewResizeIndicatorImage = nil;
var bundle = [CPBundle bundleForClass:[CPWindow class]];
_sheetShadowView = [[CPView alloc] initWithFrame:CGRectMake(0, 0, CGRectGetWidth([self bounds]), 8)];
[_sheetShadowView setAutoresizingMask:CPViewWidthSizable];
[_sheetShadowView setBackgroundColor:[CPColor colorWithPatternImage:[[CPImage alloc]
[_sheetShadowView setBackgroundColor:[CPColor colorWithPatternImage:[[CPImage alloc]
initWithContentsOfFile:[bundle pathForResource:@"CPWindow/CPWindowAttachedSheetShadow.png"] size:CGSizeMake(9,8)]]];
[self addSubview:_sheetShadowView];
}
Expand Down

0 comments on commit bff2277

Please sign in to comment.