From: pin Date: Fri, 5 Mar 2010 10:43:24 +0000 (+0000) Subject: fix problèmes d'aligement du curseur avec le pointeur. X-Git-Url: https://scm.cri.mines-paristech.fr/git/minwii.git/commitdiff_plain/f96fb4a3b382ac97bcdfd86549f685b02ff7968a?hp=a949d504ea9d83f36063583f9b2bd9f2f24b7b3f fix problèmes d'aligement du curseur avec le pointeur. git-svn-id: https://svn.cri.ensmp.fr/svn/minwii/trunk@67 fe552daf-6dbe-4428-90eb-1537e0879342 --- diff --git a/src/app/config.py b/src/app/config.py index 8251872..119f141 100755 --- a/src/app/config.py +++ b/src/app/config.py @@ -17,7 +17,7 @@ OFF_SATURATION = 1 ON_TOP_LUMINANCE = 0.6 ON_BOTTOM_LUMINANCE = 0.9 ON_SATURATION = 1 -ON_COLUMN_OVERSIZING = 1.75 +ON_COLUMN_OVERSIZING = 2 ON_COLUMN_ALPHA = 1 FONT = pygame.font.Font(None, 80) FONT_COLOR = (0,0,0) diff --git a/src/app/eventutils.py b/src/app/eventutils.py index a89509b..c115c28 100755 --- a/src/app/eventutils.py +++ b/src/app/eventutils.py @@ -79,12 +79,12 @@ class EventInitializer(type): EventDispatcher.addEventListener(v.__eventtype__, listener) def ctor(self, *args, **kw) : - init_listeners(self) default_ctor = dict.get('__init__') if not default_ctor : super(cls, self).__init__(*args, **kw) else : default_ctor(self, *args, **kw) + init_listeners(self) cls.__init__ = ctor diff --git a/src/app/minwii.py b/src/app/minwii.py index 2cc4988..a92590e 100755 --- a/src/app/minwii.py +++ b/src/app/minwii.py @@ -6,13 +6,21 @@ $Id$ $URL$ """ -#from pgu.gui import Desktop -#from pgu.gui import QUIT +from pgu.gui import Desktop +from pgu.gui import QUIT from widgets.home import Home from widgets.playingscreen import PlayingScreen class MinWii(object): def __init__(self) : - playingScreen = PlayingScreen() - playingScreen.run() + app = Desktop() + + if True : + home = Home() + home.connect(QUIT, app.quit) + app.run(home) + app.close(home) + + playingScreen = PlayingScreen() + playingScreen.run() diff --git a/src/app/widgets/cursors.py b/src/app/widgets/cursors.py index 9315211..2c22b5d 100755 --- a/src/app/widgets/cursors.py +++ b/src/app/widgets/cursors.py @@ -29,7 +29,6 @@ class WarpingCursor(pygame.sprite.DirtySprite, EventHandlerMixin): def __init__(self, theme='black', duration=50, blinkMode=True): pygame.sprite.DirtySprite.__init__(self) - pygame.mouse.set_visible(False) imagesPath, images = WarpingCursor._get_theme_images(theme) flashImage = images.pop(images.index('flash.png')) flashImagePath = os.path.sep.join([imagesPath, flashImage]) @@ -48,10 +47,23 @@ class WarpingCursor(pygame.sprite.DirtySprite, EventHandlerMixin): self.duration = duration self.image = self.images[0] - self.rect = pygame.Rect((-self.width/2,-self.height/2), (self.width, self.height)) + # workarround cursor alignement problem + pygame.event.set_blocked(pygame.MOUSEMOTION) + pygame.mouse.set_pos(pygame.mouse.get_pos()) + 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)) self.blinkMode = blinkMode self._startBlink() + + def _stopBlink(self) : + if self.blinkMode : + pygame.time.set_timer(TIMEOUT, 0) def _startBlink(self) : if self.blinkMode : diff --git a/src/app/widgets/playingscreen.py b/src/app/widgets/playingscreen.py index 1a014e7..223f4e5 100755 --- a/src/app/widgets/playingscreen.py +++ b/src/app/widgets/playingscreen.py @@ -47,7 +47,6 @@ class _PlayingScreenBase(pygame.sprite.LayeredDirty, EventHandlerMixin) : self._running = False self.draw(pygame.display.get_surface()) self._initCursor() - def _initRects(self) : @@ -98,6 +97,8 @@ class _PlayingScreenBase(pygame.sprite.LayeredDirty, EventHandlerMixin) : dirty = self.draw(pygame.display.get_surface()) pygame.display.update(dirty) clock.tick(FRAMERATE) + + self.cursor._stopBlink() @event_handler(pygame.KEYDOWN) def handleKeyDown(self, event) : @@ -132,6 +133,7 @@ class PlayingScreen(_PlayingScreenBase) : fs.program_select(0, fsid, bank, preset) def __del__(self) : + print 'PlayingScreen.__del__' self.fs.delete() @event_handler(events.NOTEON)