Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/Jam/Picker.py
blob: 5c1627b4ff6b5d9244710bf16869b809e0705713 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
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 )