import os
from eventutils import EventHandlerMixin, event_handler
from itertools import cycle
-from pygame.locals import MOUSEBUTTONDOWN, MOUSEBUTTONUP, USEREVENT
+from pygame.locals import USEREVENT
TIMEOUT = USEREVENT + 1
class WarpingCursor(pygame.sprite.Sprite, EventHandlerMixin):
def __init__(self, theme='black', duration=75, blink=True):
pygame.sprite.Sprite.__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])
self.image = self.images[0]
self.rect = pygame.Rect((0,0), (self.width, self.height))
- self.update()
self.blink = blink
if blink :
def loadNext(self, event) :
if self.blink :
self.image = self.iterator.next()
- self.update()
- @event_handler(MOUSEBUTTONDOWN)
+ @event_handler(pygame.MOUSEBUTTONDOWN)
def flashOn(self, event) :
self.blink=False
self.image = self.flashImage
- self.update()
- @event_handler(MOUSEBUTTONUP)
+ @event_handler(pygame.MOUSEBUTTONUP)
def flashOff(self, event) :
self.blink = True
self.loadNext(event)
-
- def update(self) :
- surface = pygame.display.get_surface()
- surface.blit(self.image, self.rect)
+
+ @event_handler(pygame.MOUSEMOTION)
+ def move(self, event) :
+ x, y = event.rel
+ self.rect.centerx += x
+ self.rect.centery += y
+ #self.rect.move_ip(*rel)
import types
# TODO : positionner cette constance en fonction de la résolution d'affichage
# externaliser la conf.
-BORDER = 5 # 5px
+BORDER = 0 # 5px
FIRST_HUE = 0.6
OFF_LUMINANCE = 0.2
OFF_SATURATION = 1
distinctNotes : notes disctinctes présentes dans la chanson
triées du plus grave au plus aigu.
"""
- print '__init__ _PlayingScreenBase'
super(_PlayingScreenBase, self).__init__()
self.distinctNotes = distinctNotes
self.keyboardLength = 0
def _initCursor(self) :
self.cursor = WarpingCursor()
- #self.add(self.cursor)
+ self.add(self.cursor)
def highlightColumn(self, index) :
def run(self):
self._running = True
clock = pygame.time.Clock()
+ pygame.display.flip()
while self._running :
- pygame.display.flip()
EventDispatcher.dispatchEvents()
+ dirty = self.draw(pygame.display.get_surface())
+ pygame.display.update(dirty)
clock.tick(50)
@event_handler(pygame.KEYDOWN)
class SongPlayingScreenTest(_PlayingScreenBase) :
def __init__(self) :
- print '__init__ SongPlayingScreenTest'
class C:pass
o = C()
o.midi=1