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
|
import pygtk
pygtk.require( '2.0' )
import gtk
#----------------------------------------------------------------------
# A verical bar used to show the current point in time on a page
# TODO: modify this class to change the current point in time
# on click and drag
#----------------------------------------------------------------------
class PositionIndicator( gtk.DrawingArea ):
#-----------------------------------
# initialization
#-----------------------------------
def __init__( self, trackIDs, selectedTrackIDs, mutedTrackIDs ):
gtk.DrawingArea.__init__( self )
self.trackIDs = trackIDs
self.selectedTrackIDs = selectedTrackIDs
self.mutedTrackIDs = mutedTrackIDs
self.connect( "expose-event", self.draw )
def draw( self, drawingArea, event ):
indicatorSize = self.get_allocation()
trackHeight = indicatorSize.height / len( self.trackIDs )
context = drawingArea.window.cairo_create()
trackIndex = 0
for trackID in self.trackIDs:
height = trackIndex * trackHeight
context.move_to( 0, height )
context.rel_line_to( indicatorSize.width, 0 )
context.rel_line_to( 0, height + trackHeight )
context.rel_line_to( -indicatorSize.width, 0 )
context.close_path()
if trackID not in self.mutedTrackIDs:
context.set_source_rgb( 0, 0, 0 ) #black
else:
context.set_source_rgb( 0.6, 0.6, 0.6 ) #grey
context.fill_preserve()
context.stroke()
trackIndex += 1
|