Community
Participate
Working Groups
Build ID: 3.3 Steps To Reproduce: Currently if an animated gif is passed to the toolbar it will just display a still image instead of the animation itself. We need toolbars to have the ability to support and display animated gifs. More information:
We should write a snippet that shows this. I can't see us adding support to SWT. The platforms don't do it.
Yes snippet would be enough, and great ! :)
This would take me a while to write, and I am in the middle of other things. If you want to have a go at it yourself, you can start with Snippet141, which shows how to run one animated GIF by drawing on a shell. http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet141.java Because a toolbar has many tool items, you will have to keep an array of everything - loaders, imageDataArrays (an array of arrays), threads, etc - one per tool item. And you might want to pre-create your offscreen images (an array of arrays of these, also <g>) for better efficiency - Snippet141 doesn't do that. You will have to use asyncExec (or maybe syncExec, to get the timing right?) to set each image into the tool item. (instead of drawing on the shellGC). Good luck, Carolyn
I think I'll take a shot at writing this snippet. Should be a few weeks before I get it done and approved to post it here. If anyone has already started on it, please let me know.
Hey, I wrote the snippet...didn't take as long as I thought. It generally follows Carolyn's specifications. It lets you multi-select and open any number of animated GIF files and show them in an animated fashion in a ToolBar. I did go ahead and render all of the images for each frame of animation first and put them in arrays so that the animation thread can swap in a new image very quickly. Pretty nifty. After I get release approval from my organization I'll post the snippet here where it can be tested. Hopefully this will take about a week or so.
Thank-you, Mark! I look forward to trying it out - it can go on our snippets page. Carolyn
Great! Please read http://www.eclipse.org/swt/snippets/ for a description of an SWT snippet. The issue here is that snippets are minimal and describe one main idea. They are minimal in terms of number of lines of code and classes. Most snippets only contain only on class and a main(). Yours may be different though. Good luck!! We're hot for your code.
It's ok if it isn't one class and one main - I can make it a separate example. (i.e. it doesn't have to ba a snippet)
Created attachment 87829 [details] Snippet source code for animated GIFs in ToolBar
Created attachment 87830 [details] a sample animated GIF
Created attachment 87831 [details] another example animated GIF
Created attachment 87832 [details] yet another example animated GIF
As you can see, I posted my code. If you would care to re-organize it into one main() method, that's fine. I tend to think that separating concerns within the example into smaller methods makes it more readable and easier to understand, but I also understand the usefulness of conventions. The intended usage is, run the snippet, (Multi-)select one or more GIF files in the FileDialog, and it will load each image, render all the frames, build ToolItems for each of them, and start an animation thread for each of them that flips the frames. As you can see I borrowed heavily from the existing Animated GIF snippet code in writing this. At any rate, it's all yours...hope you like.
Great! Carolyn can't get to this right now but she will on Monday.
OK, this is in. I kept the extra 2 methods instead of moving the code into main, because we do have a dozen or so snippets that have several methods. Other than adding a title to the dialog, using import *, and changing the class name to Snippet288, the code is all yours. Thanks very much, Mark!
Thanks for the contribution.