[mythtv] Time-based animation controller in mythui

Bryan Mayland bmayland at leoninedev.com
Fri Mar 10 16:15:20 UTC 2006


After reading the thread "New fade effect in front end not working well" 
and looking through the mythui code, I've spent some time thinking about 
how to improve the moves and fades done in the mythui. 

The problem is that mythui uses interval-step as an animation 
controller, which would normally not be a problem considering that the 
Pulse() events should be coming at regular intervals.  However, in cases 
where draw speed is for some reason limited the interval between these 
events becomes longer than the designer anticipated, leading to the 
undesired side effect of really slow looking animation. 

If we can agree that when we say "we want to do transition X in 1 
second" we want to actually do it in 1 second, as opposed to doing it in 
25 smooth steps, I can replace the current interval-step animation 
controller with a time-based attribute animation controller.  I'll start 
by defining the attribute animator itself, then move up to the controller.

If we want to size, move or fade a UI element we need to define an 
animator (names are just placeholders right now)
class AttributeAnimator <T> {
  Attribute a; // set to Height, Width, Top, Left, or Alpha
  Duration d; // duration of the effect from start to finish
  AnimateMode mode; // see section below about modes
  List<T> values; // used when mode is "Value"
  T from;  // used for mode "FromTo" and "FromBy"
  T to; // used for mode "FromTo" and "To"
  T by; // used for mode "FromBy" and "By"
  // CalcMode c;  can be added later, version 1 uses linear interpolation
  int repeatcount;
}

AnimateMode indicates how the controller determines start and end points:
  FromTo: Most common mode.  Animate value from to value to over 
duration, repeat restarts at from
  FromBy: Animate value from to value from+by over duration, repeat 
restarts at from
  To: Animate value from component's original value to value to over 
duration, repeat has no effect.
  By: Animate value from component's original value to component's 
original value + by over duration, repeat starts at final value
  Value: Animate from first value to last value over duration.  e.g. 
10;100;10 will animate from 10 to 100 then back to 10.  Repeat restarts 
from first value

A global animation controller (owned by mythmainwindow I'm guessing) 
will be provided to the UI elements during the Pulse event, which can 
then be passed to the element's individual AttributeAnimator controls.  
These will be used in place of the individual Pulse* events currently 
used.  This global controller would only hold timing information and be 
able to provide a "current" value, based on the parameters set in the 
AttributeAnimator objects.

Using this system, the fades moves and resizes would animate the same 
speed on everyone's machine independent of the interval between Pulse() 
calls.  I have a fairly solid game development / opengl background and 
can code this. Comments?


More information about the mythtv-dev mailing list