introduce the movingPixmap and use it to position the arrow in the start-wizard ...
[vuplus_dvbapp] / lib / python / Components / Pixmap.py
1 from ConditionalWidget import *
2
3 from enigma import *
4
5 class Pixmap(Widget):
6         def __init__(self):
7                 Widget.__init__(self)
8
9         def getePixmap(self, parent):
10                 #pixmap = ePixmap(parent)
11                 #pixmap.setPixmapFromFile(self.filename)
12                 return ePixmap(parent)
13         
14         def createWidget(self, parent):
15                 return self.getePixmap(parent)
16
17         def removeWidget(self, w):
18                 pass
19
20         def move(self, x, y):
21                 self.instance.move(ePoint(int(x), int(y)))
22
23 class PixmapConditional(ConditionalWidget, Pixmap):
24         def __init__(self, withTimer = True):
25                 ConditionalWidget.__init__(self)
26                 Pixmap.__init__(self)
27
28 class MovingPixmap(Pixmap):
29         def __init__(self):
30                 Pixmap.__init__(self)
31                 
32                 self.moving = False
33                 
34                 # TODO: get real values
35                 self.x = 0.0
36                 self.y = 0.0
37                 
38                 self.moveTimer = eTimer()
39                 self.moveTimer.timeout.get().append(self.doMove)
40                 
41         def moveTo(self, x, y, time = 20):
42                 self.time = time
43                 self.destX = x
44                 self.destY = y
45                 self.stepX = (self.destX - self.x) / float(time)
46                 self.stepY = (self.destY - self.y) / float(time)
47                 
48         def startMoving(self):
49                 if not self.moving:
50                         self.moving = True
51                         self.moveTimer.start(10)
52                 
53         def doMove(self):
54                 self.x += self.stepX
55                 self.y += self.stepY
56                 self.time -= 1
57                 self.move(int(self.x), int(self.y))
58                 if (self.time == 0):
59                         self.moveTimer.stop()
60                         self.moving = False