From 74ccca8586322fa0fd95fe171f6b9287eb60c85d Mon Sep 17 00:00:00 2001 From: Daniel Francis Date: Sun, 10 Feb 2013 17:11:06 +0000 Subject: Allow to select notes Signed-off-by: Daniel Francis --- diff --git a/__init__.py b/__init__.py index 14eb76d..2b7597f 100644 --- a/__init__.py +++ b/__init__.py @@ -30,13 +30,15 @@ class StaffArea(Gtk.DrawingArea): height = 0 width = 0 tracks = [] + selected = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15] def __init__(self): Gtk.DrawingArea.__init__(self) self.modify_bg(Gtk.StateType.NORMAL, Gdk.color_parse('#FFF')) self.connect('draw', self._draw_cb) self.connect('size-allocate', self.__allocate_cb) - self.tracks.append(Track()) + self.track = Track() + self.tracks.append(self.track) def __allocate_cb(self, widget, rect): self.width = rect.width @@ -50,3 +52,23 @@ class StaffArea(Gtk.DrawingArea): for track in self.tracks: track.linespacing = height * 0.05 track.draw(window, width, context) + + for i in self.selected: + self._draw_note(ctx, i) + + def get_note_position(self, note): + ymax = self.track.piano.ymax + linespacing = self.track.linespacing + noteincrement = linespacing / 2.0 + rmargin = self.track.piano.staffx + linespacing * 2 + lmargin = self.track.piano.staffx * 0.1 + return (rmargin + ((self.width - (rmargin + lmargin)) / 16) * note, ymax - noteincrement * (note + 6), noteincrement) + + def select_note(self, note): + self.selected.append(note) + + def _draw_note(self, ctx, note): + x, y, radius = self.get_note_position(note) + ctx.arc(x, y, radius, 0, 180) + ctx.fill() + ctx.stroke() -- cgit v0.9.1