Logo Search packages:      
Sourcecode: jokosher version File versions  Download package

def TimeLine::TimeLine::DrawLine (   self,
  widget 
)

Draws the timeline and saves it to memory
    - Must be called initially and to redraw the timeline
  after moving the project start

Definition at line 80 of file TimeLine.py.

00080                                 :
            """ Draws the timeline and saves it to memory
                - Must be called initially and to redraw the timeline
                          after moving the project start
            """
            d = widget.window

            gc = d.new_gc()
            
            y = 0
            
            col = gc.get_colormap().alloc_color("#FFFFFF")
            gc.set_foreground(col)
            gc.set_fill(gtk.gdk.SOLID)
            
            d.draw_rectangle( gc, True, 
                                          0, 
                                          0, 
                                          self.get_allocation().width, 
                                          self.get_allocation().height)
                                          
            col = gc.get_colormap().alloc_color("#555555")
            gc.set_foreground(col)
                                          
            d.draw_rectangle( gc, False, 
                                          0, 
                                          0, 
                                          self.get_allocation().width, 
                                          self.get_allocation().height)
            
            transport = self.project.transport
            x = 0
            if transport.mode == transport.MODE_BARS_BEATS:
            
                  # Calculate our scroll offset
                  pos = (self.project.viewStart / 60.) * transport.bpm
                  beat = int(pos)
                  offset = pos - beat
                  
                  if offset > 0.:
                        x -= offset * ((self.project.viewScale * 60.) / transport.bpm)
                        x += (self.project.viewScale * 60.) / transport.bpm
                        beat += 1
            
                  while x < self.get_allocation().width:
                        # Draw the beat/bar divisions
                        ix = int(x)
                        if beat % transport.meter_nom:
                              d.draw_line(gc, ix, int(self.get_allocation().height/1.2), ix, self.get_allocation().height)
                        else:
                              d.draw_line(gc, ix, int(self.get_allocation().height/2), ix, self.get_allocation().height)
                              
                              # Draw the bar number
                              l = pango.Layout(self.create_pango_context())
                              l.set_text(str((beat / transport.meter_nom)+1))
                              d.draw_layout(gc, ix, 5, l)
                              
                        beat += 1
                        
                        x += (60. / transport.bpm ) * self.project.viewScale
            else:
                  # Calculate our scroll offset
                  sec = int(self.project.viewStart)
                  offset = self.project.viewStart - sec

                  if offset > 0.:
                        x -= offset * self.project.viewScale
                        x += self.project.viewScale
                        sec += 1
                        
                  # Draw ticks up to the end of our display
                  while x < self.get_allocation().width:
                        ix = int(x)
                        if sec % 5:
                              d.draw_line(gc, ix, int(self.get_allocation().height/1.2), ix, self.get_allocation().height)
                        else:
                              d.draw_line(gc, ix, int(self.get_allocation().height/2), ix, self.get_allocation().height)
                              
                              # Draw the bar number
                              l = pango.Layout(self.create_pango_context())
                              l.set_text("%d:%02d"%(sec / 60, sec % 60))
                              d.draw_layout(gc, ix, 5, l)
                              
                        sec += 1
                        x += self.project.viewScale
            self.savedLine = d.get_image(0, 0, self.get_allocation().width, self.get_allocation().height)
      
      #_____________________________________________________________________
            
      def do_size_request(self, requisition):


Generated by  Doxygen 1.6.0   Back to index