Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Edit/MainWindow.py18
-rw-r--r--Util/InstrumentPanel.py34
2 files changed, 47 insertions, 5 deletions
diff --git a/Edit/MainWindow.py b/Edit/MainWindow.py
index dc29b11..7d716c6 100644
--- a/Edit/MainWindow.py
+++ b/Edit/MainWindow.py
@@ -9,6 +9,7 @@ from Util.Profiler import TP
from Util.NoteDB import NoteDB
from Util.CSoundClient import new_csound_client
from Util.InstrumentPanel import InstrumentPanel
+from Util.InstrumentPanel import DrumPanel
import time
@@ -78,7 +79,7 @@ class MainWindow( SubActivity ):
def init_GUI():
self.instrumentPanel = InstrumentPanel( self.donePickInstrument, enterMode = True )
-
+ self.drumPanel = DrumPanel( self.donePickDrum )
self.GUI = {}
self.GUI["2main"] = gtk.HBox()
@@ -99,7 +100,7 @@ class MainWindow( SubActivity ):
return instrumentMenuBar
def draw_inst_icons():
- instrumentNames = [ k for k in Config.INSTRUMENTS.keys() if k[0:4] != 'drum' and k[0:4] != 'guid']
+ instrumentNames = [ k for k in Config.INSTRUMENTS.keys() if k[0:4] != 'drum' and k[0:4] != 'guid'] + Config.DRUMKITS
self.GUI["2instrumentIcons"] = {}
for instrument in instrumentNames:
self.GUI["2instrumentIcons"][instrument] = gtk.gdk.pixbuf_new_from_file(Config.IMAGE_ROOT + instrument + '.png')
@@ -188,7 +189,8 @@ class MainWindow( SubActivity ):
self.GUI["2drumvolumeSlider"].set_size_request( 30, -1 )
self.GUI["2drumvolumeAdjustment"].connect( "value-changed", self.handleTrackVolume, 4 )
self.GUI["2drumBox"].pack_start( self.GUI["2drumvolumeSlider"], False, False, 0 )
- self.GUI["2drumButton"] = gtk.Button("?")
+ self.GUI["2drumButton"] = ImageButton(Config.IMAGE_ROOT + 'drum1kit' + '.png')
+ self.GUI["2drumButton"].connect("pressed", self.pickDrum)
self.GUI["2drumBox"].pack_start( self.GUI["2drumButton"] )
#self.GUI["2instrument1Box"].pack_start( track_menu(4,'?') )
self.GUI["2instrumentPanel"].pack_start( self.GUI["2drumBox"] )
@@ -692,6 +694,16 @@ class MainWindow( SubActivity ):
self.GUI["2main"].pack_start( self.GUI["2rightPanel"] )
self.GUI["2instrument" + str(self.panel_track+1) + "Button"].load_pixmap( "main", self.GUI["2instrumentIcons"][instrumentName] )
#self.instrumentPanel.destroy()
+
+ def pickDrum( self, widget , data = None ):
+ self.GUI["2main"].remove( self.GUI["2rightPanel"] )
+ self.GUI["2main"].pack_start( self.drumPanel )
+
+ def donePickDrum( self, drum ):
+ self._data['track_inst'][4] = drum
+ self.GUI["2drumButton"].load_pixmap( "main", self.GUI["2instrumentIcons"][drum] )
+ self.GUI["2main"].remove( self.drumPanel )
+ self.GUI["2main"].pack_start( self.GUI["2rightPanel"] )
#-----------------------------------
# generation functions
diff --git a/Util/InstrumentPanel.py b/Util/InstrumentPanel.py
index 84c8f11..fc6185c 100644
--- a/Util/InstrumentPanel.py
+++ b/Util/InstrumentPanel.py
@@ -8,7 +8,7 @@ import Config
from Util.ThemeWidgets import *
Tooltips = Config.Tooltips
-class InstrumentPanel(gtk.EventBox):
+class InstrumentPanel( gtk.EventBox ):
def __init__(self,setInstrument = None, playInstrument = None, enterMode = False, micRec = None, synthRec = None, rowLen = 8, _instDic = None ):
gtk.EventBox.__init__(self)
color = gtk.gdk.color_parse(Config.PANEL_BCK_COLOR)
@@ -190,9 +190,39 @@ class InstrumentPanel(gtk.EventBox):
#instrumentList = instrumentList.sort(lambda g,l: cmp(Config.INSTRUMENTS[g].category, Config.INSTRUMENTS[l].category) )
return instrumentList
+class DrumPanel( gtk.EventBox ):
+ def __init__(self, setDrum = None):
+ gtk.EventBox.__init__(self)
+ color = gtk.gdk.color_parse(Config.PANEL_BCK_COLOR)
+ self.modify_bg(gtk.STATE_NORMAL, color)
+
+ self.setDrum = setDrum
+ self.drawDrums()
+
+ def drawDrums(self):
+ firstBtn = None
+ btnBox = RoundHBox(fillcolor = '#6F947B', bordercolor = Config.PANEL_BCK_COLOR, radius = Config.PANEL_RADIUS)
+ btnBox.set_border_width(Config.PANEL_SPACING)
+ self.drums = {}
+ for drumkit in Config.DRUMKITS:
+ instBox = RoundVBox(fillcolor = Config.INST_BCK_COLOR, bordercolor = Config.PANEL_COLOR, radius = Config.PANEL_RADIUS)
+ instBox.set_border_width(Config.PANEL_SPACING)
+ self.drums[drumkit] = ImageRadioButton(firstBtn, Config.IMAGE_ROOT + drumkit + '.png' , Config.IMAGE_ROOT + drumkit + 'sel.png', Config.IMAGE_ROOT + drumkit + 'sel.png')
+ self.drums[drumkit].connect('clicked',self.setDrums,drumkit)
+ if firstBtn == None:
+ firstBtn = self.drums[drumkit]
+ instBox.pack_start(self.drums[drumkit], False, False, 0)
+ btnBox.pack_start(instBox, False, False, 0)
+ self.add(btnBox)
+ self.show_all()
+
+ def setDrums(self,widget,data):
+ if widget.get_active():
+ if self.setDrum: self.setDrum(data)
+
if __name__ == "__main__":
win = gtk.Window()
- wc = InstrumentPanel()
+ wc = DrumPanel(None)
win.add(wc)
win.show()
#start the gtk event loop