Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/Edit/HitInterface.py
diff options
context:
space:
mode:
authoramartin <olpc@localhost.localdomain>2007-01-31 06:28:53 (GMT)
committer amartin <olpc@localhost.localdomain>2007-01-31 06:28:53 (GMT)
commit46d07b755b7a53610f6b88a98a2e170410668ba3 (patch)
treefe81b1f416db3e1312f4a4d7f63d468c80d2e96e /Edit/HitInterface.py
parent8f6117e6876047931a035d3058a5b725a720c318 (diff)
NoteDB
Diffstat (limited to 'Edit/HitInterface.py')
-rw-r--r--[-rwxr-xr-x]Edit/HitInterface.py117
1 files changed, 42 insertions, 75 deletions
diff --git a/Edit/HitInterface.py b/Edit/HitInterface.py
index 3eac69f..1301a33 100755..100644
--- a/Edit/HitInterface.py
+++ b/Edit/HitInterface.py
@@ -2,87 +2,62 @@ import pygtk
pygtk.require( '2.0' )
import gtk
+from Util.NoteDB import PARAMETER
from Edit.NoteInterface import NoteInterface
import Config
class HitInterface( NoteInterface ):
- def __init__( self, parent, page, track, note, pitch, onset, duration, amplitude, image, imageSelected, colors ):
- NoteInterface.__init__( self, parent, page, track, note, pitch, onset, duration, amplitude, image, imageSelected, colors )
+ def __init__( self, noteDB, owner, note ):
+ NoteInterface.__init__( self, noteDB, owner, note )
- self.width = self.height = Config.HIT_HEIGHT
+ self.width = self.height = Config.HIT_HEIGHT
self.imgWidth = self.imgHeight = Config.HIT_HEIGHT + Config.HIT_IMAGE_PADDING_MUL2
self.firstTransform = True
self.updateTransform()
- def updateParams( self, pitch, onset, duration, amplitude):
- self.pitch = pitch
- self.onset = onset
- self.duration = duration
- self.end = onset + duration
-
- self.amplitude = amplitude
- r = self.baseColors[0][0] + int(self.baseColors[1][0]*amplitude)
- g = self.baseColors[0][1] + int(self.baseColors[1][1]*amplitude)
- 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()
-
- def getId( self ):
- return self.note
-
- def getStartTick( self ):
- return self.onset
-
- def getEndTick( self ):
- return self.end
-
- def testOnset( self, start, stop ):
- return self.onset >= start and self.onset < stop
-
def updateTransform( self ):
- if self.page == self.parent.curPage and not self.firstTransform:
+ if self.note.page == self.owner.curPage and not self.firstTransform:
oldX = self.imgX
oldY = self.imgY
oldEndX = self.imgX + self.imgWidth
- if self.onset != self.oldOnset:
- self.x = self.parent.ticksToPixels( self.onset )
+ if self.note.cs.onset != self.oldOnset:
+ self.x = self.owner.ticksToPixels( self.noteDB.getPage(self.note.page).beats, self.note.cs.onset )
self.x += self.origin[0]
self.imgX = self.x - Config.NOTE_IMAGE_PADDING
- self.oldOnset = self.onset
- if self.pitch != self.oldPitch:
- self.y = self.parent.pitchToPixelsDrum( self.pitch ) + self.origin[1]
+ self.oldOnset = self.note.cs.onset
+ if self.note.cs.pitch != self.oldPitch:
+ self.y = self.owner.pitchToPixelsDrum( self.note.cs.pitch ) + self.origin[1]
self.imgY = self.y - Config.NOTE_IMAGE_PADDING
- self.oldPitch = self.pitch
-
- if self.page == self.parent.curPage:
+ self.oldPitch = self.note.cs.pitch
+
+ if self.note.page == self.owner.curPage:
if self.firstTransform:
- self.parent.invalidate_rect( self.imgX, self.imgY, self.imgWidth, self.imgHeight, self.page )
+ self.owner.invalidate_rect( self.imgX, self.imgY, self.imgWidth, self.imgHeight, self.note.page )
self.firstTransform = False
else:
x = min( self.imgX, oldX )
y = min( self.imgY, oldY )
endx = max( self.imgX + self.imgWidth, oldEndX )
endy = max( self.imgY, oldY ) + self.imgHeight
- self.parent.invalidate_rect( x, y, endx-x, endy-y, self.page )
+ self.owner.invalidate_rect( x, y, endx-x, endy-y, self.note.page )
def updateDragLimits( self, dragLimits, leftBound, rightBound, widthBound, maxRightBound ):
- left = 0 - self.onset
- right = maxRightBound - self.duration - self.onset
- up = Config.MAXIMUM_PITCH_DRUM - self.pitch
- down = Config.MINIMUM_PITCH_DRUM - self.pitch
-
+ left = 0 - self.note.cs.onset
+ right = maxRightBound - self.note.cs.duration - self.note.cs.onset
+ up = Config.MAXIMUM_PITCH_DRUM - self.note.cs.pitch
+ down = Config.MINIMUM_PITCH_DRUM - self.note.cs.pitch
+
if dragLimits[0][0] < left: dragLimits[0][0] = left
if dragLimits[0][1] > right: dragLimits[0][1] = right
if dragLimits[1][0] < down: dragLimits[1][0] = down
if dragLimits[1][1] > up: dragLimits[1][1] = up
-
+
# store the current loc as a reference point
- self.baseOnset = self.onset
- self.basePitch = self.pitch
+ self.baseOnset = self.note.cs.onset
+ self.basePitch = self.note.cs.pitch
#=======================================================
# Events
@@ -97,62 +72,54 @@ class HitInterface( NoteInterface ):
return -1 # event occurs before us, no point in checking further
if eX > self.width:
return 0 # no X overlap
-
+
eY = event.y - self.y
if eY < 0 or eY > self.height:
return 0 # not a hit
-
+
if event.button == 3:
- print "Show some note parameters!?!"
- #self.noteParameters = NoteParametersWindow( self.note, self.getNoteParameters )
+ print "Show some note parameters!?!"
+ #self.noteParameters = NoteParametersWindow( self.note, self.getNoteParameters )
return 1 # handled
if event.type == gtk.gdk._2BUTTON_PRESS: # select bar
self.potentialDeselect = False
start = 0
- check = self.onset - Config.TICKS_PER_BEAT
+ check = self.note.cs.onset - Config.TICKS_PER_BEAT
while start <= check: start += Config.TICKS_PER_BEAT
stop = start + Config.TICKS_PER_BEAT
- check += self.duration
+ check += 1
while stop < check: stop += Config.TICKS_PER_BEAT
- emitter.selectNotesByBar( self.track, start, stop )
+ emitter.selectNotesByBar( self.note.track, start, stop )
elif event.type == gtk.gdk._3BUTTON_PRESS: # select track
self.potentialDeselect = False
- emitter.selectNotesByTrack( self.track )
+ emitter.selectNotesByTrack( self.note.track )
else:
if self.getSelected(): # we already selected, might want to delected
self.potentialDeselect = True
else:
- emitter.selectNotes( { self.track: [ self ] } )
- self.updateSampleNote( self.pitch )
-
+ emitter.selectNotes( { self.note.track: [ self ] } )
+ self.updateSampleNote( self.note.cs.pitch )
+
percent = eX/self.width
if percent < 0.5: emitter.setCurrentAction( "note-drag-onset", self )
else: emitter.setCurrentAction( "note-drag-pitch-drum", self )
-
+
return 1
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
+ self.noteDB.updateNote( self.note.page, self.note.track, self.note.id, PARAMETER.ONSET, self.baseOnset + do )
+ self.end = self.note.cs.onset + self.note.cs.duration
if dp != self.lastDragP and not dp%2:
self.lastDragP = dp
newPitch = self.basePitch + dp
- self.pitch = newPitch
+ self.noteDB.updateNote( self.note.page, self.note.track, self.note.id, PARAMETER.PITCH, newPitch )
self.updateSampleNote( newPitch )
- changed = True
-
- self.updateTransform()
-
- if changed: return (self.note, self.pitch, self.onset, self.duration )
- else: return False
# updateTooltip returns:
# -1, event occurs before us so don't bother checking any later notes
@@ -164,15 +131,15 @@ class HitInterface( NoteInterface ):
return -1 # event occurs before us, no point in checking further
if eX > self.width:
return 0 # no X overlap
-
+
eY = event.y - self.y
if eY < 0 or eY > self.height:
return 0 # not a hit
-
+
percent = eX/self.width
if percent < 0.5: emitter.setCursor("drag-onset")
else: emitter.setCursor("drag-pitch")
-
+
return 1 # we handled it
#=======================================================
@@ -190,4 +157,4 @@ class HitInterface( NoteInterface ):
win.draw_pixbuf( gc, img, 0, 0, self.imgX, self.imgY, self.imgWidth, self.imgHeight, gtk.gdk.RGB_DITHER_NONE )
return True # we drew something
-
+