Progress bar jitters
Progress bar jitters
- Subject: Progress bar jitters
- From: Trygve Inda <email@hidden>
- Date: Thu, 24 Aug 2006 20:39:05 +0000
- Thread-topic: Progress bar jitters
In the Apple sample code, QTKitProgressTester, why does the progress bar
jitter... That is it goes up some, then jumps back?
The code in question is in a QTKit callback:
- (BOOL)movie:(QTMovie *)movie shouldContinueOperation:(NSString *)op
withPhase:(QTMovieOperationPhase)phase atPercent:(NSNumber *)percent
withAttributes:(NSDictionary *)attributes
{
BOOL shouldContinue = YES;
NSEvent* event;
double percentDoneDouble = (double)[percent doubleValue] * 100.0;
double currentPercent;
switch (phase)
{
case QTMovieOperationBeginPhase:
// set up the progress panel
[progressMsg setStringValue:op];
[progressBar setDoubleValue:0];
break;
case QTMovieOperationUpdatePercentPhase:
// update the percent done
currentPercent = [progressBar doubleValue];
if (percentDoneDouble > currentPercent + 0.5)
{
[progressBar setDoubleValue:percentDoneDouble];
[progressBar display];
}
break;
case QTMovieOperationEndPhase:
[NSApp endSheet:progressSheet returnCode:NSOKButton];
[progressSheet close];
break;
}
// cancel (if requested)
event = [progressSheet nextEventMatchingMask:NSLeftMouseUpMask
untilDate:[NSDate distantPast] inMode:NSDefaultRunLoopMode dequeue:YES];
if (event && NSPointInRect([event locationInWindow], [progressCancel
frame]))
{
[progressCancel performClick:self];
shouldContinue = NO;
}
return (shouldContinue);
}
I added the currentPercent + 0.5 part to only update if the change is
significant and it helped a bit, but is still jumpy. I am guessing it has to
do with the value setting being a double? Is it better to make it an int and
normalize it to 0-1000 for example?
Thanks,
Trygve
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden