mgarin / weblaf

WebLaF is a fully open-source Look & Feel and component library written in pure Java for cross-platform desktop Swing applications.
http://weblookandfeel.com
GNU General Public License v3.0
1.14k stars 235 forks source link

Possibility to turn off progress bar animation #120

Closed Sciss closed 8 years ago

Sciss commented 10 years ago

I can't seem to find a way to disable the animation for progress bars. While I don't mind having the animation during actual processing, I have an application where the progress bar remains visible after finishing at 100%. I think the animation should always stop when the bar reaches 100% (this is for example what the Apple LaF does), but also that there should be a way to customise the UI to not use animation at all.

I guess it should be a switch on WebProgressBarStyle. I can turn off visible animation via

WebProgressBarStyle.highlightWhite = new Color(255, 255, 255, 0)
WebProgressBarStyle.highlightDarkWhite = new Color(255, 255, 255, 0)

Yet that would keep the LaF using CPU power for running an invisible animation, right?

I also tried StyleConstants.animate = false but it doesn't seem to have any effect here.

mgarin commented 10 years ago

A good note, I will add a few options to progress bar to disable/control animation.

I will also disable the animation as soon as progress bar is at 100% - animating it after is indeed just a waste of processing time. That doesn't apply to indeterminate progress bar though - it will still be animated until removed or changed to non-indeterminate.

Sciss commented 10 years ago

Thanks. A question about indeterminate bars - I use them sometimes in terms of visible/hidden. Does WebLaF stop the animation when a bar becomes invisible, or do I actually have to remove it from its parent?

mgarin commented 10 years ago

WebLaF animation timer doesn't actually stop, but it causes no effect when component is not visible - repaint calls are simply ignored so even if there would be like 1000 repaint calls per second it will have zero impact on performance. It does waste some micro processing time but it is too small if compare to Swing drawing operations.

But anyway, I will fix this case as well, timer will pause if animation is not needed and will resume when it should be running. Thanks for pointing out this case :)

mgarin commented 10 years ago

These changes will be delayed till v1.29 update due to a large amount of changes already available in v1.28, but I will include them into v1.29 for sure.

mgarin commented 8 years ago

I'll be closing this now as new progress bar implementation will have all settings configurable through the styles including any existing animations.