diff options
author | James <olpc@localhost.localdomain> | 2007-01-22 09:12:24 (GMT) |
---|---|---|
committer | James <olpc@localhost.localdomain> | 2007-01-22 09:12:24 (GMT) |
commit | 95d5c857729d03e474f04538c11df9ccf9c9eada (patch) | |
tree | dc76595561bd93722c5502a49b7df19b546c44e0 | |
parent | 962b90d00c747532481560a44ca03a8205363232 (diff) | |
parent | 974d292469bb9c8f8a373e7616fdedb8db31e5d0 (diff) |
Merge branch 'master' of git+ssh://jaberg@dev.laptop.org/git/projects/tamtam
-rw-r--r-- | Config.py | 11 | ||||
-rw-r--r-- | Edit/HitInterface.py | 23 | ||||
-rw-r--r-- | Edit/MainWindow.py | 2 | ||||
-rw-r--r-- | Edit/TrackInterface.py | 46 | ||||
-rwxr-xr-x | Resources/Images/hit.png | bin | 0 -> 962 bytes | |||
-rwxr-xr-x | Resources/Images/hitSelected.png | bin | 0 -> 1152 bytes | |||
-rw-r--r-- | Util/ThemeWidgets.py | 12 |
7 files changed, 56 insertions, 38 deletions
@@ -359,13 +359,16 @@ UNLOAD_TABLES_COMMAND = \ LANGUAGE = 'En' IMAGE_ROOT = TAM_TAM_ROOT + '/Resources/Images/' - + +MAIN_WINDOW_PADDING = 5 NOTE_HEIGHT = 9 # pixels NOTE_IMAGE_PADDING = 6 NOTE_IMAGE_PADDING_MUL2 = NOTE_IMAGE_PADDING*2 NOTE_IMAGE_TAIL = 1059 NOTE_IMAGE_ENDLENGTH = 12 -MAIN_WINDOW_PADDING = 5 +HIT_HEIGHT = 13 # pixels +HIT_IMAGE_PADDING = 6 +HIT_IMAGE_PADDING_MUL2 = HIT_IMAGE_PADDING*2 TRACK_SPACING = 4 TRACK_SPACING_DIV2 = TRACK_SPACING//2 TRACK_COLORS = [ ( "#00591B", "#00E847" ), \ @@ -450,6 +453,10 @@ DEFAULT_VOLUME = 80 NUMBER_OF_POSSIBLE_PITCHES = 25.0 MINIMUM_PITCH = 24.0 MAXIMUM_PITCH = MINIMUM_PITCH + NUMBER_OF_POSSIBLE_PITCHES - 1 +NUMBER_OF_POSSIBLE_PITCHES_DRUM = 13.0 +PITCH_STEP_DRUM = 2 +MINIMUM_PITCH_DRUM = 24.0 +MAXIMUM_PITCH_DRUM = MINIMUM_PITCH_DRUM + PITCH_STEP_DRUM*(NUMBER_OF_POSSIBLE_PITCHES_DRUM - 1) MINIMUM_NOTE_DURATION = 1 # ticks MS_PER_MINUTE = 60000.0 TICKS_PER_BEAT = 12 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)) diff --git a/Resources/Images/hit.png b/Resources/Images/hit.png Binary files differnew file mode 100755 index 0000000..57617f7 --- /dev/null +++ b/Resources/Images/hit.png diff --git a/Resources/Images/hitSelected.png b/Resources/Images/hitSelected.png Binary files differnew file mode 100755 index 0000000..70ddeea --- /dev/null +++ b/Resources/Images/hitSelected.png diff --git a/Util/ThemeWidgets.py b/Util/ThemeWidgets.py index 88dbb11..9c360cb 100644 --- a/Util/ThemeWidgets.py +++ b/Util/ThemeWidgets.py @@ -519,7 +519,8 @@ class ImageButton(gtk.Button): self.connect('enter',self.on_btn_enter, None) self.connect('leave',self.on_btn_leave, None) - self.curImage = self.upImage = self.stateImage = "main" + self.curImage = self.upImage = "main" + self.down = False self.connect('expose-event', self.expose) self.connect('size-allocate', self.size_allocate) @@ -539,12 +540,14 @@ class ImageButton(gtk.Button): return True def on_btn_press(self, widget, event): - self.curImage = self.stateImage = "click" + self.curImage = "click" + self.down = True self.queue_draw() def on_btn_enter(self, widget, event): self.upImage = "enter" - self.curImage = self.stateImage + if self.down: self.curImage = "click" + else: self.curImage = "enter" self.queue_draw() def on_btn_leave(self, widget, event): @@ -553,7 +556,7 @@ class ImageButton(gtk.Button): def on_btn_release(self, widget, event): self.curImage = self.upImage - self.stateImage = "main" + self.down = False self.queue_draw() class ImageToggleButton(gtk.ToggleButton): @@ -682,7 +685,6 @@ class ImageRadioButton(gtk.RadioButton): def expose(self, widget, event): if self.itype[self.curImage] == ITYPE.PIXBUF: -# self.window.draw_pixbuf( self.gc, self.image[self.curImage], 0, 0, self.drawX - self.iwidthDIV2[self.curImage], self.alloc.y + (self.alloc.height//2) - self.iheightDIV2[self.curImage], self.iwidth[self.curImage], self.iheight[self.curImage], gtk.gdk.RGB_DITHER_NONE) self.window.draw_pixbuf( self.gc, self.image[self.curImage], 0, 0, self.drawX - self.iwidthDIV2[self.curImage], self.drawY - self.iheightDIV2[self.curImage], self.iwidth[self.curImage], self.iheight[self.curImage], gtk.gdk.RGB_DITHER_NONE) else: self.window.draw_drawable( self.gc, self.image[self.curImage], 0, 0, self.drawX - self.iwidthDIV2[self.curImage], self.drawY - self.iheightDIV2[self.curImage], self.iwidth[self.curImage], self.iheight[self.curImage] ) |