mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-09-24 19:30:42 +00:00
Merge branch 'refs/heads/cppopover-fix-transient-delegate-calls' into cappuccino
This commit is contained in:
+35
-14
@@ -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;
|
||||
|
||||
|
||||
@@ -73,7 +73,7 @@ var CPPopoverDelegate_popover_willShow_ = 1 << 0,
|
||||
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark INitialization
|
||||
#pragma mark Initialization
|
||||
|
||||
/*!
|
||||
Initialize the CPPopover witn default values
|
||||
@@ -221,6 +221,7 @@ var CPPopoverDelegate_popover_willShow_ = 1 << 0,
|
||||
|
||||
[_attachedWindow setAppearance:_appearance];
|
||||
[_attachedWindow setAnimates:_animates];
|
||||
[_attachedWindow setDelegate:self];
|
||||
[_attachedWindow setMovableByWindowBackground:NO];
|
||||
[_attachedWindow setFrame:[_attachedWindow frameRectForContentRect:[[_contentViewController view] frame]]];
|
||||
[_attachedWindow setContentView:[_contentViewController view]];
|
||||
@@ -268,8 +269,28 @@ var CPPopoverDelegate_popover_willShow_ = 1 << 0,
|
||||
[self close];
|
||||
}
|
||||
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Delegates
|
||||
|
||||
/*! @ignore */
|
||||
- (BOOL)attachedWindowShouldClose:(_CPAttachedWindow)anAttachedWindow
|
||||
{
|
||||
[self close];
|
||||
|
||||
// we return NO, because we want the CPPopover to compute
|
||||
// if the attached can be close in order to send delegate messages
|
||||
return NO;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
var CPPopoverNeedsComputeKey = @"CPPopoverNeedsComputeKey",
|
||||
CPPopoverAppearanceKey = @"CPPopoverAppearanceKey",
|
||||
CPPopoverAnimatesKey = @"CPPopoverAnimatesKey",
|
||||
CPPopoverContentViewControllerKey = @"CPPopoverContentViewControllerKey",
|
||||
CPPopoverDelegateKey = @"CPPopoverDelegateKey",
|
||||
CPPopoverBehaviorKey = @"CPPopoverBehaviorKey";
|
||||
|
||||
@implementation CPPopover (CPCoding)
|
||||
|
||||
@@ -279,12 +300,12 @@ var CPPopoverDelegate_popover_willShow_ = 1 << 0,
|
||||
|
||||
if (self)
|
||||
{
|
||||
_needsCompute = [aCoder decodeIntForKey:@"_needsCompute"];
|
||||
_appearance = [aCoder decodeIntForKey:@"_appearance"];
|
||||
_animates = [aCoder decodeBoolForKey:@"_animates"];
|
||||
_contentViewController = [aCoder decodeObjectForKey:@"_contentViewController"];
|
||||
[self setDelegate:[aCoder decodeObjectForKey:@"_delegate"]];
|
||||
[self setBehaviour:[aCoder decodeIntForKey:@"_behavior"]];
|
||||
_needsCompute = [aCoder decodeIntForKey:CPPopoverNeedsComputeKey];
|
||||
_appearance = [aCoder decodeIntForKey:CPPopoverAppearanceKey];
|
||||
_animates = [aCoder decodeBoolForKey:CPPopoverAnimatesKey];
|
||||
_contentViewController = [aCoder decodeObjectForKey:CPPopoverContentViewControllerKey];
|
||||
[self setDelegate:[aCoder decodeObjectForKey:CPPopoverDelegateKey]];
|
||||
[self setBehaviour:[aCoder decodeIntForKey:CPPopoverBehaviorKey]];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
@@ -293,12 +314,12 @@ var CPPopoverDelegate_popover_willShow_ = 1 << 0,
|
||||
{
|
||||
[super encodeWithCoder:aCoder];
|
||||
|
||||
[aCoder encodeInt:_behavior forKey:@"_behavior"];
|
||||
[aCoder encodeInt:_appearance forKey:@"_appearance"];
|
||||
[aCoder encodeBool:_needsCompute forKey:@"_needsCompute"];
|
||||
[aCoder encodeObject:_contentViewController forKey:@"_contentViewController"];
|
||||
[aCoder encodeObject:_delegate forKey:@"_delegate"];
|
||||
[aCoder encodeObject:_animates forKey:@"_animates"];
|
||||
[aCoder encodeBool:_needsCompute forKey:CPPopoverNeedsComputeKey];
|
||||
[aCoder encodeInt:_appearance forKey:CPPopoverAppearanceKey];
|
||||
[aCoder encodeObject:_animates forKey:CPPopoverAnimatesKey];
|
||||
[aCoder encodeObject:_contentViewController forKey:CPPopoverContentViewControllerKey];
|
||||
[aCoder encodeObject:_delegate forKey:CPPopoverDelegateKey];
|
||||
[aCoder encodeInt:_behavior forKey:CPPopoverBehaviorKey];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -30,6 +30,9 @@ CPClosableOnBlurWindowMask = 1 << 4;
|
||||
CPPopoverAppearanceMinimal = 0;
|
||||
CPPopoverAppearanceHUD = 1;
|
||||
|
||||
var _CPAttachedWindow_attachedWindowShouldClose_ = 1 << 0,
|
||||
_CPAttachedWindow_attachedWindowDidClose_ = 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(attachedWindowDidClose:)])
|
||||
_implementedDelegateMethods |= _CPAttachedWindow_attachedWindowDidClose_;
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Observer
|
||||
|
||||
@@ -408,12 +427,9 @@ CPPopoverAppearanceHUD = 1;
|
||||
{
|
||||
if (_closeOnBlur && !_isClosed)
|
||||
{
|
||||
// set a close flag to avoid infinite loop
|
||||
_isClosed = YES;
|
||||
if (!_delegate || ((_implementedDelegateMethods & _CPAttachedWindow_attachedWindowShouldClose_)
|
||||
&& [_delegate attachedWindowShouldClose:self]))
|
||||
[self close];
|
||||
|
||||
if (_delegate && [_delegate respondsToSelector:@selector(didAttachedWindowClose:)])
|
||||
[_delegate didAttachedWindowClose:self];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -478,6 +494,9 @@ CPPopoverAppearanceHUD = 1;
|
||||
*/
|
||||
- (void)close
|
||||
{
|
||||
// set a close flag to avoid infinite loop
|
||||
_isClosed = YES;
|
||||
|
||||
if (_animates && typeof(_DOMElement.style.WebkitTransform) != "undefined")
|
||||
{
|
||||
_DOMElement.style.opacity = 0;
|
||||
@@ -494,8 +513,8 @@ CPPopoverAppearanceHUD = 1;
|
||||
|
||||
_shouldPerformAnimation = _animates;
|
||||
|
||||
if (_delegate && [_delegate respondsToSelector:@selector(didAttachedWindowClose:)])
|
||||
[_delegate didAttachedWindowClose:self];
|
||||
if (_implementedDelegateMethods & _CPAttachedWindow_attachedWindowDidClose_)
|
||||
[_delegate attachedWindowDidClose:self];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -84,7 +84,7 @@
|
||||
- (IBAction)open:(id)sender
|
||||
{
|
||||
var g;
|
||||
switch([buttonGravity title])
|
||||
switch ([buttonGravity title])
|
||||
{
|
||||
case "Automatic":
|
||||
g = nil;
|
||||
@@ -104,7 +104,7 @@
|
||||
}
|
||||
|
||||
var a;
|
||||
switch([buttonStyle title])
|
||||
switch ([buttonStyle title])
|
||||
{
|
||||
case "Minimal":
|
||||
a = CPPopoverAppearanceMinimal;
|
||||
@@ -115,7 +115,7 @@
|
||||
}
|
||||
|
||||
var p = [[CPPopover alloc] init],
|
||||
viewC = [[CPViewController alloc] init];
|
||||
viewC = [[CPViewController alloc] init],
|
||||
view = [[CPView alloc] initWithFrame:CPRectMake(0.0, 0.0, 320, 300)],
|
||||
label = [CPTextField labelWithTitle:[buttonGravity title]];
|
||||
|
||||
@@ -136,8 +136,8 @@
|
||||
[p setDelegate:self];
|
||||
[p showRelativeToRect:nil ofView:sender preferredEdge:g];
|
||||
CPLog.info("content size - w:" + [p contentSize].width + " h:" + [p contentSize].width);
|
||||
CPLog.info("positionning rect - x: " + [p positionningRect].origin.x + " y: " + [p positionningRect].origin.x
|
||||
+ " w:" + [p positionningRect].size.width + " h:" + [p positionningRect].size.width);
|
||||
CPLog.info("positioning rect - x: " + [p positioningRect].origin.x + " y: " + [p positioningRect].origin.x
|
||||
+ " w:" + [p positioningRect].size.width + " h:" + [p positioningRect].size.width);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user