NSWindow - flickering shadow during height animation (borderless, transparent)
NSWindow - flickering shadow during height animation (borderless, transparent)
- Subject: NSWindow - flickering shadow during height animation (borderless, transparent)
- From: Robert Vojta <email@hidden>
- Date: Tue, 23 Apr 2013 12:55:22 +0200
Hallo all,
I do use borderless & transparent NSWindow with shadow. The way I do initialize this window is at the end of this email. I experienced lot of problems with shadow, but found in Apple examples that the only way to fix shadow (= read to display it correctly) is to call …
[self display];
[self setHasShadow:NO];
[self setHasShadow:YES];
… I tried to use [self invalidateShadow], etc. but nothing did work. Shadow was always crippled (not following shape of the window, smaller height, …). Just these three lines do work. So far, so good. Whenever window frame changes, I do send these three message in my viewFrameDidChange: method. Works perfectly.
But now, I do want to animate height of the window. I do use auto layout and I simply call …
[self.heightConstraint.animator setConstant:newHeight];
… in one of my subviews. Window is resizing correctly, stays where it should be, etc. But …
- shadow is flickering,
- first guess was it's because of setHasShadow:NO/YES in viewFrameDidChange: method,
- when I comment out setHasShadow:NO/YES along with [self display], it's much more worse, because it's flickering and draws shadow artifacts around the window,
My question is - how one can animate borderless/transparent window height with shadow, which is not flickering and is not crippled when view/window height did change? It drives me crazy. Searching on SO, searching in archives, nothing useful found yet.
Regards,
Robert
P.S. Here's the link where you can see flickering shadow - http://d.pr/v/lbkQ
- (id)initWithView:(NSView *)view anchorPoint:(NSPoint)anchorPoint position:(NSPoint)position distance:(CGFloat)distance {
if ( !view ) {
return nil;
}
NSSize size = view.intrinsicContentSize;
NSRect contentRect = NSMakeRect( 0, 0, size.width, size.height );
self = [super initWithContentRect:contentRect
styleMask:NSBorderlessWindowMask
backing:NSBackingStoreBuffered
defer:NO];
if ( !self ) {
return nil;
}
_windowView = view;
_anchorPoint = anchorPoint;
_position = position;
_distance = distance;
[self setContentView:_windowView];
[self setExcludedFromWindowsMenu:YES];
[self setMovableByWindowBackground:NO];
[self setOpaque:NO];
[self setBackgroundColor:[NSColor clearColor]];
[self setHasShadow:NO];
[self useOptimizedDrawing:YES];
[self setReleasedWhenClosed:NO];
[self setFrame:[self windowRectWithSize:contentRect.size] display:YES];
[self setAnchorAttribute:NSLayoutAttributeTop forOrientation:NSLayoutConstraintOrientationVertical];
[self setAnchorAttribute:NSLayoutAttributeCenterX forOrientation:NSLayoutConstraintOrientationHorizontal];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(viewFrameDidChange:)
name:NSViewFrameDidChangeNotification
object:nil];
return self;
}
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden