define movepaths for MovingPixmaps and proof of concept in the start-wizard
authorStefan Pluecken <stefan.pluecken@multimedia-labs.de>
Thu, 8 Dec 2005 18:41:52 +0000 (18:41 +0000)
committerStefan Pluecken <stefan.pluecken@multimedia-labs.de>
Thu, 8 Dec 2005 18:41:52 +0000 (18:41 +0000)
moving over pixmaps flickers sometimes. is this fixable somehow?

lib/python/Components/Pixmap.py
lib/python/Screens/Wizard.py

index fc7bfe27b1df343aa21a674b6ce46f3650af57f4..d25530ea71e8ca9980e37aedb31ba980c3e8d195 100644 (file)
@@ -35,26 +35,58 @@ class MovingPixmap(Pixmap):
                self.x = 0.0
                self.y = 0.0
                
+               self.clearPath()
+               
                self.moveTimer = eTimer()
                self.moveTimer.timeout.get().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.time = time
-               self.destX = x
-               self.destY = y
-               self.stepX = (self.destX - self.x) / float(time)
-               self.stepY = (self.destY - self.y) / float(time)
+               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(10)
+                       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
-               self.move(int(self.x), int(self.y))
+               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
\ No newline at end of file
+                       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()
index 5aa0fada82b74fb384f7478a827c0a2550667d3b..818d99ec5ee342da02d3ea2bd1ad0e3a2bcfdd97 100644 (file)
@@ -43,7 +43,7 @@ class WelcomeWizard(Screen, HelpableScreen):
                self["text"] = Label()
                self["rc"] = Pixmap()
                self["arrowdown"] = MovingPixmap()
-               self["arrowdown"].moveTo(557, 232, 100)
+               self["arrowdown"].moveTo(557, 232, 10)
                self["arrowup"] = MovingPixmap()
                
                self.onShown.append(self["arrowdown"].startMoving)
@@ -85,11 +85,17 @@ class WelcomeWizard(Screen, HelpableScreen):
                        self.updateValues()
                        
                        if (self.currStep == 2):
-                               self["arrowdown"].moveTo(557, 200, 100)
-                               self["arrowup"].moveTo(557, 355, 100)
+                               self["arrowdown"].moveTo(557, 200, 10)
+                               self["arrowup"].moveTo(557, 355, 10)
                                self["arrowdown"].startMoving()
                                self["arrowup"].startMoving()
-                               
+                       if (self.currStep == 3):
+                               self["arrowup"].moveTo(740, 355, 10)
+                               self["arrowup"].startMoving()
+                               self["arrowdown"].clearPath(True)
+                               self["arrowdown"].addMovePoint(510, 300, 10)
+                               self["arrowdown"].addMovePoint(610, 300, 10)
+                               self["arrowdown"].startMoving()
 
 def listActiveWizards():
        wizards = [ ]