X-Git-Url: https://scm.cri.ensmp.fr/git/minwii.git/blobdiff_plain/f96fb4a3b382ac97bcdfd86549f685b02ff7968a..baf4f2fe0e04d6b95c428813dd920b597031ec04:/src/app/widgets/cursors.py diff --git a/src/app/widgets/cursors.py b/src/app/widgets/cursors.py index 2c22b5d..1e3fc4e 100755 --- a/src/app/widgets/cursors.py +++ b/src/app/widgets/cursors.py @@ -20,7 +20,7 @@ class WarpingCursor(pygame.sprite.DirtySprite, EventHandlerMixin): @staticmethod def _get_theme_images(name) : basePath = os.path.abspath(__file__).split(os.path.sep)[:-1] - basePath.append('data') + basePath.extend(['data', 'cursor']) basePath.append(name) basePath = os.path.sep.join(basePath) images = [f for f in os.listdir(basePath) if os.path.splitext(f)[1] == '.png'] @@ -53,7 +53,6 @@ class WarpingCursor(pygame.sprite.DirtySprite, EventHandlerMixin): pygame.event.set_allowed(pygame.MOUSEMOTION) # --- x, y = pygame.mouse.get_pos() - print 'mouse pos :', x, y left = x - self.width / 2 top = y - self.height / 2 self.rect = pygame.Rect((left, top), (self.width, self.height)) @@ -61,16 +60,16 @@ class WarpingCursor(pygame.sprite.DirtySprite, EventHandlerMixin): self.blinkMode = blinkMode self._startBlink() - def _stopBlink(self) : - if self.blinkMode : - pygame.time.set_timer(TIMEOUT, 0) - def _startBlink(self) : if self.blinkMode : self._blinking = True pygame.time.set_timer(TIMEOUT, self.duration) self.iterator = self.iterImages() + def _stopBlink(self) : + if self.blinkMode : + pygame.time.set_timer(TIMEOUT, 0) + def iterImages(self) : for img in cycle(self.images) : yield img @@ -100,3 +99,9 @@ class WarpingCursor(pygame.sprite.DirtySprite, EventHandlerMixin): def move(self, event) : self.dirty = 1 self.rect.move_ip(event.rel) + + def setPosition(self, pos) : + self.dirty = 1 + x, y = pos + rx, ry = self.rect.centerx, self.rect.centery + self.rect.move_ip(x-rx, y-ry)