screen = pygame.display.get_surface()
# taille de la zone d'affichage utile (bordure autour)
- dispWidth = screen.get_width() - 2 * BORDER
- dispHeight = screen.get_height() - 2 * BORDER
+ self.dispWidth = dispWidth = screen.get_width() - 2 * BORDER
+ self.dispHeight = dispHeight = screen.get_height() - 2 * BORDER
columnWidth = int(round(float(dispWidth) / self.keyboardLength))
for i, rect in enumerate(self.keyboardRects) :
hue = FIRST_HUE - hueStep * i
tone = self.distinctNotes[i]
- atBorder = False
- if i == 0 :
- atBorder = 'left'
- elif i == self.keyboardLength -1 :
- atBorder = 'right'
- c = Column(self, hue, rect, tone, atBorder)
+ c = Column(self, i, hue, rect, tone)
self.add(c, layer=BACKGROUND_LAYER)
self.columns[tone.midi] = c
# parce qu'il s'agit du curseur
for col in reversed(self.sprites()[:-1]) :
if col.rect.collidepoint(*event.pos):
- self.raiseColDown(col)
+ self.raiseColDown(col, event.pos)
break
@event_handler(pygame.MOUSEBUTTONUP)
def onMouseUp(self, event) :
for col in reversed(self.sprites()[:-1]) :
if col.rect.collidepoint(*event.pos) :
- self.raiseColUp(col)
+ self.raiseColUp(col, event.pos)
break
@event_handler(pygame.MOUSEMOTION)
def onMouseMove(self, event) :
for col in reversed(self.sprites()[:-1]) :
if col.rect.collidepoint(*event.pos) :
- self.raiseColOver(col)
+ self.raiseColOver(col, event.pos)
break
- def raiseColDown(self, col) :
- evt = pygame.event.Event(events.COLDOWN, column=col)
+ def raiseColDown(self, col, pos) :
+ evt = pygame.event.Event(events.COLDOWN, column=col, pos=pos)
pygame.event.post(evt)
- def raiseColUp(self, col) :
- evt = pygame.event.Event(events.COLUP, column=col)
+ def raiseColUp(self, col, pos) :
+ evt = pygame.event.Event(events.COLUP, column=col, pos=pos)
pygame.event.post(evt)
- def raiseColOver(self, col) :
- evt = pygame.event.Event(events.COLOVER, column=col)
+ def raiseColOver(self, col, pos) :
+ evt = pygame.event.Event(events.COLOVER, column=col, pos=pos)
pygame.event.post(evt)