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 Mar 25, 2012
2 parents da80176 + 96a0385 commit 4172ecf
Show file tree
Hide file tree
Showing 10 changed files with 213 additions and 174 deletions.
2 changes: 1 addition & 1 deletion AppKit/CPOutlineView.j
Original file line number Diff line number Diff line change
Expand Up @@ -996,7 +996,7 @@ var CPOutlineViewCoalesceSelectionNotificationStateOff = 0,
_disclosureControlData = nil;
_disclosureControlQueue = [];

// fIXME: really?
// FIXME: really?
[self reloadData];
}

Expand Down
85 changes: 31 additions & 54 deletions AppKit/CPPopover.j
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,6 @@ CPPopoverBehaviorApplicationDefined = 0;
CPPopoverBehaviorTransient = 1;
CPPopoverBehaviorSemitransient = 2;

CPPopoverAnimationStyleLion = 0;
CPPopoverAnimationStyleIOS = 1;

var CPPopoverDelegate_popover_willShow_ = 1 << 0,
CPPopoverDelegate_popover_didShow_ = 1 << 1,
CPPopoverDelegate_popover_shouldClose_ = 1 << 2,
Expand Down Expand Up @@ -67,13 +64,11 @@ var CPPopoverDelegate_popover_willShow_ = 1 << 0,
@outlet id _delegate @accessors(getter=delegate);

BOOL _animates @accessors(property=animates);
int _animationStyle;
BOOL _shown @accessors(getter=shown);
int _appearance @accessors(property=appearance);
int _behavior @accessors(getter=behavior);

BOOL _needsCompute;
_CPAttachedWindow _attachedWindow;
BOOL _needsNewAttachedWindow;
int _implementedDelegateMethods;
}

Expand All @@ -90,12 +85,10 @@ var CPPopoverDelegate_popover_willShow_ = 1 << 0,
{
if (self = [super init])
{
_animates = YES;
_animationStyle = CPPopoverAnimationStyleLion;
_appearance = CPPopoverAppearanceMinimal;
_behavior = CPPopoverBehaviorApplicationDefined;
_needsCompute = YES;
_shown = NO;
_animates = YES;
_appearance = CPPopoverAppearanceMinimal;
_behavior = CPPopoverBehaviorApplicationDefined;
_needsNewAttachedWindow = YES;
}

return self;
Expand All @@ -112,7 +105,7 @@ var CPPopoverDelegate_popover_willShow_ = 1 << 0,
*/
- (CGRect)positioningRect
{
if (!_attachedWindow || ![_attachedWindow isVisible])
if (![_attachedWindow isVisible])
return nil;
return [_attachedWindow frame];
}
Expand All @@ -122,7 +115,7 @@ var CPPopoverDelegate_popover_willShow_ = 1 << 0,
*/
- (void)setPositioningRect:(CGRect)aRect
{
if (!_attachedWindow || ![_attachedWindow isVisible])
if (![_attachedWindow isVisible])
return;
[_attachedWindow setFrame:aRect];
}
Expand All @@ -134,7 +127,7 @@ var CPPopoverDelegate_popover_willShow_ = 1 << 0,
*/
- (CGSize)contentSize
{
if (!_attachedWindow || ![_attachedWindow isVisible])
if (![_attachedWindow isVisible])
return nil;
return [[_contentViewController view] frameSize];
}
Expand All @@ -156,15 +149,13 @@ var CPPopoverDelegate_popover_willShow_ = 1 << 0,
*/
- (BOOL)shown
{
if (!_attachedWindow)
return NO;
return [_attachedWindow isVisible];
}

/*!
Set the behaviour of the CPPopover. It can be:
- \c CPPopoverBehaviorTransient: the popover will be close if another control outside the popover become the responder
- \c CPPopoverBehaviorTransient: the popover will close if another control outside the popover becomes the responder
- \c CPPopoverBehaviorApplicationDefined: (DEFAULT) the application is responsible for closing the popover
@param aBehaviour the desired behaviour
Expand All @@ -175,31 +166,9 @@ Set the behaviour of the CPPopover. It can be:
return;

_behavior = aBehaviour;
_needsCompute = YES;
}

/*!
Returns the current animation style.
*/
- (int)animationStyle
{
return _animationStyle;
}

/*!
Set the animation style of the CPPopover. It can be:
- \c CPPopoverAnimationStyleLion: (DEFAULT) the popover will zoom open and fade out when closing
- \c CPPopoverAnimationStyleIOS: the popover appears instantly when opening and fades out when closing
@param style the desired animation style
*/
- (void)setAnimationStyle:(int)style
{
_animationStyle = style;
_needsNewAttachedWindow = YES;
}


- (void)setDelegate:(id)aDelegate
{
if (_delegate === aDelegate)
Expand Down Expand Up @@ -236,21 +205,21 @@ Set the animation style of the CPPopover. It can be:
*/
- (void)showRelativeToRect:(CGRect)positioningRect ofView:(CPView)positioningView preferredEdge:(CPRectEdge)preferredEdge
{
if (_implementedDelegateMethods & CPPopoverDelegate_popover_willShow_)
[_delegate popoverWillShow:self];

if (!_contentViewController)
[CPException raise:CPInternalInconsistencyException reason:@"contentViewController must not be nil"];

if (_needsCompute || !_attachedWindow)
if (_implementedDelegateMethods & CPPopoverDelegate_popover_willShow_)
[_delegate popoverWillShow:self];

if (!_attachedWindow || _needsNewAttachedWindow || [_attachedWindow isVisible])
{
var styleMask = (_behavior == CPPopoverBehaviorTransient) ? CPClosableOnBlurWindowMask : nil;
_attachedWindow = [[_CPAttachedWindow alloc] initWithContentRect:CGRectMakeZero() styleMask:styleMask];
_needsNewAttachedWindow = NO;
}

[_attachedWindow setAppearance:_appearance];
[_attachedWindow setAnimates:_animates];
[_attachedWindow setAnimationStyle:_animationStyle];
[_attachedWindow setDelegate:self];
[_attachedWindow setMovableByWindowBackground:NO];
[_attachedWindow setFrame:[_attachedWindow frameRectForContentRect:[[_contentViewController view] frame]]];
Expand Down Expand Up @@ -281,8 +250,8 @@ Set the animation style of the CPPopover. It can be:

[_attachedWindow close];

if (_implementedDelegateMethods & CPPopoverDelegate_popover_didClose_)
[_delegate popoverDidClose:self];
// popoverDidClose will be sent from attachedWindowDidClose, since
// the attached window will close asynchronously when animating.
}


Expand All @@ -308,14 +277,22 @@ Set the animation style of the CPPopover. It can be:
{
[self close];

// we return NO, because we want the CPPopover to compute
// if the attached can be close in order to send delegate messages
// We return NO, because we want the CPPopover to determine
// if the attached window can be closed and to give us a chance
// to send delegate messages.
return NO;
}

/*! @ignore */
- (void)attachedWindowDidClose:(_CPAttachedWindow)anAttachedWindow
{
if (_implementedDelegateMethods & CPPopoverDelegate_popover_didClose_)
[_delegate popoverDidClose:self];
}

@end

var CPPopoverNeedsComputeKey = @"CPPopoverNeedsComputeKey",
var CPPopoverNeedsNewAttachedWindowKey = @"CPPopoverNeedsNewAttachedWindowKey",
CPPopoverAppearanceKey = @"CPPopoverAppearanceKey",
CPPopoverAnimatesKey = @"CPPopoverAnimatesKey",
CPPopoverContentViewControllerKey = @"CPPopoverContentViewControllerKey",
Expand All @@ -330,7 +307,7 @@ var CPPopoverNeedsComputeKey = @"CPPopoverNeedsComputeKey",

if (self)
{
_needsCompute = [aCoder decodeIntForKey:CPPopoverNeedsComputeKey];
_needsNewAttachedWindow = [aCoder decodeBoolForKey:CPPopoverNeedsNewAttachedWindowKey];
_appearance = [aCoder decodeIntForKey:CPPopoverAppearanceKey];
_animates = [aCoder decodeBoolForKey:CPPopoverAnimatesKey];
_contentViewController = [aCoder decodeObjectForKey:CPPopoverContentViewControllerKey];
Expand All @@ -344,9 +321,9 @@ var CPPopoverNeedsComputeKey = @"CPPopoverNeedsComputeKey",
{
[super encodeWithCoder:aCoder];

[aCoder encodeBool:_needsCompute forKey:CPPopoverNeedsComputeKey];
[aCoder encodeBool:_needsNewAttachedWindow forKey:CPPopoverNeedsNewAttachedWindowKey];
[aCoder encodeInt:_appearance forKey:CPPopoverAppearanceKey];
[aCoder encodeObject:_animates forKey:CPPopoverAnimatesKey];
[aCoder encodeBool:_animates forKey:CPPopoverAnimatesKey];
[aCoder encodeObject:_contentViewController forKey:CPPopoverContentViewControllerKey];
[aCoder encodeObject:_delegate forKey:CPPopoverDelegateKey];
[aCoder encodeInt:_behavior forKey:CPPopoverBehaviorKey];
Expand Down

0 comments on commit 4172ecf

Please sign in to comment.