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