import pygame
from colorsys import hls_to_rgb
from gradients import gradients
+from cursors import WarpingCursor
+from eventutils import event_handler, EventHandlerMixin
from math import floor
import types
# TODO : positionner cette constance en fonction de la résolution d'affichage
ON_COLUMN_OVERSIZING = 1.5
-def rename_method(newName) :
- def doRename(m) :
- m.__name__ = newName
- return m
- return doRename
-
-
-class MetaRenamer(type):
- def __new__(mcs, name, bases, dict) :
- for k, v in dict.items() :
- if isinstance(v, types.FunctionType) :
- if k != v.__name__ :
- print 'renommage de %s en %s' % (k, v.__name__)
- dict[v.__name__] = v
- del dict[k]
- return type.__new__(mcs, name, bases, dict)
-
-
-class _PlayingScreenBase(pygame.sprite.OrderedUpdates) :
-
- __metaclass__ = MetaRenamer
+class _PlayingScreenBase(pygame.sprite.OrderedUpdates, EventHandlerMixin) :
def __init__(self, distinctNotes=[]) :
"""
self.distinctNotes = distinctNotes
self.keyboardLength = 0
self.keyboardRects = []
+ self.cursor = None
self._initRects()
self._initColumns()
self._running = False
+ self.draw(pygame.display.get_surface())
+ self._initCursor()
print hue
c = Column(hue, rect)
self.add(c)
-
+
+ def _initCursor(self) :
+ self.cursor = WarpingCursor()
+ #self.add(self.cursor)
+
def highlightColumn(self, index) :
for i, sprite in enumerate(self.sprites()) :
handler = getattr(self, 'eventHandler%s' % event.type, lambda e:None)
handler(event)
- @rename_method('eventHandler%s' % pygame.KEYDOWN)
+ @event_handler(pygame.KEYDOWN)
def handleKeyDown(self, event) :
if event.key == pygame.K_q:
self._running = False
if uni.isdigit() and int(uni) <=8 :
self.highlightColumn(int(uni))
+
+ @event_handler(pygame.MOUSEMOTION)
+ def handleMouseMotion(self, event) :
+ pass