aboutsummaryrefslogtreecommitdiff
path: root/lib/python/Components/Pixmap.py
blob: fc7bfe27b1df343aa21a674b6ce46f3650af57f4 (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
56
57
58
59
60
from ConditionalWidget import *

from enigma import *

class Pixmap(Widget):
	def __init__(self):
		Widget.__init__(self)

	def getePixmap(self, parent):
		#pixmap = ePixmap(parent)
		#pixmap.setPixmapFromFile(self.filename)
		return ePixmap(parent)
	
	def createWidget(self, parent):
		return self.getePixmap(parent)

	def removeWidget(self, w):
		pass

	def move(self, x, y):
		self.instance.move(ePoint(int(x), int(y)))

class PixmapConditional(ConditionalWidget, Pixmap):
	def __init__(self, withTimer = True):
		ConditionalWidget.__init__(self)
		Pixmap.__init__(self)

class MovingPixmap(Pixmap):
	def __init__(self):
		Pixmap.__init__(self)
		
		self.moving = False
		
		# TODO: get real values
		self.x = 0.0
		self.y = 0.0
		
		self.moveTimer = eTimer()
		self.moveTimer.timeout.get().append(self.doMove)
		
	def moveTo(self, x, y, time = 20):
		self.time = time
		self.destX = x
		self.destY = y
		self.stepX = (self.destX - self.x) / float(time)
		self.stepY = (self.destY - self.y) / float(time)
		
	def startMoving(self):
		if not self.moving:
			self.moving = True
			self.moveTimer.start(10)
		
	def doMove(self):
		self.x += self.stepX
		self.y += self.stepY
		self.time -= 1
		self.move(int(self.x), int(self.y))
		if (self.time == 0):
			self.moveTimer.stop()
			self.moving = False