Bug 196864 - Toolbar should support animated gifs
Summary: Toolbar should support animated gifs
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 3.3   Edit
Hardware: PC All
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Carolyn MacLeod CLA
QA Contact:
URL:
Whiteboard:
Keywords: contributed
Depends on:
Blocks:
 
Reported: 2007-07-17 15:19 EDT by Raji Akella CLA
Modified: 2008-01-30 14:05 EST (History)
6 users (show)

See Also:


Attachments
Snippet source code for animated GIFs in ToolBar (5.69 KB, text/x-java)
2008-01-24 22:14 EST, Mark Powell CLA
no flags Details
a sample animated GIF (10.38 KB, image/gif)
2008-01-24 22:15 EST, Mark Powell CLA
no flags Details
another example animated GIF (44.53 KB, image/gif)
2008-01-24 22:16 EST, Mark Powell CLA
no flags Details
yet another example animated GIF (8.48 KB, image/gif)
2008-01-24 22:16 EST, Mark Powell CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Raji Akella CLA 2007-07-17 15:19:09 EDT
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:
Comment 1 Steve Northover CLA 2008-01-14 15:26:55 EST
We should write a snippet that shows this.  I can't see us adding support to SWT.  The platforms don't do it.
Comment 2 Benjamin Cabé CLA 2008-01-14 15:47:41 EST
Yes snippet would be enough, and great ! :)
Comment 3 Carolyn MacLeod CLA 2008-01-15 17:16:21 EST
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
Comment 4 Mark Powell CLA 2008-01-19 20:55:33 EST
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.
Comment 5 Mark Powell CLA 2008-01-20 02:14:53 EST
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.

Comment 6 Carolyn MacLeod CLA 2008-01-20 15:20:56 EST
Thank-you, Mark!
I look forward to trying it out - it can go on our snippets page.
Carolyn
Comment 7 Steve Northover CLA 2008-01-21 11:56:50 EST
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.
Comment 8 Carolyn MacLeod CLA 2008-01-21 14:01:31 EST
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)
Comment 9 Mark Powell CLA 2008-01-24 22:14:36 EST
Created attachment 87829 [details]
Snippet source code for animated GIFs in ToolBar
Comment 10 Mark Powell CLA 2008-01-24 22:15:19 EST
Created attachment 87830 [details]
a sample animated GIF
Comment 11 Mark Powell CLA 2008-01-24 22:16:02 EST
Created attachment 87831 [details]
another example animated GIF
Comment 12 Mark Powell CLA 2008-01-24 22:16:42 EST
Created attachment 87832 [details]
yet another example animated GIF
Comment 13 Mark Powell CLA 2008-01-24 22:22:40 EST
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.
Comment 14 Steve Northover CLA 2008-01-25 12:00:48 EST
Great!  Carolyn can't get to this right now but she will on Monday.
Comment 15 Carolyn MacLeod CLA 2008-01-28 17:15:42 EST
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!
Comment 16 Steve Northover CLA 2008-01-30 14:05:11 EST
Thanks for the contribution.