allow using complex shell commandlines (including | etc.) for job tasks (handle with...
[enigma2.git] / lib / gui / ewidgetanimation.cpp
1 #include <lib/gui/ewidgetanimation.h>
2 #include <lib/gui/ewidget.h>
3
4 eWidgetAnimation::eWidgetAnimation(eWidget *widget): m_widget(widget)
5 {
6         m_active = 0;
7 }
8
9 void eWidgetAnimation::tick(int inc)
10 {
11         if (!m_active)
12                 return;
13         
14                 // move animation
15         if (m_move_length)
16         {
17                 if (m_move_current_tick >= m_move_length)
18                 {
19                         m_active = 0;
20                         m_move_current_tick = m_move_length;
21                 }
22                 
23                 m_move_start = m_widget->position();
24                 
25                 int xdiff = m_move_start.x() - m_move_end.x();
26                 int ydiff = m_move_start.y() - m_move_end.y();
27                 
28                 xdiff *= 31; xdiff /= 32;
29                 ydiff *= 31; ydiff /= 32;
30                 
31                 #if 0
32                 xdiff *= m_move_current_tick;
33                 xdiff /= m_move_length;
34
35                 ydiff *= m_move_current_tick;
36                 ydiff /= m_move_length;
37                 #endif
38                 
39                 ePoint res(m_move_end.x() + xdiff, m_move_end.y() + ydiff);
40                 
41                 m_move_current_tick += inc;
42                 
43                 m_widget->move(res);
44         }
45 }
46
47 void eWidgetAnimation::startMoveAnimation(ePoint start, ePoint end, int length)
48 {
49         m_move_current_tick = 0;
50         m_move_length = length;
51         m_move_start = start;
52         m_move_end = end;
53         m_active = 1;
54 }