Exemplo n.º 1
0
  def draw(self, canvas, x = 0, y = 0):
    if hasattr(self, "canvas"):
      self.canvas.itemconfigure(self.header, text = self.partition.header)
      x1, y1, x2, y2 = canvas.bbox(self.header)
      old_y1 = self.y1
      self.y1 = y + y2 - y1 + 8
      
      self.canvas.move(self.group, x - self.x, self.y1 - old_y1)

      self.bar.coords(x2 + 20, self.bar.y)
      self.x = x
      
      self.canvas.itemconfigure(self.header, text = self.partition.header)
      
      # All GraphicNote instance share the same y
      self.drawnote.y = self.y1 = y + y2 - y1 + 8
      
      old_height = self.height
      if self.graphic_notes:
        self.height = max(map(lambda graphic_note: graphic_note.height, self.graphic_notes.values()))
        if self.height < 25: self.height = 25
      self.y2 = self.y1 + self.height
      
      if old_height != self.height:
        self.rythm_changed()
        for graphic_note in self.graphic_notes.values(): graphic_note.set_max_height(self.height)
    else:
      self.canvas = canvas
      
      self.group  = view.new_tag()
      self.header = canvas.create_text(x, y + 4, text = self.partition.header, anchor = "nw", tag = self.group)
      x1, y1, x2, y2 = canvas.bbox(self.header)
      self.y1 = y + y2 - y1 + 8
      self.x = x
      
      self.bar = ui.LinksBar(canvas, x2 + 20, y + 10, ((_("Move up")   , lambda event: self.canvas.app.move_partition(self.partition, -1)),
                                                       (_("Move down") , lambda event: self.canvas.app.move_partition(self.partition,  1)),
                                                       (_("Delete")    , lambda event: self.canvas.app.on_partition_delete(self.partition)),
                                                       (_("Properties"), lambda event: self.on_prop()),
                                                       (_("Convert to the new lyrics system"), lambda event: self.on_convert()),
                                                       ),
                             tag = self.group
                             )
      
      # All GraphicNote instance share the same y
      self.drawnote.y = self.y1 = y + y2 - y1 + 8
      
      map(self.drawnote, self.partition.notes)
      
      self.y2 = self.y1 + self.height
      
      self.checktime()
      
    return x, self.y2
Exemplo n.º 2
0
 def draw(self, canvas, x = 0, y = 0):
   if hasattr(self, "canvas"):
     self.canvas.itemconfigure(self.header, text = self.partition.header)
     x1, y1, x2, y2 = canvas.bbox(self.header)
     old_y1 = self.y1
     self.y1 = y + y2 - y1 + 8
     
     self.canvas.move(self.group, x - self.x, self.y1 - old_y1)
     
     self.canvas.coords(self.header, canvas.app.old_x1 + 20, y + 4)
     self.bar.coords(x2 + 20, y + 10)
     self.x = x
     
     self.canvas.itemconfigure(self.header, text = self.partition.header)
     
     self.update()
     
     self.y2 = self.y1 + self.height
   else:
     self.canvas = canvas
     
     self.group  = view.new_tag()
     self.header = canvas.create_text(canvas.app.old_x1 + 20, y + 4, text = self.partition.header, anchor = "nw", tag = (self.group, "noscroll"))
     x1, y1, x2, y2 = canvas.bbox(self.header)
     self.y1 = y + y2 - y1 + 8
     self.x = x
     
     self.bar = ui.LinksBar(canvas, x2 + 20, y + 10, ((_("Move up")   , lambda event: self.canvas.app.move_partition(self.partition, -1)),
                                                      (_("Move down") , lambda event: self.canvas.app.move_partition(self.partition,  1)),
                                                      (_("Delete")    , lambda event: self.canvas.app.on_partition_delete(self.partition)),
                                                      (_("Properties"), lambda event: self.on_prop()),
                                                      ),
                            tag = (self.group, "noscroll")
                            )
     
     self.text = Tkinter.Text(canvas, wrap = "word", font = "Helvetica -12", highlightthickness = 1, highlightcolor = "#AAAADD", selectbackground = "#CCCCFF")
     if self.partition.text and (self.partition.text[-1] == "\n"):
       self.text.insert("end", self.partition.text[:-1])
     else: self.text.insert("end", self.partition.text)
     
     self.text.bind("<FocusIn>"   , self.on_focus)
     self.text.bind("<FocusOut>"  , self.on_focus_out)
     self.text.bind("<KeyRelease>", self.on_text_key_release)
     self.text.bind("<KeyPress>"  , self.on_text_key_press)
     self.text_item = canvas.create_window(self.x, self.y1, window = self.text, anchor = "nw", tag = self.group)
     self.update()
     
     self.y2 = self.y1 + self.height
     
   return x, self.y2