diff --git a/darwin/progressbar.m b/darwin/progressbar.m index a26874f1..87a9c8d2 100644 --- a/darwin/progressbar.m +++ b/darwin/progressbar.m @@ -27,10 +27,31 @@ struct uiProgressBar { uiDarwinControlAllDefaults(uiProgressBar, pi) +int uiProgressBarValue(uiProgressBar *p) +{ + if ([p->pi getIndeterminate]) { + return -1; + } + + return (int) [p->pi getDoubleValue]; +} + void uiProgressBarSetValue(uiProgressBar *p, int value) { + if (value == -1) { + [p->pi setIndeterminate:YES]; + [p->pi startAnimation:p->pi]; + return; + } + + if ([p->pi getIndeterminate]) { + [p->pi setIndeterminate:NO]; + [p->pi stopAnimation:p->pi]; + } + if (value < 0 || value > 100) userbug("Value %d out of range for a uiProgressBar.", value); + // on 10.8 there's an animation when the progress bar increases, just like with Aero if (value == 100) { [p->pi setMaxValue:101];