Beispiel #1
0
 def __init__(self, callback, strings,
             string_thickness=(1, 1, 1, 1, 1, 1)):
     gtk.DrawingArea.__init__(self)
     CairoCommon.__init__(self)
     self.m_callback = callback
     self.m_strings = strings
     self.m_string_thickness = string_thickness
     self.m_fretdist = (20, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 30, 30)
     self.m_stringdist = 17
     self.m_numstring = len(self.m_strings)
     self.m_neckborder = 6
     self.m_neckl = 0
     self.m_xlist = []
     self.m_lowest_tone = mpd.int_to_notename(
         min(map(mpd.notename_to_int, self.m_strings)))
     self.m_highest_tone = mpd.int_to_notename(
         len(self.m_fretdist) - 1 + max(map(mpd.notename_to_int, self.m_strings)))
     self.m_stringtuning = map(mpd.notename_to_int, self.m_strings)
     tmp = 0
     for x in self.m_fretdist:
         tmp = tmp + x
         self.m_xlist.append(tmp)
     tmp = self.m_neckborder + self.m_stringdist/2
     self.m_ylist = [tmp]
     for y in range(self.m_numstring-1):
         tmp = tmp + self.m_stringdist
         self.m_ylist.append(tmp)
     for x in self.m_fretdist:
         self.m_neckl = self.m_neckl + x
     self.m_neckl = self.m_neckl + 2
     self.m_neckw = self.m_neckborder \
                    + (self.m_numstring-1)*self.m_stringdist \
                    + 1 + self.m_neckborder
     self.set_events(gtk.gdk.BUTTON_PRESS_MASK|gtk.gdk.BUTTON_RELEASE_MASK | gtk.gdk.POINTER_MOTION_MASK | gtk.gdk.ENTER_NOTIFY_MASK | gtk.gdk.LEAVE_NOTIFY_MASK)
     self.connect('expose_event', self.expose)
     self.m_mouse_pos = None, None
     self.connect('motion-notify-event', self.on_motion_notify_event)
     self.connect('leave-notify-event', self.on_leave_notify_event)
     self.connect('button-press-event', self.on_button_press_event)
     self.set_size_request(self.m_neckl, self.m_neckw)
Beispiel #2
0
 def on_button_press_event(self, event, midi_int):
     if event.button == 3:
         utils.play_note(4, midi_int)
     elif event.button == 1:
         self.m_callback(mpd.int_to_notename(midi_int))
 def on_high_changed(self, w, v):
     NotenameRangeController.on_high_changed(self, w, v)
     self.set_string(self.m_name_high, mpd.int_to_notename(self.g_spin_high.get_value()))