- fix serious problems in widget code. fixup buffered mode. add animation support...
[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                 int xdiff = m_move_end.x() - m_move_start.x();
23                 int ydiff = m_move_end.y() - m_move_start.y();
24                 
25                 xdiff *= m_move_current_tick;
26                 xdiff /= m_move_length;
27
28                 ydiff *= m_move_current_tick;
29                 ydiff /= m_move_length;
30                 
31                 ePoint res(m_move_start.x() + xdiff, m_move_start.y() + ydiff);
32                 
33                 m_move_current_tick += inc;
34                 
35                 m_widget->move(res);
36         }
37 }
38
39 void eWidgetAnimation::startMoveAnimation(ePoint start, ePoint end, int length)
40 {
41         m_move_current_tick = 0;
42         m_move_length = length;
43         m_move_start = start;
44         m_move_end = end;
45         m_active = 1;
46 }