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_octave_notename(
min(map(mpd.notename_to_int, self.m_strings)))
self.m_highest_tone = mpd.int_to_octave_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(Gdk.EventMask.BUTTON_PRESS_MASK|Gdk.EventMask.BUTTON_RELEASE_MASK | Gdk.EventMask.POINTER_MOTION_MASK | Gdk.EventMask.ENTER_NOTIFY_MASK | Gdk.EventMask.LEAVE_NOTIFY_MASK)
self.connect('draw', self.draw)
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)
评论列表
文章目录