r125: This commit was manufactured by cvs2svn to create tag 'r1_1_7-last'.
[cinelerra_cv/mob.git] / hvirtual / cinelerra / panautos.C
blob911f08ff4e1db2401b639ce1185ca8867402c7f8
1 #include "panauto.h"
2 #include "panautos.h"
3 #include "transportque.inc"
5 PanAutos::PanAutos(EDL *edl, Track *track)
6  : Autos(edl, track)
10 PanAutos::~PanAutos()
15 Auto* PanAutos::new_auto()
17         return new PanAuto(edl, this);
20 void PanAutos::get_handle(int &handle_x,
21                 int &handle_y,
22                 int64_t position, 
23                 int direction,
24                 PanAuto* &previous,
25                 PanAuto* &next)
27         previous = (PanAuto*)get_prev_auto(position, direction, (Auto*)previous);
28         next = (PanAuto*)get_next_auto(position, direction, (Auto*)next);
30 // Constant
31         if(previous->handle_x == next->handle_x &&
32                 previous->handle_y == next->handle_y)
33         {
34                 handle_x = previous->handle_x;
35                 handle_y = previous->handle_y;
36                 return;
37         }
39 // Interpolate
40         int64_t total = labs(next->position - previous->position);
41         double fraction;
42         if(direction == PLAY_FORWARD)
43         {
44                 fraction = (double)(position - previous->position) / total;
45         }
46         else
47         {
48                 fraction = (double)(previous->position - position) / total;
49         }
51         handle_x = (int)(previous->handle_x + (next->handle_x - previous->handle_x) * fraction);
52         handle_y = (int)(previous->handle_y + (next->handle_y - previous->handle_y) * fraction);
55 void PanAutos::dump()
57         printf("        PanAutos::dump %p\n", this);
58                 printf("        Default: position %ld\n", default_auto->position);
59                 ((PanAuto*)default_auto)->dump();
60         for(Auto* current = first; current; current = NEXT)
61         {
62                 printf("        position %ld\n", current->position);
63                 ((PanAuto*)current)->dump();
64         }