cache delegates methods for _CPAttachedView

This commit is contained in:
Antoine Mercadal committed 2011-11-02 16:59:34 +01:00
1 parent ddb6f63ea7
commit 4303ea3584
2 files changed
+22 -3

No files matched your search

+1 -1
View File
@@ -39,7 +39,7 @@ CPPopoverBehaviorSemitransient = 2;
var CPPopoverDelegate_popover_willShow_ = 1 << 0,
CPPopoverDelegate_popover_didShow_ = 1 << 1,
CPPopoverDelegate_popover_shouldClose_ = 1 << 2,
CPPopoverDelegate_popover_willClose_ = 1 << 3,
CPPopoverDelegate_popover_willClose_ = 1 << 3,
CPPopoverDelegate_popover_didClose_ = 1 << 4;
+21 -2
View File
@@ -30,6 +30,9 @@ CPClosableOnBlurWindowMask = 1 << 4;
CPPopoverAppearanceMinimal = 0;
CPPopoverAppearanceHUD = 1;
var _CPAttachedWindow_attachedWindowShouldClose_ = 1 << 0,
_CPAttachedWindow_didAttachedWindowClose_ = 1 << 1;
/*!
@ignore
@@ -48,6 +51,7 @@ CPPopoverAppearanceHUD = 1;
BOOL _shouldPerformAnimation;
CPButton _closeButton;
float _animationDuration;
CPInteger _implementedDelegateMethods;
}
/*!
@@ -153,6 +157,21 @@ CPPopoverAppearanceHUD = 1;
[_windowView setAppearance:anAppearance];
}
- (void)setDelegate:(id)aDelegate
{
if (_delegate == aDelegate)
return;
_delegate = aDelegate;
_implementedDelegateMethods = 0;
if ([_delegate respondsToSelector:@selector(attachedWindowShouldClose:)])
_implementedDelegateMethods |= _CPAttachedWindow_attachedWindowShouldClose_;
if ([_delegate respondsToSelector:@selector(didAttachedWindowClose:)])
_implementedDelegateMethods |= _CPAttachedWindow_didAttachedWindowClose_;
}
#pragma mark -
#pragma mark Observer
@@ -408,7 +427,7 @@ CPPopoverAppearanceHUD = 1;
{
if (_closeOnBlur && !_isClosed)
{
if (!_delegate || ([_delegate respondsToSelector:@selector(attachedWindowShouldClose:)]
if (!_delegate || ((_implementedDelegateMethods & _CPAttachedWindow_attachedWindowShouldClose_)
&& [_delegate attachedWindowShouldClose:self]))
[self close];
}
@@ -494,7 +513,7 @@ CPPopoverAppearanceHUD = 1;
_shouldPerformAnimation = _animates;
if (_delegate && [_delegate respondsToSelector:@selector(didAttachedWindowClose:)])
if (_implementedDelegateMethods & _CPAttachedWindow_didAttachedWindowClose_)
[_delegate didAttachedWindowClose:self];
}