Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/Edit
diff options
context:
space:
mode:
authoramartin <olpc@localhost.localdomain>2007-01-21 22:48:33 (GMT)
committer amartin <olpc@localhost.localdomain>2007-01-21 22:48:33 (GMT)
commit974d292469bb9c8f8a373e7616fdedb8db31e5d0 (patch)
treeb149467acaf66bf6f2c32b6e69fd963b20236c36 /Edit
parente2eab95f6e89691198c61ea01e10a041099ba782 (diff)
hit graphics
Diffstat (limited to 'Edit')
-rw-r--r--Edit/HitInterface.py23
-rw-r--r--Edit/MainWindow.py2
-rw-r--r--Edit/TrackInterface.py46
3 files changed, 40 insertions, 31 deletions
diff --git a/Edit/HitInterface.py b/Edit/HitInterface.py
index fc9bfc1..5092549 100644
--- a/Edit/HitInterface.py
+++ b/Edit/HitInterface.py
@@ -10,6 +10,10 @@ 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 )
+ self.width = self.height = Config.HIT_HEIGHT
+ self.imgWidth = self.imgHeight = Config.HIT_HEIGHT + Config.HIT_IMAGE_PADDING_MUL2
+
+
def updateParams( self, pitch, onset, duration, amplitude):
self.pitch = pitch
self.onset = onset
@@ -44,12 +48,9 @@ class HitInterface( NoteInterface ):
origin = self.parent.getTrackOrigin( self.track )
self.x = self.parent.ticksToPixels( self.onset )
- self.width = self.parent.ticksToPixels( self.end ) - self.x
- self.imgWidth = self.width + Config.NOTE_IMAGE_PADDING_MUL2
self.x += origin[0]
self.imgX = self.x - Config.NOTE_IMAGE_PADDING
- # TODO: change pitchToPixels to some drumPitchToPixels
- self.y = self.parent.pitchToPixels( self.pitch ) + origin[1]
+ self.y = self.parent.pitchToPixelsDrum( self.pitch ) + origin[1]
self.imgY = self.y - Config.NOTE_IMAGE_PADDING
if self.page == self.parent.curPage:
@@ -62,9 +63,8 @@ class HitInterface( NoteInterface ):
def updateDragLimits( self, dragLimits, leftBound, rightBound, widthBound, maxRightBound ):
left = 0 - self.onset
right = maxRightBound - self.duration - self.onset
- # TODO: some sort of maximum/minimum drum pitch
- up = Config.MAXIMUM_PITCH - self.pitch
- down = Config.MINIMUM_PITCH - self.pitch
+ up = Config.MAXIMUM_PITCH_DRUM - self.pitch
+ down = Config.MINIMUM_PITCH_DRUM - self.pitch
if dragLimits[0][0] < left: dragLimits[0][0] = left
if dragLimits[0][1] > right: dragLimits[0][1] = right
@@ -119,7 +119,7 @@ class HitInterface( NoteInterface ):
percent = eX/self.width
if percent < 0.5: emitter.setCurrentAction( "note-drag-onset", self )
- else: emitter.setCurrentAction( "note-drag-pitch", self )
+ else: emitter.setCurrentAction( "note-drag-pitch-drum", self )
return 1
@@ -133,7 +133,7 @@ class HitInterface( NoteInterface ):
self.end = self.onset + self.duration
changed = True
- if dp != self.lastDragP:
+ if dp != self.lastDragP and not dp%2:
self.lastDragP = dp
newPitch = self.basePitch + dp
self.pitch = newPitch
@@ -174,12 +174,11 @@ class HitInterface( NoteInterface ):
if startX > self.imgX + self.imgWidth: return True # we don't need to draw, but maybe a later note does
gc.foreground = self.color
- win.draw_rectangle( gc, True, self.x+1, self.y+1, self.width-2, self.height-2 )
+ win.draw_rectangle( gc, True, self.x+2, self.y+2, self.width-4, self.height-4 )
if self.selected: img = self.imageSelected
else: img = self.image
- win.draw_pixbuf( gc, img, 0, 0, self.imgX, self.imgY, self.imgWidth-Config.NOTE_IMAGE_ENDLENGTH, self.imgHeight, gtk.gdk.RGB_DITHER_NONE )
- win.draw_pixbuf( gc, img, Config.NOTE_IMAGE_TAIL, 0, self.imgX+self.imgWidth-Config.NOTE_IMAGE_ENDLENGTH, self.imgY, Config.NOTE_IMAGE_ENDLENGTH, self.imgHeight, gtk.gdk.RGB_DITHER_NONE )
+ 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
diff --git a/Edit/MainWindow.py b/Edit/MainWindow.py
index 482b0f3..40cb94b 100644
--- a/Edit/MainWindow.py
+++ b/Edit/MainWindow.py
@@ -194,8 +194,6 @@ class MainWindow( gtk.EventBox ):
self.GUI["2toolBox"] = formatRoundBox( RoundHBox(), "#6C9790" )
self.GUI["2toolBox"].set_size_request( 146, -1 )
self.GUI["2toolPointerButton"] = ImageRadioButton( None, Config.IMAGE_ROOT+"pointer.png", Config.IMAGE_ROOT+"pointerDown.png" )
-# self.GUI["2toolPointerButton"].set_active( True )
- self.GUI["2toolPointerButton"].toggled()
self.GUI["2toolPointerButton"].connect( "clicked", self.handleToolClick , "Default" )
self.GUI["2toolBox"].pack_start( self.GUI["2toolPointerButton"] )
self.GUI["2toolPencilButton"] = ImageRadioButton( self.GUI["2toolPointerButton"], Config.IMAGE_ROOT+"pencil.png", Config.IMAGE_ROOT+"pencilDown.png" )
diff --git a/Edit/TrackInterface.py b/Edit/TrackInterface.py
index af4f836..6a7c8b3 100644
--- a/Edit/TrackInterface.py
+++ b/Edit/TrackInterface.py
@@ -119,10 +119,9 @@ class TrackInterface( gtk.EventBox ):
prepareDrawable( "trackBGDrumSelected" )
preparePixbuf( "note" )
preparePixbuf( "noteSelected" )
- # temp
- self.image["hit"] = self.image["note"]
- self.image["hitSelected"] = self.image["noteSelected"]
-
+ preparePixbuf( "hit" )
+ preparePixbuf( "hitSelected" )
+
# define dimensions
self.width = self.trackFullWidth = self.image["trackBG"].get_size()[0]
self.trackWidth = self.width - Config.TRACK_SPACING
@@ -143,7 +142,9 @@ class TrackInterface( gtk.EventBox ):
self.pitchPerPixel = float(Config.NUMBER_OF_POSSIBLE_PITCHES-1) / (self.trackHeight - Config.NOTE_HEIGHT)
self.pixelsPerPitch = float(self.trackHeight-Config.NOTE_HEIGHT)/(Config.MAXIMUM_PITCH - Config.MINIMUM_PITCH)
-
+ self.pitchPerPixelDrum = float(Config.NUMBER_OF_POSSIBLE_PITCHES_DRUM-1)*Config.PITCH_STEP_DRUM / (self.trackHeightDrum - Config.HIT_HEIGHT)
+ self.pixelsPerPitchDrum = float(self.trackHeightDrum-Config.HIT_HEIGHT)/(Config.MAXIMUM_PITCH_DRUM - Config.MINIMUM_PITCH_DRUM )
+
# screen buffers
self.screenBuf = [ gtk.gdk.Pixmap( win, self.width, self.height ), \
gtk.gdk.Pixmap( win, self.width, self.height ) ]
@@ -469,7 +470,10 @@ class TrackInterface( gtk.EventBox ):
elif self.curAction == "note-drag-pitch":
self.noteDragPitch( event )
-
+
+ elif self.curAction == "note-drag-pitch-drum":
+ self.noteDragPitch( event, True )
+
elif self.curAction == "marquee":
self.updateMarquee( event )
@@ -494,14 +498,16 @@ class TrackInterface( gtk.EventBox ):
self.curAction = action
self.curActionObject = obj
- if action == "note-drag-onset": self.updateDragLimits()
- elif action == "note-drag-duration": self.updateDragLimits()
- elif action == "note-drag-pitch": self.updateDragLimits()
+ if action == "note-drag-onset": self.updateDragLimits()
+ elif action == "note-drag-duration": self.updateDragLimits()
+ elif action == "note-drag-pitch": self.updateDragLimits()
+ elif action == "note-drag-pitch-drum": self.updateDragLimits()
def doneCurrentAction( self ):
- if self.curAction == "note-drag-onset": self.doneNoteDrag()
- elif self.curAction == "note-drag-duration": self.doneNoteDrag()
- elif self.curAction == "note-drag-pitch": self.doneNoteDrag()
+ if self.curAction == "note-drag-onset": self.doneNoteDrag()
+ elif self.curAction == "note-drag-duration": self.doneNoteDrag()
+ elif self.curAction == "note-drag-pitch": self.doneNoteDrag()
+ elif self.curAction == "note-drag-pitch-drum": self.doneNoteDrag()
self.curAction = False
self.curActionObject = False
@@ -517,9 +523,10 @@ class TrackInterface( gtk.EventBox ):
self.invalidate_rect( 0, self.trackLimits[trackN][0], self.width, self.trackLimits[trackN][1]-self.trackLimits[trackN][0], self.curPage )
def selectionChanged( self ):
- if self.curAction == "note-drag-onset": self.updateDragLimits()
- elif self.curAction == "note-drag-duration": self.updateDragLimits()
- elif self.curAction == "note-drag-pitch": self.updateDragLimits()
+ if self.curAction == "note-drag-onset": self.updateDragLimits()
+ elif self.curAction == "note-drag-duration": self.updateDragLimits()
+ elif self.curAction == "note-drag-pitch": self.updateDragLimits()
+ elif self.curAction == "note-drag-pitch-drum": self.updateDragLimits()
def applyNoteSelection( self, mode, trackN, which ):
if mode == SELECTNOTES.ALL:
@@ -659,9 +666,10 @@ class TrackInterface( gtk.EventBox ):
if ret: changed += [ret]
self.onNoteDrag( changed )
- def noteDragPitch( self, event ):
+ def noteDragPitch( self, event, drum = False ):
do = 0
- dp = self.pixelsToPitch( event.y - self.clickLoc[1] )
+ if not drum: dp = self.pixelsToPitch( event.y - self.clickLoc[1] )
+ else: dp = self.pixelsToPitchDrum( event.y - self.clickLoc[1] )
dp = min( self.dragLimits[1][1], max( self.dragLimits[1][0], dp ) )
dd = 0
@@ -953,3 +961,7 @@ class TrackInterface( gtk.EventBox ):
return int(round( ( Config.MAXIMUM_PITCH - pitch ) * self.pixelsPerPitch ))
def pixelsToPitch( self, pixels ):
return int(round(-pixels*self.pitchPerPixel))
+ def pitchToPixelsDrum( self, pitch ):
+ return int(round( ( Config.MAXIMUM_PITCH_DRUM - pitch ) * self.pixelsPerPitchDrum ))
+ def pixelsToPitchDrum( self, pixels ):
+ return int(round(-pixels*self.pitchPerPixelDrum))