From 29e22f05090827be14e2d9cfd29c73a5d0ec9239 Mon Sep 17 00:00:00 2001 From: amartin Date: Wed, 01 Aug 2007 11:26:00 +0000 Subject: Jam Desktop --- (limited to 'Jam/Picker.py') diff --git a/Jam/Picker.py b/Jam/Picker.py new file mode 100644 index 0000000..5c1627b --- /dev/null +++ b/Jam/Picker.py @@ -0,0 +1,51 @@ + +import pygtk +pygtk.require( '2.0' ) +import gtk + +import Jam.Block as Block + +class Picker( gtk.HBox ): + + INSTRUMENTS = 0 + LOOPS = 1 + DRUMKITS = 2 + + def __init__( self, owner, type, filter = None ): + gtk.HBox.__init__( self ) + + self.owner = owner + + self.type = type + self.filter = filter + + self.desktop = owner.getDesktop() + + # temp + dummy = gtk.Button("dummy") + dummy.add_events(gtk.gdk.BUTTON_MOTION_MASK) + dummy.connect( "button-press-event", self.button_press ) + dummy.connect( "button-release-event", self.button_release ) + dummy.connect( "motion-notify-event", self.motion_notify ) + + self.pack_start( dummy, False, False ) + + def button_press( self, widget, event ): + alloc = widget.get_allocation() + if self.type == Picker.INSTRUMENTS: + blockClass = Block.Instrument + blockData = [] + loc = ( alloc.x + event.x - blockClass.WIDTH_DIV2, -1 ) + elif self.type == Picker.LOOPS: + pass + elif self.type == Picker.DRUMKITS: + pass + self.desktop.addBlock( blockClass, blockData, loc, True ) + + def button_release( self, widget, event ): + self.desktop.button_release( widget, event ) + + def motion_notify( self, widget, event ): + self.desktop.motion_notify( widget, event ) + + -- cgit v0.9.1