Animating GTK+ widgets in real time (slowness of)



Hi guys,

I'm trying to do something unorthadox and I was wondering if anyone here
has an idea to speed things up a bit.

----to set the scene.

you have a window, with a GtkPaned splitting it into two halfs, the
window covers the bottom half of the pane, so the drag bar in the
middle, is at the bottom of the window being displayed.

on clicking a button in the top pane, I want to increase the size of the
window, to EXPOSE the bottom half of the pane, and I want to do it like
an animation, so clicking it will "expand out" the lower half,
containing other controls and information.

i suppose like windows media player, when you click to open the
playlist, it expands out the side of the window.

but when I do this, it's incredibly slow.  The top half of the pane
contains quite a few widgets, around 10-15.

----problem.

now, if I put a notebook in the top pane, with two tabs, one with the
widgets, the other just with a label inside saying "please wait" then
upon clicking the button, flip to the other tab, animate the window,
then flip back, it animates smoothly, but when I Dont do this, it's all
jerky and rubbish.

the animation isnt supposed to be "interactive" so it's quite ok to
block the user from doing anything whilst the animation does it's job,
since they will most likely wait anyway, plus it's only 1-2 seconds, so
it's not a long animation.  When your system gets a little loaded, the
animation is painful and jerky to watch.

so, I want it to be smooth and silky, if anyone has a windows machine,
and GTK+ you can take the zip, VIRUS SCAN IT! and run the exe to see
what I am trying to do.  here is a source code snippet of the function
which does the animation.

<source>
void Window_Main::showHelp(void)
{
    m_help = true;
    animateWindow(300,300,500,m_animationspeed);
}

void Window_Main::hideHelp(bool newstate)
{
    m_help = newstate;
    animateWindow(500,500,300,-m_animationspeed);
}

void Window_Main::animateWindow(int ch, int sh, int eh, int off)
{
    while(1){		
      if(ch == sh){
        // the commented out line is the notebook which I flip the page
        // in the example I gave above
        //gtk_notebook_set_current_page(GTK_NOTEBOOK(m_ITest),1);
        gtk_notebook_set_current_page(GTK_NOTEBOOK(m_IAdmin),1);
      }
		
      ch+=off;
		
      gtk_window_resize(GTK_WINDOW(m_Window),500,ch);
      gtk_main_iteration();
		
      if(ch == eh){
        // obviously, this is where I flip the page back again
        //gtk_notebook_set_current_page(GTK_NOTEBOOK(m_ITest),0);
        return;
      }
    }
}
</source>

--- end note.

so, if you have anything that could help me, then please let me know! thanks

if you try the demo, to understand what I mean, click the "Start" button
and then click the "Stop" button, you'll see the animation at the bottom
of the window

oh and if this app is of use to you, say you are learning spanish? then
you can get back in touch with me and I'll explain how it works, if you
can't figure it out already, thanks guys!

(I found out that I can't send the zip file, so if you want to see the program to run it, then you can contact me and I'll reply to you directly)

Chris Thomas




--
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.308 / Virus Database: 266.6.0 - Release Date: 02/03/2005





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]