From 3ef626cf8302e8c7ec32a385adef3f6fb76776b8 Mon Sep 17 00:00:00 2001 From: amartin Date: Fri, 19 Jan 2007 11:17:21 +0000 Subject: HitInterface first draft --- (limited to 'Edit/NoteInterface.py') diff --git a/Edit/NoteInterface.py b/Edit/NoteInterface.py index b1d2f1c..f355b57 100644 --- a/Edit/NoteInterface.py +++ b/Edit/NoteInterface.py @@ -50,7 +50,7 @@ class NoteInterface: b = self.baseColors[0][2] + int(self.baseColors[1][2]*amplitude) self.color = self.parent.drawingArea.get_colormap().alloc_color( r, g, b, True, True ) - self.updateTransform( False ) + self.updateTransform() def getId( self ): return self.note @@ -63,8 +63,11 @@ class NoteInterface: def testOnset( self, start, stop ): return self.onset >= start and self.onset < stop + + def getPitch( self ): + return self.pitch - def updateTransform( self, onlyX ): + def updateTransform( self ): if self.page == self.parent.curPage: oldX = self.imgX oldY = self.imgY @@ -76,9 +79,8 @@ class NoteInterface: self.imgWidth = self.width + Config.NOTE_IMAGE_PADDING_MUL2 self.x += origin[0] self.imgX = self.x - Config.NOTE_IMAGE_PADDING - if not onlyX: - self.y = self.parent.pitchToPixels( self.pitch ) + origin[1] - self.imgY = self.y - Config.NOTE_IMAGE_PADDING + self.y = self.parent.pitchToPixels( self.pitch ) + origin[1] + self.imgY = self.y - Config.NOTE_IMAGE_PADDING if self.page == self.parent.curPage: x = min( self.imgX, oldX ) @@ -87,7 +89,7 @@ class NoteInterface: endy = max( self.imgY, oldY ) + self.imgHeight self.parent.invalidate_rect( x, y, endx-x, endy-y, self.page ) - def updateDragLimits( self, dragLimits, leftBound, rightBound, widthBound ): + def updateDragLimits( self, dragLimits, leftBound, rightBound, widthBound, maxRightBound ): left = leftBound - self.onset right = rightBound - self.duration - self.onset up = Config.MAXIMUM_PITCH - self.pitch @@ -177,26 +179,31 @@ class NoteInterface: def noteDrag( self, emitter, do, dp, dd ): self.potentialDeselect = False + changed = False if do != self.lastDragO: self.lastDragO = do self.onset = self.baseOnset + do self.end = self.onset + self.duration + changed = True if dp != self.lastDragP: self.lastDragP = dp newPitch = self.basePitch + dp self.pitch = newPitch self.updateSampleNote( newPitch ) + changed = True if dd != self.lastDragD: self.lastDragD = dd self.duration = self.baseDuration + dd self.end = self.onset + self.duration + changed = True - self.updateTransform( False ) + self.updateTransform() - return (self.note, self.pitch, self.onset, self.duration) + if changed: return (self.note, self.pitch, self.onset, self.duration ) + else: return False def doneNoteDrag( self, emitter ): self.baseOnset = self.onset @@ -259,7 +266,7 @@ class NoteInterface: return self.selected #======================================================= - # Selection + # Draw def draw( self, win, gc, startX, stopX ): if stopX < self.imgX: return False # we don't need to draw and no one after us will draw -- cgit v0.9.1