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-02-18 02:27:40 (GMT)
committer amartin <olpc@localhost.localdomain>2007-02-18 02:27:40 (GMT)
commit293b47cd9c714730ab5fdd38414d2e817313a213 (patch)
treeb98a7445f4c601c1d417c9b3b05527ead3abcc47 /Edit
parent413329130347634f7bb567ccf2dfe4a47480067a (diff)
note drawing
Diffstat (limited to 'Edit')
-rw-r--r--Edit/MainWindow.py60
-rw-r--r--Edit/NoteInterface.py2
-rw-r--r--Edit/TrackInterface.py61
-rw-r--r--Edit/TuneInterface.py14
4 files changed, 111 insertions, 26 deletions
diff --git a/Edit/MainWindow.py b/Edit/MainWindow.py
index 14de116..778eaf3 100644
--- a/Edit/MainWindow.py
+++ b/Edit/MainWindow.py
@@ -235,30 +235,30 @@ class MainWindow( gtk.EventBox ):
self.GUI["2contextBox"].put( self.GUI["2contextNextButton"], contextWidth-25, 0 )
# + + + page box
self.GUI["2pageBox"] = gtk.HBox()
- self.GUI["2pageBox"].set_size_request( contextWidth-50, -1 )
- self.GUI["2pageGenerateButton"] = gtk.Button("Gen")
+ self.GUI["2pageBox"].set_size_request( contextWidth-50, 73 )
+ self.GUI["2pageGenerateButton"] = ImageButton( Config.IMAGE_ROOT+"genPage.png", Config.IMAGE_ROOT+"genPageOver.png", Config.IMAGE_ROOT+"genPageDown.png", backgroundFill = "#6C9790" )
self.GUI["2pageGenerateButton"].connect( "clicked", lambda a1:self.pageGenerate() )
self.GUI["2pageBox"].pack_start( self.GUI["2pageGenerateButton"] )
- self.GUI["2pagePropertiesButton"] = gtk.Button("Prop")
+ self.GUI["2pagePropertiesButton"] = ImageButton( Config.IMAGE_ROOT+"propPage.png", Config.IMAGE_ROOT+"propPageOver.png", Config.IMAGE_ROOT+"propPageDown.png", backgroundFill = "#6C9790" )
self.GUI["2pagePropertiesButton"].connect( "clicked", lambda a1:self.pageProperties() )
self.GUI["2pageBox"].pack_start( self.GUI["2pagePropertiesButton"] )
- self.GUI["2pageDeleteButton"] = gtk.Button("Delete")
+ self.GUI["2pageDeleteButton"] = ImageButton( Config.IMAGE_ROOT+"delPage.png", Config.IMAGE_ROOT+"delPageOver.png", Config.IMAGE_ROOT+"delPageDown.png", backgroundFill = "#6C9790" )
self.GUI["2pageDeleteButton"].connect( "clicked", lambda a1:self.pageDelete() )
self.GUI["2pageBox"].pack_start( self.GUI["2pageDeleteButton"] )
- self.GUI["2pageDuplicateButton"] = gtk.Button("Duplicate")
+ self.GUI["2pageDuplicateButton"] = ImageButton( Config.IMAGE_ROOT+"dupPage.png", Config.IMAGE_ROOT+"dupPageOver.png", Config.IMAGE_ROOT+"dupPageDown.png", backgroundFill = "#6C9790" )
self.GUI["2pageDuplicateButton"].connect( "clicked", lambda a1:self.pageDuplicate() )
self.GUI["2pageBox"].pack_start( self.GUI["2pageDuplicateButton"] )
- self.GUI["2pageNewButton"] = gtk.Button("New")
+ self.GUI["2pageNewButton"] = ImageButton( Config.IMAGE_ROOT+"addPage.png", Config.IMAGE_ROOT+"addPageOver.png", Config.IMAGE_ROOT+"addPageDown.png", backgroundFill = "#6C9790" )
self.GUI["2pageNewButton"].connect( "clicked", lambda a1:self.pageAdd() )
self.GUI["2pageBox"].pack_start( self.GUI["2pageNewButton"] )
- self.GUI["2pageBeatsButton"] = gtk.Button("Beats")
+ self.GUI["2pageBeatsButton"] = ImageButton( Config.IMAGE_ROOT+"beatPage.png", Config.IMAGE_ROOT+"beatPageOver.png", Config.IMAGE_ROOT+"beatPageDown.png", backgroundFill = "#6C9790" )
self.GUI["2pageBeatsButton"].connect( "clicked", lambda a1:self.pageBeats() )
self.GUI["2pageBox"].pack_start( self.GUI["2pageBeatsButton"] )
self.GUI["2contextBox"].put( self.GUI["2pageBox"], 25, 0 )
# + + + track box
self.GUI["2trackBox"] = gtk.HBox()
- self.GUI["2trackBox"].set_size_request( contextWidth-50, -1 )
- self.GUI["2trackGenerateButton"] = gtk.Button("tGen")
+ self.GUI["2trackBox"].set_size_request( contextWidth-50, 73 )
+ self.GUI["2trackGenerateButton"] = ImageButton( Config.IMAGE_ROOT+"genPage.png", None, None, backgroundFill = "#6C9790" )
self.GUI["2trackGenerateButton"].connect( "clicked", lambda a1:self.trackGenerate() )
self.GUI["2trackBox"].pack_start( self.GUI["2trackGenerateButton"] )
self.GUI["2trackPropertiesButton"] = gtk.Button("tProp")
@@ -273,7 +273,7 @@ class MainWindow( gtk.EventBox ):
self.GUI["2contextBox"].put( self.GUI["2trackBox"], 25, 0 )
# + + + note box
self.GUI["2noteBox"] = gtk.HBox()
- self.GUI["2noteBox"].set_size_request( contextWidth-50, -1 )
+ self.GUI["2noteBox"].set_size_request( contextWidth-50, 73 )
self.GUI["2notePropertiesButton"] = gtk.Button("nProp")
self.GUI["2notePropertiesButton"].connect( "clicked", lambda a1:self.noteProperties() )
self.GUI["2noteBox"].pack_start( self.GUI["2notePropertiesButton"] )
@@ -391,6 +391,36 @@ class MainWindow( gtk.EventBox ):
self.GUI["2noteBox"].hide()
self.setContext( CONTEXT.PAGE )
+ self.tempPopup = gtk.Window(gtk.WINDOW_POPUP)
+ self.tempPopup.set_decorated(False)
+ b = gtk.Button("hello")
+ self.tempPopup.add(b)
+ self.tempPopup.connect("set-focus", self.tempPrint)
+ #b.connect("focus-in-event", self.tempFocus)
+ b.connect("focus-out-event", self.tempFocus)
+ self.tempPopup.move( 100, 100 )
+ self.tempPopup.resize( 300, 100 )
+ #self.tempPopup.show_all()
+ self.menu = gtk.Menu()
+ m1 = gtk.MenuItem("hello")
+ m2 = gtk.MenuItem("people")
+ m3 = gtk.MenuItem("s")
+ self.menu.append(m1)
+ self.menu.append(m2)
+ self.menu.append(m3)
+ m1.show()
+ m2.show()
+ m3.show()
+
+ def tempFocus( self, widget, event ):
+ print "tempFocus", widget, event.type
+ self.tempPopup.hide_all()
+
+ def tempPrint( self, window, widget ):
+ print "tempPrint", window, widget, self.tempPopup
+ print "helloeuaue", self.tempPopup.has_toplevel_focus()
+
+
def updateFPS( self ):
t = time.time()
dt = t - self.fpsLastTime
@@ -537,6 +567,12 @@ class MainWindow( gtk.EventBox ):
def handleTrackVolume( self, widget, track ):
self._data["track_volume"][track] = round( widget.get_value() )
+ def getTrackInstrument( self, track ):
+ return self._data["track_inst"][track]
+
+ def getTrackVolume( self, track ):
+ return self._data["track_volume"][track]
+
def handleTempo( self, widget ):
self._data['tempo'] = round( widget.get_value() )
img = min(7,int(8*(self._data["tempo"]-widget.lower)/(widget.upper-widget.lower)))+1# tempo 1-8
@@ -807,6 +843,10 @@ class MainWindow( gtk.EventBox ):
self.generationParametersWindow.show_all()
def pageProperties( self, pageIds = -1 ):
+ #print "hello", self.tempPopup.has_toplevel_focus()
+ #self.tempPopup.show_all()
+ #self.tempPopup.unfullscreen()
+ #self.menu.popup( None, None, None, self.GUI["2pagePropertiesButton"], 0 )
if pageIds == -1: pageIds = self.tuneInterface.getSelectedIds()
diff --git a/Edit/NoteInterface.py b/Edit/NoteInterface.py
index c923013..90a941e 100644
--- a/Edit/NoteInterface.py
+++ b/Edit/NoteInterface.py
@@ -88,7 +88,7 @@ class NoteInterface:
self.imgX = self.x - Config.NOTE_IMAGE_PADDING
self.oldOnset = self.note.cs.onset
if self.end != self.oldEnd or self.note.cs.onset != self.oldOnset:
- self.width = self.owner.ticksToPixels( self.noteDB.getPage( self.note.page).beats, self.end ) - self.x - self.origin[0]
+ self.width = self.owner.ticksToPixels( self.noteDB.getPage( self.note.page).beats, self.end ) - self.x + self.origin[0]
self.imgWidth = self.width + Config.NOTE_IMAGE_PADDING_MUL2
self.oldEnd = self.end
if self.note.cs.pitch != self.oldPitch:
diff --git a/Edit/TrackInterface.py b/Edit/TrackInterface.py
index ce3ad6e..5d9da92 100644
--- a/Edit/TrackInterface.py
+++ b/Edit/TrackInterface.py
@@ -11,6 +11,7 @@ from Edit.HitInterface import HitInterface
from Edit.MainWindow import CONTEXT
from Util.NoteDB import PARAMETER
+from Util.CSoundNote import CSoundNote
from Util.Profiler import TP
@@ -288,6 +289,13 @@ class TrackInterface( gtk.EventBox ):
TP.ProfileBegin( "TI::handleButtonPress" )
+ if event.button != 1:
+ print "Should bring up some note parameters or something!"
+ #self.noteParameters = NoteParametersWindow( self.trackDictionary, self.getNoteParameters )
+ #self.setCurrentAction( "noteParameters", False )
+ TP.ProfileEnd( "TI::handleButtonPress" )
+ return
+
if event.type == gtk.gdk._2BUTTON_PRESS: self.buttonPressCount = 2
elif event.type == gtk.gdk._3BUTTON_PRESS: self.buttonPressCount = 3
else: self.buttonPressCount = 1
@@ -329,13 +337,32 @@ class TrackInterface( gtk.EventBox ):
break
if self.interfaceMode == INTERFACEMODE.DRAW:
- if handled == -1: # event occured before this note and didn't overlap with the previous note, so we can draw
- print "draw a note"
+ if not handled or handled == -1: # event didn't overlap any notes, so we can draw
+ if i == self.drumIndex: pitch = min( self.pixelsToPitchDrumFloor( self.clickLoc[1] - self.trackLimits[i][1] + Config.HIT_HEIGHT//2 )//Config.PITCH_STEP_DRUM, Config.NUMBER_OF_POSSIBLE_PITCHES_DRUM-1)*Config.PITCH_STEP_DRUM + Config.MINIMUM_PITCH_DRUM
+ else: pitch = min( self.pixelsToPitchFloor( self.clickLoc[1] - self.trackLimits[i][1] + Config.NOTE_HEIGHT//2 ), Config.NUMBER_OF_POSSIBLE_PITCHES-1) + Config.MINIMUM_PITCH
+ print "draw a note", self.curPage, i, self.pixelsToTicksFloor( self.curBeats, self.clickLoc[0] ), pitch
+ cs = CSoundNote( self.pixelsToTicksFloor( self.curBeats, self.clickLoc[0] - self.trackRect[i].x ),
+ pitch,
+ 0.75,
+ 0,
+ 1,
+ i,
+ instrument = self.owner.getTrackInstrument(i),
+ instrumentFlag = self.owner.getTrackInstrument(i) )
+ cs.pageId = self.curPage
+ id = self.noteDB.addNote( self.curPage, i, cs )
+ n = self.noteDB.getNote( self.curPage, i, id, self )
+ self.selectNotes( { i:[n] }, True )
+ if i != self.drumIndex: # switch to drag duration
+ self.updateDragLimits()
+ self.clickLoc[0] += self.ticksToPixels( self.curBeats, 1 )
+ self.setCurrentAction( "note-drag-duration", n )
+ self.setCursor("drag-duration")
+ else:
+ self.curAction = True # we handled this, but there's no real action
- if event.button == 3:
- print "Should bring up some note parameters or something!"
- #self.noteParameters = NoteParametersWindow( self.trackDictionary, self.getNoteParameters )
- #self.setCurrentAction( "noteParameters", False )
+ TP.ProfileEnd( "TI::handleButtonPress" )
+ return
TP.ProfileEnd( "TI::handleButtonPress" )
@@ -343,6 +370,10 @@ class TrackInterface( gtk.EventBox ):
def handleButtonRelease( self, widget, event ):
TP.ProfileBegin( "TI::handleButtonRelease" )
+ if event.button != 1:
+ TP.ProfileEnd( "TI::handleButtonRelease" )
+ return
+
if not self.curAction: #do track selection stuff here so that we can also handle marquee selection
for i in range(Config.NUMBER_OF_TRACKS):
if self.trackLimits[i][0] > event.y: break
@@ -393,7 +424,7 @@ class TrackInterface( gtk.EventBox ):
if self.trackLimits[i][1] < event.y: continue
top = i
break
- self.updatePaste( self.pixelsToTicks( self.curBeats, event.x ), top )
+ self.updatePaste( self.pixelsToTicksFloor( self.curBeats, event.x ), top )
TP.ProfileEnd( "TI::handleMotion::Paste" )
elif event.state & gtk.gdk.BUTTON1_MASK:
TP.ProfileBegin( "TI::handleMotion::Drag" )
@@ -1079,11 +1110,23 @@ class TrackInterface( gtk.EventBox ):
return int(round( ticks * self.pixelsPerTick[beats] ))
def pixelsToTicks( self, beats, pixels ):
return int(round( pixels * self.ticksPerPixel[beats] ))
+ def ticksToPixelsFloor( self, beats, ticks ):
+ return int( ticks * self.pixelsPerTick[beats] )
+ def pixelsToTicksFloor( self, beats, pixels ):
+ return int( pixels * self.ticksPerPixel[beats] )
def pitchToPixels( self, pitch ):
- return int(round( ( Config.MAXIMUM_PITCH - pitch ) * self.pixelsPerPitch ))
+ return int(round( ( Config.MAXIMUM_PITCH - pitch ) * self.pixelsPerPitch ))
def pixelsToPitch( self, pixels ):
return int(round(-pixels*self.pitchPerPixel))
+ def pitchToPixelsFloor( self, pitch ):
+ return int(( Config.MAXIMUM_PITCH - pitch ) * self.pixelsPerPitch )
+ def pixelsToPitchFloor( self, pixels ):
+ return int(-pixels*self.pitchPerPixel)
def pitchToPixelsDrum( self, pitch ):
- return int(round( ( Config.MAXIMUM_PITCH_DRUM - pitch ) * self.pixelsPerPitchDrum ))
+ return int(round( ( Config.MAXIMUM_PITCH_DRUM - pitch ) * self.pixelsPerPitchDrum ))
def pixelsToPitchDrum( self, pixels ):
return int(round(-pixels*self.pitchPerPixelDrum))
+ def pitchToPixelsDrumFloor( self, pitch ):
+ return int( ( Config.MAXIMUM_PITCH_DRUM - pitch ) * self.pixelsPerPitchDrum )
+ def pixelsToPitchDrumFloor( self, pixels ):
+ return int(-pixels*self.pitchPerPixelDrum)
diff --git a/Edit/TuneInterface.py b/Edit/TuneInterface.py
index d1d5481..ce61dd3 100644
--- a/Edit/TuneInterface.py
+++ b/Edit/TuneInterface.py
@@ -90,6 +90,10 @@ class TuneInterface( gtk.EventBox ):
self.set_size_request( max( self.baseWidth, width), -1 )
def handleButtonPress( self, widget, event ):
+ if event.button != 1:
+ # bring up properties or something
+ return
+
ind = int(event.x-self.pageOffset)//self.pageSpacing
if ind >= self.noteDB.getPageCount():
if self.dragMode != self.DRAG_MOVE:
@@ -101,10 +105,6 @@ class TuneInterface( gtk.EventBox ):
id = self.noteDB.getPageByIndex( ind )
- if event.state & gtk.gdk.BUTTON2_MASK:
- # bring up properties or something
- return
-
if event.type == gtk.gdk._3BUTTON_PRESS: # triple click -> select all
self.selectAll()
self.owner.displayPage( id )
@@ -130,8 +130,10 @@ class TuneInterface( gtk.EventBox ):
self.owner.setContext( CONTEXT.PAGE )
def handleButtonRelease( self, widget, event ):
- if self.dragMode == self.DRAG_MOVE \
- and event.button == 1:
+ if event.button != 1:
+ return
+
+ if self.dragMode == self.DRAG_MOVE:
self.invalidate_rect( 0, 0, self.width, self.height ) # drop head
if self.dropAt > 0: after = self.noteDB.getPageByIndex( self.dropAt-1 )