CVSROOT:        /cvsroot/lilypond
Module name:    ikebana
Branch:         
Changes by:     Han-Wen Nienhuys <[EMAIL PROTECTED]>    05/07/21 23:14:18

Modified files:
        .              : ChangeLog ikebana.py notation.py 
                         notationcanvas.py 

Log message:
        * ikebana.py (NotationApplication.create_window): add zoom.
        
        * notationcanvas.py (Notation_toolbar.__init__): multiple rows.

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/lilypond/ikebana/ChangeLog.diff?tr1=1.2&tr2=1.3&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/lilypond/ikebana/ikebana.py.diff?tr1=1.4&tr2=1.5&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/lilypond/ikebana/notation.py.diff?tr1=1.4&tr2=1.5&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/lilypond/ikebana/notationcanvas.py.diff?tr1=1.4&tr2=1.5&r1=text&r2=text

Patches:
Index: ikebana/ChangeLog
diff -u ikebana/ChangeLog:1.2 ikebana/ChangeLog:1.3
--- ikebana/ChangeLog:1.2       Thu Jul 21 13:50:36 2005
+++ ikebana/ChangeLog   Thu Jul 21 23:14:18 2005
@@ -1,3 +1,9 @@
+2005-07-22  Han-Wen Nienhuys  <[EMAIL PROTECTED]>
+
+       * ikebana.py (NotationApplication.create_window): add zoom.
+
+       * notationcanvas.py (Notation_toolbar.__init__): multiple rows.
+
 2005-07-20  Han-Wen Nienhuys  <[EMAIL PROTECTED]>
 
        * notationcanvas.py (Notation_toolbar.__init__): new class
Index: ikebana/ikebana.py
diff -u ikebana/ikebana.py:1.4 ikebana/ikebana.py:1.5
--- ikebana/ikebana.py:1.4      Thu Jul 21 13:50:36 2005
+++ ikebana/ikebana.py  Thu Jul 21 23:14:18 2005
@@ -47,6 +47,10 @@
         
         win.add (vbox)
         toolbar.show ()
+
+        toolbar.add_button ('zoom out', 'minus', lambda: canvas.zoom (-1), 0)
+        toolbar.add_button ('zoom in', 'Shift+plus', lambda: canvas.zoom (1), 
0)
+        
         win.show()
         
         return win
Index: ikebana/notation.py
diff -u ikebana/notation.py:1.4 ikebana/notation.py:1.5
--- ikebana/notation.py:1.4     Thu Jul 21 13:50:36 2005
+++ ikebana/notation.py Thu Jul 21 23:14:18 2005
@@ -22,6 +22,9 @@
        (make-property-set 'middleCPosition 0) 'Staff)
 """
 
+server = 'maagd'
+# server = 'localhost'
+
 lilypond_input_log_file = open ("input.log", 'w')
 
 def talk_to_lilypond (expression_str):
@@ -31,7 +34,7 @@
         lilypond_input_log_file.flush ()
     
     sock = socket.socket (socket.AF_INET)
-    address = ("localhost", 2904)
+    address = (server, 2904)
     sock.connect (address)
     sock.send (expression_str, socket.MSG_WAITALL)
 
Index: ikebana/notationcanvas.py
diff -u ikebana/notationcanvas.py:1.4 ikebana/notationcanvas.py:1.5
--- ikebana/notationcanvas.py:1.4       Thu Jul 21 13:50:36 2005
+++ ikebana/notationcanvas.py   Thu Jul 21 23:14:18 2005
@@ -1,17 +1,28 @@
 import gtk
 import gnomecanvas
 import music
+import math
 
-
-class Notation_toolbar (gtk.HBox):
+class Notation_toolbar (gtk.VBox):
        def __init__ (self, notation, check_refresh_callback):
-               gtk.HBox.__init__ (self)
+               gtk.VBox.__init__ (self)
                self.button_dict = {}
                self.key_dict = {}
                self.notation = notation
+               self.rows = {}
                self.add_buttons ()
                self.check_refresh_callback = check_refresh_callback
                
+       def get_row (self, row):
+               if not self.rows.has_key (row):
+                       r = gtk.HBox()
+                       self.pack_start (r, expand = False)
+                       r.show ()
+                       self.rows[row] = r
+                       return r
+               
+               return self.rows[row]
+               
        def click_callback (self, widget):
                if not self.button_dict.has_key (widget):
                        print 'no such widget?'
@@ -38,9 +49,11 @@
                button.do_activate (button)
                return True
        
-       def add_button (self, text, key, callback):
+       def add_button (self, text, key, callback, row_id):
                b = gtk.Button (text)
-               self.pack_start (b, expand=True)
+               row = self.get_row (row_id)
+               row.pack_start (b, expand=True)
+               
                b.connect ('clicked', self.click_callback)
                b.set_focus_on_click (False)
                self.key_dict[key] = b
@@ -48,69 +61,69 @@
                b.show ()
 
        def add_buttons (self):
-               for (key_name, text, func) in \
-                       [('Left', '<-',
-                         lambda: self.notation.cursor_move (-1)),
+               for (key_name, text, func, row) in \
+                       [('p', 'LilyPond',
+                         lambda: self.notation.print_score(), 0),
+                        ('q', 'quit',
+                         lambda: gtk.main_quit(), 0),
+                        ('Left', '<-',
+                         lambda: self.notation.cursor_move (-1), 0),
                         ('Right', '->',
-                         lambda: self.notation.cursor_move (1)),
-                        ('space', 'next',
-                         lambda: self.notation.add_note ()),
+                         lambda: self.notation.cursor_move (1), 0),
+                        ('space', 'new',
+                         lambda: self.notation.add_note (), 0),
                         ('BackSpace', 'backspace',
-                         lambda: self.notation.backspace ()),
+                         lambda: self.notation.backspace (), 0),
                         ('Shift+Up', '#',
-                         lambda: self.notation.change_alteration (2)),
+                         lambda: self.notation.change_alteration (2), 1),
                         ('Shift+Down', 'b',
-                         lambda: self.notation.change_alteration (-2)),
+                         lambda: self.notation.change_alteration (-2), 1),
                         ('Up', 'up',
-                         lambda: self.notation.change_step (1)),
+                         lambda: self.notation.change_step (1), 1),
                         ('Down', 'down',
-                         lambda: self.notation.change_step (-1)),
+                         lambda: self.notation.change_step (-1), 1),
                         ('apostrophe', 'oct up',
-                         lambda: self.notation.change_octave (1)),
+                         lambda: self.notation.change_octave (1), 1),
                         ('comma', 'oct down',
-                         lambda: self.notation.change_octave (-1)),
+                         lambda: self.notation.change_octave (-1), 1),
                         ('period', '.',
-                         lambda: self.notation.change_dots ()),
+                         lambda: self.notation.change_dots (), 1),
                         ('slash', 'shorter',
-                         lambda: self.notation.change_duration_log (1)),
+                         lambda: self.notation.change_duration_log (1), 1),
                         ('Shift+asterisk', 'longer',
-                         lambda: self.notation.change_duration_log (-1)),
-                        ('p', 'LilyPond',
-                         lambda: self.notation.print_score()),
-                        ('q', 'quit',
-                         lambda: gtk.main_quit()),
+                         lambda: self.notation.change_duration_log (-1), 1),
                         ('r', 'rest',
-                         lambda: self.notation.ensure_rest ()),
+                         lambda: self.notation.ensure_rest (), 1),
                         ('Shift+C', '+C',
-                         lambda: self.notation.add_step (0)),
+                         lambda: self.notation.add_step (0), 2),
                         ('Shift+D', '+D',
-                         lambda: self.notation.add_step (1)),
+                         lambda: self.notation.add_step (1), 2),
                         ('Shift+E', '+E',
-                         lambda: self.notation.add_step (2)),
+                         lambda: self.notation.add_step (2), 2),
                         ('Shift+F', '+F',
-                         lambda: self.notation.add_step (3)),
+                         lambda: self.notation.add_step (3), 2),
                         ('Shift+G', '+G',
-                         lambda: self.notation.add_step (4)),
+                         lambda: self.notation.add_step (4), 2),
                         ('Shift+A', '+A',
-                         lambda: self.notation.add_step (5)),
+                         lambda: self.notation.add_step (5), 2),
                         ('Shift+B', '+B',
-                         lambda: self.notation.add_step (6)),
+                         lambda: self.notation.add_step (6), 2),
                         ('c', 'C',
-                         lambda: self.notation.set_step (0)),
+                         lambda: self.notation.set_step (0), 3),
                         ('d', 'D',
-                         lambda: self.notation.set_step (1)),
+                         lambda: self.notation.set_step (1), 3),
                         ('e', 'E',
-                         lambda: self.notation.set_step (2)),
+                         lambda: self.notation.set_step (2), 3),
                         ('f', 'F',
-                         lambda: self.notation.set_step (3)),
+                         lambda: self.notation.set_step (3), 3),
                         ('g', 'G',
-                         lambda: self.notation.set_step (4)),
+                         lambda: self.notation.set_step (4), 3),
                         ('a', 'A',
-                         lambda: self.notation.set_step (5)),
+                         lambda: self.notation.set_step (5), 3),
                         ('b', 'B',
-                         lambda: self.notation.set_step (6))]:
+                         lambda: self.notation.set_step (6), 3)]:
                        
-                       self.add_button (text, key_name, func)
+                       self.add_button (text, key_name, func, row)
 
 
 class Notation_canvas (gnomecanvas.Canvas):
@@ -120,14 +133,16 @@
                gnomecanvas.Canvas.__init__ (self,
                                             #aa=True
                                             )
-               (w,h) = (800,400)
+               (w,h) = (400,200)
                self.set_size_request (w, h) 
                self.set_scroll_region (0, 0, w, h)
                root = self.root ()
-               root.affine_relative ((1,0,0,-1,0,0))
+               root.affine_relative ((1,0,0,-1,0, 5))
                self.pixel_scale = 10
                self.set_pixels_per_unit (self.pixel_scale)
-               i = root.add (gnomecanvas.CanvasRect, x2 = w, y2 = -h,
+               i = root.add (gnomecanvas.CanvasRect,
+                             y1 = 5,
+                             x2 = w, y2 = -h + 5,
                              fill_color = 'white', outline_color = 'white')
                i.notation_item = None
                self.notation_canvas_controller = canvas_controller
@@ -187,6 +202,11 @@
                if c_items:
                        self.set_cursor (c_items[0].notation_item)
 
+       def zoom (self, delta):
+               fact = pow (1.25, delta)
+               self.pixel_scale *= fact
+               self.set_pixels_per_unit (self.pixel_scale)
+               
 class Notation_canvas_controller:
        """The connection between canvas and the abstract notation graphics."""
 
@@ -206,3 +226,5 @@
                        self.update_canvas ()
                elif self.notation.cursor_touched:
                        self.update_cursor ()
+
+       


_______________________________________________
Lilypond-cvs mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/lilypond-cvs

Reply via email to