NSWindow subclass VERY slow to resize
NSWindow subclass VERY slow to resize
- Subject: NSWindow subclass VERY slow to resize
- From: Daniel Weber <email@hidden>
- Date: Fri, 26 Mar 2010 03:36:12 -0700
Ok, I finally managed to get all the drawing/event-handling code
working for my borderless window subclass. The only problem I have
left now is performance. I have a basic formula in the mouseDown
method that does a little arithmetic and sets the window's new frame.
It works fine when the window is < 400 x 400, more or less. However,
when the window starts to get bigger, around 800x800 maybe, there is
very noticeable slowdown as the window is redrawn. I find this odd
because my drawing code is not complicated at all (I'm drawing a
rounded rect with a little arrow pointing up):
- (void)drawRect:(NSRect)rect
{
roundedRect.size.height = roundedRect.size.height - window.arrowHeight;
NSBezierPath *roundRectPath = [NSBezierPath
bezierPathWithRoundedRect:roundedRect xRadius:10.0 yRadius:10.0];
if (window.drawsArrow) {
NSPoint p1 = NSMakePoint(NSMidX(rect) - window.arrowWidth / 2.0,
NSMaxY(roundedRect));
NSPoint p2 = NSMakePoint(NSMidX(rect), NSMaxY(rect));
NSPoint p3 = NSMakePoint(NSMidX(rect) + window.arrowWidth / 2.0,
NSMaxY(roundedRect));
NSBezierPath *trianglePath = [NSBezierPath bezierPath];
[trianglePath moveToPoint:p1];
[trianglePath lineToPoint:p2];
[trianglePath lineToPoint:p3];
[trianglePath closePath];
[roundRectPath appendBezierPath:trianglePath];
}
}
Is there some way to speed this up? Could something else be going on?
Thanks.
_______________________________________________
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