Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoramartin <olpc@localhost.localdomain>2007-02-20 22:43:12 (GMT)
committer amartin <olpc@localhost.localdomain>2007-02-20 22:43:12 (GMT)
commit1fcc777030bb0ca9d3768edf21bd0de704032c62 (patch)
tree3631fee8bdf561a4c2f4148e26464fc0cd07c3a9
parent14996eec6c02ec388f35114a910d7bdad9b3b899 (diff)
sample notes
-rw-r--r--Edit/HitInterface.py8
-rw-r--r--Edit/MainWindow.py35
-rw-r--r--Edit/NoteInterface.py13
-rw-r--r--Edit/TrackInterface.py80
-rw-r--r--Edit/TuneInterface.py54
-rw-r--r--Util/ThemeWidgets.py3
6 files changed, 118 insertions, 75 deletions
diff --git a/Edit/HitInterface.py b/Edit/HitInterface.py
index f121302..e3692b7 100644
--- a/Edit/HitInterface.py
+++ b/Edit/HitInterface.py
@@ -88,6 +88,8 @@ class HitInterface( NoteInterface ):
#self.noteParameters = NoteParametersWindow( self.note, self.getNoteParameters )
return 1 # handled
+ playSample = False
+
if event.type == gtk.gdk._2BUTTON_PRESS: # select bar
self.potentialDeselect = False
start = 0
@@ -105,11 +107,13 @@ class HitInterface( NoteInterface ):
self.potentialDeselect = True
else:
emitter.selectNotes( { self.note.track: [ self ] } )
- self.updateSampleNote( self.note.cs.pitch )
+ playSample = True
percent = eX/self.width
if percent < 0.5: emitter.setCurrentAction( "note-drag-onset", self )
- else: emitter.setCurrentAction( "note-drag-pitch-drum", self )
+ else:
+ emitter.setCurrentAction( "note-drag-pitch-drum", self )
+ if playSample: self.playSampleNote()
return 1
diff --git a/Edit/MainWindow.py b/Edit/MainWindow.py
index aa17ec3..60774ca 100644
--- a/Edit/MainWindow.py
+++ b/Edit/MainWindow.py
@@ -360,14 +360,28 @@ class MainWindow( gtk.EventBox ):
self.GUI["2transportBox"].pack_start( self.GUI["2loopButton"] )
self.GUI["2toolPanel"].pack_start( self.GUI["2transportBox"] )
# + tune box
- self.GUI["2tuneBox"] = formatRoundBox( RoundVBox(), Config.BG_COLOR )
+ self.GUI["2tuneBox"] = formatRoundBox( RoundHBox(), Config.BG_COLOR )
+ self.GUI["2tuneHBox"] = gtk.HBox()
+ self.GUI["2tuneScrollLeftButton"] = ImageButton( Config.IMAGE_ROOT+"arrowEditLeft.png", backgroundFill = Config.BG_COLOR )
+ self.GUI["2tuneScrollLeftButton"].set_size_request( 25, -1 )
+ self.GUI["2tuneScrollLeftButton"].connect( "clicked", lambda a1:self.scrollTune( -1 ) )
+ self.GUI["2tuneHBox"].pack_start( self.GUI["2tuneScrollLeftButton"], False, False )
+ self.GUI["2tuneVBox"] = gtk.VBox()
self.GUI["2tuneScrolledWindow"] = gtk.ScrolledWindow()
- self.GUI["2tuneScrolledWindow"].set_policy( gtk.POLICY_ALWAYS, gtk.POLICY_NEVER )
- self.GUI["2tuneScrolledWindow"].set_shadow_type(gtk.SHADOW_NONE)
+ self.GUI["2tuneScrolledWindow"].set_policy( gtk.POLICY_NEVER, gtk.POLICY_NEVER )
self.tuneInterface = TuneInterface( self.noteDB, self, self.GUI["2tuneScrolledWindow"].get_hadjustment() )
self.noteDB.addListener( self.tuneInterface, TuneInterfaceParasite, True )
self.GUI["2tuneScrolledWindow"].add_with_viewport( self.tuneInterface )
- self.GUI["2tuneBox"].pack_start( self.GUI["2tuneScrolledWindow"] )
+ self.tuneInterface.get_parent().set_shadow_type( gtk.SHADOW_NONE )
+ self.GUI["2tuneVBox"].pack_start( self.GUI["2tuneScrolledWindow"] )
+ self.GUI["2tuneSlider"] = gtk.HScrollbar( self.GUI["2tuneScrolledWindow"].get_hadjustment() ) #ImageHScale( Config.IMAGE_ROOT+"sliderEditTempo.png", self.GUI["2tuneScrolledWindow"].get_hadjustment(), 6 )
+ self.GUI["2tuneVBox"].pack_start( self.GUI["2tuneSlider"], False, False )
+ self.GUI["2tuneHBox"].pack_start( self.GUI["2tuneVBox"] )
+ self.GUI["2tuneScrollRightButton"] = ImageButton( Config.IMAGE_ROOT+"arrowEditRight.png", backgroundFill = Config.BG_COLOR )
+ self.GUI["2tuneScrollRightButton"].set_size_request( 25, toolPanelHeight )
+ self.GUI["2tuneScrollRightButton"].connect( "clicked", lambda a1:self.scrollTune( 1 ) )
+ self.GUI["2tuneHBox"].pack_start( self.GUI["2tuneScrollRightButton"], False, False )
+ self.GUI["2tuneBox"].pack_start( self.GUI["2tuneHBox"] )
self.GUI["2rightPanel"].pack_start( self.GUI["2tuneBox"] )
self.GUI["2main"].pack_start( self.GUI["2rightPanel"] )
@@ -387,11 +401,11 @@ class MainWindow( gtk.EventBox ):
self.GUI["9loopBox"] = formatRoundBox( RoundHBox(), Config.BG_COLOR )
self.GUI["9loopAllOnce"] = gtk.Button("AO")
self.GUI["9loopBox"].pack_start( self.GUI["9loopAllOnce"] )
- self.GUI["9loopAllRepeat"] = gtk.Button("AO")
+ self.GUI["9loopAllRepeat"] = gtk.Button("AR")
self.GUI["9loopBox"].pack_start( self.GUI["9loopAllRepeat"] )
- self.GUI["9loopSelectedOnce"] = gtk.Button("AO")
+ self.GUI["9loopSelectedOnce"] = gtk.Button("SO")
self.GUI["9loopBox"].pack_start( self.GUI["9loopSelectedOnce"] )
- self.GUI["9loopSelectedRepeat"] = gtk.Button("AO")
+ self.GUI["9loopSelectedRepeat"] = gtk.Button("SR")
self.GUI["9loopBox"].pack_start( self.GUI["9loopSelectedRepeat"] )
self.GUI["9loopPopup"].add(self.GUI["9loopBox"])
@@ -904,6 +918,13 @@ class MainWindow( gtk.EventBox ):
# tune/page functions
#-----------------------------------
+ def scrollTune( self, direction ):
+ adj = self.GUI["2tuneScrolledWindow"].get_hadjustment()
+ if direction > 0:
+ adj.set_value( min( adj.value + Config.PAGE_THUMBNAIL_WIDTH, adj.upper - adj.page_size ) )
+ else:
+ adj.set_value( max( adj.value - Config.PAGE_THUMBNAIL_WIDTH, 0) )
+
def displayPage( self, pageId, nextId = -1 ):
self.displayedPage = pageId
diff --git a/Edit/NoteInterface.py b/Edit/NoteInterface.py
index 6b0a8c9..3a90c9f 100644
--- a/Edit/NoteInterface.py
+++ b/Edit/NoteInterface.py
@@ -168,6 +168,8 @@ class NoteInterface:
#self.noteParameters = NoteParametersWindow( self.note, self.getNoteParameters )
return 1 # handled
+ playSample = False
+
if event.type == gtk.gdk._2BUTTON_PRESS: # select bar
self.potentialDeselect = False
start = 0
@@ -185,12 +187,14 @@ class NoteInterface:
self.potentialDeselect = True
else:
emitter.selectNotes( { self.note.track: [ self ] } )
- self.playSampleNote( )
+ playSample = True
percent = eX/self.width
if percent < 0.3: emitter.setCurrentAction( "note-drag-onset", self )
elif percent > 0.7: emitter.setCurrentAction( "note-drag-duration", self )
- else: emitter.setCurrentAction( "note-drag-pitch", self )
+ else:
+ emitter.setCurrentAction( "note-drag-pitch", self )
+ if playSample: self.playSampleNote()
return 1
@@ -200,8 +204,6 @@ class NoteInterface:
self.potentialDeselect = False
emitter.deselectNotes( { self.note.track: [ self ] } )
- self.playSampleNote()
-
emitter.doneCurrentAction()
return True
@@ -217,7 +219,6 @@ class NoteInterface:
if dp != self.lastDragP:
self.lastDragP = dp
stream += [ self.note.id, self.basePitch + dp ]
- self.playSampleNote(False)
def noteDragDuration( self, dd, stream ):
self.potentialDeselect = False
@@ -234,8 +235,6 @@ class NoteInterface:
self.lastDragP = 0
self.lastDragD = 0
- self.playSampleNote()
-
def noteDecOnset( self, step, leftBound, stream ):
if self.selected:
if leftBound < self.note.cs.onset:
diff --git a/Edit/TrackInterface.py b/Edit/TrackInterface.py
index c83bfed..4acba12 100644
--- a/Edit/TrackInterface.py
+++ b/Edit/TrackInterface.py
@@ -66,6 +66,8 @@ class TrackInterface( gtk.EventBox ):
self.curAction = False # stores the current mouse action
self.curActionObject = False # stores the object that in handling the action
+ self.lastDO = self.lastDP = self.lastDD = None
+
self.clickButton = 0 # used in release and motion events to make sure we where actually the widget originally clicked. (hack for popup windows)
self.buttonPressCount = 1 # used on release events to indicate double/triple releases
self.clickLoc = [0,0] # location of the last click
@@ -357,6 +359,7 @@ class TrackInterface( gtk.EventBox ):
id = self.noteDB.addNote( self.curPage, i, cs )
n = self.noteDB.getNote( self.curPage, i, id, self )
self.selectNotes( { i:[n] }, True )
+ n.playSampleNote()
if i != self.drumIndex: # switch to drag duration
self.updateDragLimits()
self.clickLoc[0] += self.ticksToPixels( self.curBeats, 1 )
@@ -494,10 +497,10 @@ class TrackInterface( gtk.EventBox ):
action = self.curAction
self.curAction = False
- if action == "note-drag-onset": self.doneNoteDrag()
- elif action == "note-drag-duration": self.doneNoteDrag()
- elif action == "note-drag-pitch": self.doneNoteDrag()
- elif action == "note-drag-pitch-drum": self.doneNoteDrag()
+ if action == "note-drag-onset": self.doneNoteDrag( action )
+ elif action == "note-drag-duration": self.doneNoteDrag( action )
+ elif action == "note-drag-pitch": self.doneNoteDrag( action )
+ elif action == "note-drag-pitch-drum": self.doneNoteDrag( action )
elif action == "paste":
self.owner.cleanupClipboard()
@@ -631,46 +634,59 @@ class TrackInterface( gtk.EventBox ):
do = self.pixelsToTicks( self.curBeats, event.x - self.clickLoc[0] )
do = min( self.dragLimits[0][1], max( self.dragLimits[0][0], do ) )
- stream = []
- for i in range(Config.NUMBER_OF_TRACKS):
- tstream = []
- for note in self.selectedNotes[i]:
- note.noteDragOnset( do, tstream )
- if len(tstream):
- stream += [ self.curPage, i, PARAMETER.ONSET, len(tstream)//2 ] + tstream
- if len(stream):
- self.noteDB.updateNotes( stream + [-1] )
+ if do != self.lastDO:
+ self.lastDO = do
+ stream = []
+ for i in range(Config.NUMBER_OF_TRACKS):
+ tstream = []
+ for note in self.selectedNotes[i]:
+ note.noteDragOnset( do, tstream )
+ if len(tstream):
+ stream += [ self.curPage, i, PARAMETER.ONSET, len(tstream)//2 ] + tstream
+ if len(stream):
+ self.noteDB.updateNotes( stream + [-1] )
def noteDragDuration( self, event ):
dd = self.pixelsToTicks( self.curBeats, event.x - self.clickLoc[0] )
dd = min( self.dragLimits[2][1], max( self.dragLimits[2][0], dd ) )
- stream = []
- for i in range(Config.NUMBER_OF_TRACKS):
- tstream = []
- for note in self.selectedNotes[i]:
- note.noteDragDuration( dd, tstream )
- if len(tstream):
- stream += [ self.curPage, i, PARAMETER.DURATION, len(tstream)//2 ] + tstream
- if len(stream):
- self.noteDB.updateNotes( stream + [-1] )
+ if dd != self.lastDD:
+ self.lastDD = dd
+ stream = []
+ for i in range(Config.NUMBER_OF_TRACKS):
+ tstream = []
+ for note in self.selectedNotes[i]:
+ note.noteDragDuration( dd, tstream )
+ if len(tstream):
+ stream += [ self.curPage, i, PARAMETER.DURATION, len(tstream)//2 ] + tstream
+ if len(stream):
+ self.noteDB.updateNotes( stream + [-1] )
def noteDragPitch( self, event, drum = False ):
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 ) )
- stream = []
- for i in range(Config.NUMBER_OF_TRACKS):
- tstream = []
- for note in self.selectedNotes[i]:
- note.noteDragPitch( dp, tstream )
- if len(tstream):
- stream += [ self.curPage, i, PARAMETER.PITCH, len(tstream)//2 ] + tstream
- if len(stream):
- self.noteDB.updateNotes( stream + [-1] )
+ if dp != self.lastDP:
+ self.lastDP = dp
+ stream = []
+ for i in range(Config.NUMBER_OF_TRACKS):
+ tstream = []
+ for note in self.selectedNotes[i]:
+ note.noteDragPitch( dp, tstream )
+ if len(tstream):
+ stream += [ self.curPage, i, PARAMETER.PITCH, len(tstream)//2 ] + tstream
+ if len(stream):
+ self.noteDB.updateNotes( stream + [-1] )
+
+ self.curActionObject.playSampleNote( False )
+
+ def doneNoteDrag( self, action ):
+ # if action == "note-drag-pitch" or action == "note-drag-pitch-drum":
+ # self.curActionObject.playSampleNote()
+
+ self.lastDO = self.lastDP = self.lastDD = None
- def doneNoteDrag( self ):
for i in range(Config.NUMBER_OF_TRACKS):
for note in self.selectedNotes[i]:
note.doneNoteDrag( self )
diff --git a/Edit/TuneInterface.py b/Edit/TuneInterface.py
index cc070b8..b5597cd 100644
--- a/Edit/TuneInterface.py
+++ b/Edit/TuneInterface.py
@@ -157,7 +157,7 @@ class TuneInterface( gtk.EventBox ):
self.alloced = False
self.width = self.baseWidth = self.height = -1
self.waitingForAlloc = True
- self.scrollTo = -1
+ self.scrollTo = None
self.clickX = -1
self.set_size_request( self.width, self.height )
@@ -192,9 +192,10 @@ class TuneInterface( gtk.EventBox ):
self.pageY = (self.height-Config.PAGE_THUMBNAIL_HEIGHT)//2
- if self.scrollTo >= 0:
- self.adjustment.set_value( self.scrollTo )
- self.scrollTo = -1
+ if self.scrollTo != None:
+ if self.scrollTo >= 0: self.adjustment.set_value( self.scrollTo )
+ else: self.adjustment.set_value( self.width - self.baseWidth )
+ self.scrollTo = None
self.waitingForAlloc = False
@@ -368,8 +369,6 @@ class TuneInterface( gtk.EventBox ):
startX = self.pageOffset + ind*Config.PAGE_THUMBNAIL_WIDTH
stopX = startX + Config.PAGE_THUMBNAIL_WIDTH
- self.invalidate_rect( startX, 0, Config.PAGE_THUMBNAIL_WIDTH, self.height )
-
if self.adjustment.value > startX:
scroll = startX + Config.PAGE_THUMBNAIL_WIDTH + Config.PAGE_THUMBNAIL_WIDTH_DIV2 - self.baseWidth
if scroll < 0: scroll = 0
@@ -377,11 +376,17 @@ class TuneInterface( gtk.EventBox ):
elif self.adjustment.value + self.baseWidth < stopX:
scroll = startX - Config.PAGE_THUMBNAIL_WIDTH_DIV2
if scroll + self.baseWidth > self.width:
- scroll = stopX - self.baseWidth
- if self.waitingForAlloc:
- self.scrollTo = scroll
- else:
- self.adjustment.set_value( scroll )
+ if self.waitingForAlloc:
+ self.scrollTo = -1
+ else:
+ self.adjustment.set_value( self.width - self.baseWidth )
+ else:
+ if self.waitingForAlloc:
+ self.scrollTo = scroll
+ else:
+ self.adjustment.set_value( scroll )
+
+ self.invalidate_rect( startX, 0, Config.PAGE_THUMBNAIL_WIDTH, self.height )
def selectPage( self, id, exclusive = True ):
if exclusive:
@@ -517,9 +522,11 @@ class TuneInterface( gtk.EventBox ):
stopX = event.area.x + event.area.width
stopY = event.area.y + event.area.height
- # draw bg for pageOffset
+ self.gc.set_clip_rectangle( self.clearMask )
+
+ # draw background
self.gc.foreground = self.bgColor
- drawingArea.window.draw_rectangle( self.gc, True, 0, 0, self.pageOffset, Config.PAGE_THUMBNAIL_HEIGHT )
+ drawingArea.window.draw_rectangle( self.gc, True, startX, startY, event.area.width, event.area.height )
tracks = [ self.owner.getTrackSelected(i) for i in range(Config.NUMBER_OF_TRACKS) ]
@@ -539,8 +546,8 @@ class TuneInterface( gtk.EventBox ):
if self.thumbnailDirty[pageId]:
self.gc.set_clip_origin( 0, 0 )
self.drawThumbnail( pageId, self.thumbnail[pageId], self.thumbnailDirtyRect[pageId] )
- self.gc.set_clip_origin( x, 0 )
- drawingArea.window.draw_drawable( self.gc, self.thumbnail[pageId], 0, 0, x, 0, Config.PAGE_THUMBNAIL_WIDTH, Config.PAGE_THUMBNAIL_HEIGHT )
+ self.gc.set_clip_origin( x, self.pageY )
+ drawingArea.window.draw_drawable( self.gc, self.thumbnail[pageId], 0, 0, x, self.pageY, Config.PAGE_THUMBNAIL_WIDTH, Config.PAGE_THUMBNAIL_HEIGHT )
# draw border if necessary
if pageId == self.displayedPage: # displayed page border
@@ -550,8 +557,8 @@ class TuneInterface( gtk.EventBox ):
drawingArea.window.draw_rectangle( self.gc, True, x + self.trackRect[i][0], self.trackRect[i][1], self.trackRect[i][2], self.trackRect[i][3] )
self.gc.set_function( gtk.gdk.COPY )
self.gc.foreground = self.displayedColor
- self.gc.set_clip_origin( x - Config.PAGE_THUMBNAIL_WIDTH, 0 )
- drawingArea.window.draw_rectangle( self.gc, True, x, 0, Config.PAGE_THUMBNAIL_WIDTH, Config.PAGE_THUMBNAIL_HEIGHT )
+ self.gc.set_clip_origin( x - Config.PAGE_THUMBNAIL_WIDTH, self.pageY )
+ drawingArea.window.draw_rectangle( self.gc, True, x, self.pageY, Config.PAGE_THUMBNAIL_WIDTH, Config.PAGE_THUMBNAIL_HEIGHT )
elif pageId in self.selectedIds: # selected page border
self.gc.set_function( gtk.gdk.INVERT )
for i in range(Config.NUMBER_OF_TRACKS):
@@ -559,18 +566,11 @@ class TuneInterface( gtk.EventBox ):
drawingArea.window.draw_rectangle( self.gc, True, x + self.trackRect[i][0], self.trackRect[i][1], self.trackRect[i][2], self.trackRect[i][3] )
self.gc.set_function( gtk.gdk.COPY )
self.gc.foreground = self.selectedColor
- self.gc.set_clip_origin( x - Config.PAGE_THUMBNAIL_WIDTH, 0 )
- drawingArea.window.draw_rectangle( self.gc, True, x, 0, Config.PAGE_THUMBNAIL_WIDTH, Config.PAGE_THUMBNAIL_HEIGHT )
+ self.gc.set_clip_origin( x - Config.PAGE_THUMBNAIL_WIDTH, self.pageY )
+ drawingArea.window.draw_rectangle( self.gc, True, x, self.pageY, Config.PAGE_THUMBNAIL_WIDTH, Config.PAGE_THUMBNAIL_HEIGHT )
x += Config.PAGE_THUMBNAIL_WIDTH
- self.gc.set_clip_rectangle( self.clearMask )
-
- # fill in extra background
- if x < self.width:
- self.gc.foreground = self.bgColor
- drawingArea.window.draw_rectangle( self.gc, True, x, 0, self.width-x, Config.PAGE_THUMBNAIL_HEIGHT )
-
# draw drop marker
if self.dropAt >= 0:
self.gc.set_line_attributes( self.dropWidth, gtk.gdk.LINE_SOLID, gtk.gdk.CAP_ROUND, gtk.gdk.JOIN_MITER )
@@ -581,6 +581,8 @@ class TuneInterface( gtk.EventBox ):
if self.alloced == False: return
if x < self.visibleX: x = self.visibleX
if x + width > self.visibleEndX: width = self.visibleEndX - x
+ if width <= 0: return
+
self.dirtyRectToAdd.x = x
self.dirtyRectToAdd.y = y
self.dirtyRectToAdd.width = width
diff --git a/Util/ThemeWidgets.py b/Util/ThemeWidgets.py
index cfc1130..83d0cb1 100644
--- a/Util/ThemeWidgets.py
+++ b/Util/ThemeWidgets.py
@@ -50,6 +50,7 @@ widget "*%s*" style "scale_style"
self.connect( "expose-event", self.expose )
self.connect( "size-allocate", self.size_allocate )
self.connect( "button-release-event", self.button_release )
+ adjustment.connect( "changed", self.value_changed )
adjustment.connect( "value-changed", self.value_changed )
def size_allocate( self, widget, allocation ):
@@ -86,6 +87,7 @@ widget "*%s*" style "scale_style"
else:
sliderX = int((self.alloc.width - self.pixbufWidth)*(val-adj.lower)/(adj.upper - adj.lower))
+ print self.alloc.width, self.pixbufWidth, adj.upper, adj.lower, val
if self.insensitivePixbuf != None and self.state == gtk.STATE_INSENSITIVE:
self.window.draw_pixbuf( gc, self.insensitivePixbuf, 0, 0, self.alloc.x + sliderX, self.alloc.y + self.sliderY, self.pixbufWidth, self.pixbufHeight, gtk.gdk.RGB_DITHER_NORMAL, 0, 0 )
else:
@@ -435,7 +437,6 @@ class RoundHBox( gtk.HBox ):
return False
-
class RoundVBox( gtk.VBox ):
def __init__( self, radius = 5, fillcolor = "#000", bordercolor = "#FFF", homogeneous = False, spacing = 0 ):
gtk.VBox.__init__( self, homogeneous, spacing )