Zoom functionality (and change of raster changing function names so that COM-ZOOM...
authorDavid Lewis <[email protected]>
Thu, 12 Aug 2010 08:00:18 +0000 (12 10:00 +0200)
committerDavid Lewis <[email protected]>
Wed, 14 Sep 2011 13:07:17 +0000 (14 14:07 +0100)
buffer.lisp
gui.lisp
modes.lisp

index 0317b14..409afe6 100644 (file)
    (staves :initform (list (make-fiveline-staff))
            :initarg :staves :accessor staves)
    (rastral-size :initform 6 :initarg :r-size :accessor rastral-size)
+   (zoom-level :initform 1 :initarg :zoom :accessor zoom-level)
    ;; the min width determines the preferred geographic distance after the
    ;; timeline with the shortest duration on a line.
    (min-width :initform *default-min-width* :initarg :min-width :accessor min-width)
index b2d73bd..406712c 100644 (file)
--- a/gui.lisp
+++ b/gui.lisp
   (update-page-numbers frame))
 
 (defmethod display-score ((frame gsharp) pane)
-  (let* ((buffer (buffer (view pane))))
-    (score-pane:with-score-pane pane
-      (draw-buffer pane buffer (current-cursor)
-                   (left-margin buffer) 100)
-      (draw-the-cursor pane (current-cursor) (cursor-element (current-cursor))
-                       (last-note (input-state *application-frame*)))
-      (multiple-value-bind (minx miny maxx maxy)
-          (bounding-rectangle* (stream-output-history pane))
-        (declare (ignore minx maxx))
-        (change-space-requirements pane :height (+ maxy miny))))))
+  (let* ((buffer (buffer (view pane)))
+         (zoom (gsharp-buffer::zoom-level buffer)))
+    (with-drawing-options (pane :transformation (make-scaling-transformation zoom zoom))
+      (score-pane:with-score-pane pane
+        (draw-buffer pane buffer (current-cursor)
+                     (left-margin buffer) 100)
+        (draw-the-cursor pane (current-cursor) (cursor-element (current-cursor))
+                         (last-note (input-state *application-frame*)))
+        (multiple-value-bind (minx miny maxx maxy)
+            (bounding-rectangle* (stream-output-history pane))
+          (declare (ignore minx maxx))
+          (change-space-requirements pane :height (+ maxy miny)))))))
 
 (defmethod window-clear ((pane score-pane:score-pane))
   (let ((output-history (stream-output-history pane)))
@@ -613,13 +615,22 @@ Prints the results in the minibuffer."
          (result (format nil "~:[; No values~;~:*~{~S~^,~}~]" values)))
     (display-message result)))
 
-(define-gsharp-command (com-zoom-in :name t) ()
-  (incf (gsharp-buffer::rastral-size (buffer (current-cursor)))))
-(define-gsharp-command (com-zoom-out :name t) ()
-  (unless (<= (gsharp-buffer::rastral-size (buffer (current-cursor))) 6)
-    (decf (gsharp-buffer::rastral-size (buffer (current-cursor))))))
-(set-key 'com-zoom-in 'global-gsharp-table '(#\+))
-(set-key 'com-zoom-out 'global-gsharp-table '(#\-))
+(define-gsharp-command (com-raster+ :name t) ()
+  (let ((score-pane (get-main-score-pane)))
+    (incf (gsharp-buffer::rastral-size (buffer (current-cursor))))
+    (redisplay-frame-pane *application-frame* score-pane :force-p t)))
+(define-gsharp-command (com-raster- :name t) ()
+  (let ((score-pane (get-main-score-pane)))
+    (unless (<= (gsharp-buffer::rastral-size (buffer (current-cursor))) 6)
+      (decf (gsharp-buffer::rastral-size (buffer (current-cursor))))
+      (redisplay-frame-pane *application-frame* score-pane :force-p t))))
+
+(defun get-main-score-pane ()
+  (find "score" 
+        (frame-current-panes *application-frame*)
+        :key #'pane-name
+        :test #'string=))
+
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;;
 ;;; note insertion commands
@@ -1675,3 +1686,11 @@ Prints the results in the minibuffer."
     ()
   (com-write-buffer (gui-get-pathname :extensions '("gsh" "mxml" "xml"))))
 
+(define-gsharp-command (com-zoom-in :name t :menu t)
+    ()
+  (unless (<= (gsharp-buffer::zoom-level (buffer (current-cursor))) 64)
+    (incf (gsharp-buffer::zoom-level (buffer (current-cursor))) 1/4)))
+(define-gsharp-command (com-zoom-out :name t :menu t)
+    ()
+  (unless (<= (gsharp-buffer::zoom-level (buffer (current-cursor))) 1/4)
+    (decf (gsharp-buffer::zoom-level (buffer (current-cursor))) 1/4)))
index 593d610..949c9e7 100644 (file)
@@ -49,6 +49,9 @@
 (set-key 'com-istate-fewer-lbeams 'global-gsharp-table '((#\i) (#\x) (#\[)))
 (set-key 'com-istate-fewer-rbeams 'global-gsharp-table '((#\i) (#\x) (#\])))
 
+(set-key 'com-zoom-in 'global-gsharp-table '(#\+))
+(set-key 'com-zoom-out 'global-gsharp-table '(#\-))
+
 (set-key `(com-eval-expression ,*unsupplied-argument-marker*) 
          'global-gsharp-table '((#\: :meta)))