Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Francis <francis@sugarlabs.org>2013-02-10 17:11:06 (GMT)
committer Daniel Francis <francis@sugarlabs.org>2013-02-10 17:11:06 (GMT)
commit74ccca8586322fa0fd95fe171f6b9287eb60c85d (patch)
tree06b9bebb1d2fd2a5f2fbfe498f490641d95135d8
parent08c9cd4b95e001132352c2d190a4999facf39fee (diff)
Allow to select notes
Signed-off-by: Daniel Francis <francis@sugarlabs.org>
-rw-r--r--__init__.py24
1 files changed, 23 insertions, 1 deletions
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()