X-Git-Url: https://git.cweiske.de/enigma2.git/blobdiff_plain/7ee8589392aca17526ca30264689f204afc9646a..2a8ecd871020fdd668cf5500460e5a6e7851b4b0:/lib/python/Components/Pixmap.py diff --git a/lib/python/Components/Pixmap.py b/lib/python/Components/Pixmap.py index 5f4b9691..f6ecaf0c 100644 --- a/lib/python/Components/Pixmap.py +++ b/lib/python/Components/Pixmap.py @@ -1,27 +1,78 @@ -from ConditionalWidget import * +from ConditionalWidget import ConditionalWidget +from GUIComponent import GUIComponent -from enigma import * +from enigma import ePixmap, eTimer -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 Pixmap(GUIComponent): + GUI_WIDGET = ePixmap 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.clearPath() + + self.moveTimer = eTimer() + self.moveTimer.callback.append(self.doMove) + + def clearPath(self, repeated = False): + if (self.moving): + self.moving = False + self.moveTimer.stop() + + self.path = [] + self.currDest = 0 + self.repeated = repeated + + def addMovePoint(self, x, y, time = 20): + self.path.append((x, y, time)) + + def moveTo(self, x, y, time = 20): + self.clearPath() + self.addMovePoint(x, y, time) + + def startMoving(self): + if not self.moving: + self.time = self.path[self.currDest][2] + self.stepX = (self.path[self.currDest][0] - self.x) / float(self.time) + self.stepY = (self.path[self.currDest][1] - self.y) / float(self.time) + + self.moving = True + self.moveTimer.start(100) + + def stopMoving(self): + self.moving = False + self.moveTimer.stop() + + def doMove(self): + self.x += self.stepX + self.y += self.stepY + self.time -= 1 + try: + self.move(int(self.x), int(self.y)) + except: # moving not possible... widget not there any more... stop moving + self.stopMoving() + + if (self.time == 0): + self.currDest += 1 + self.moveTimer.stop() + self.moving = False + if (self.currDest >= len(self.path)): # end of path + if (self.repeated): + self.currDest = 0 + self.moving = False + self.startMoving() + else: + self.moving = False + self.startMoving()