From 2f1cbfa02872c54e977b23872c6b5d0f95aa461b Mon Sep 17 00:00:00 2001 From: David Lewis Date: Thu, 12 Aug 2010 10:00:18 +0200 Subject: [PATCH] Zoom functionality (and change of raster changing function names so that COM-ZOOM-IN means what it should) --- buffer.lisp | 1 + gui.lisp | 53 ++++++++++++++++++++++++++++++++++++----------------- modes.lisp | 3 +++ 3 files changed, 40 insertions(+), 17 deletions(-) diff --git a/buffer.lisp b/buffer.lisp index 0317b14..409afe6 100644 --- a/buffer.lisp +++ b/buffer.lisp @@ -540,6 +540,7 @@ (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) diff --git a/gui.lisp b/gui.lisp index b2d73bd..406712c 100644 --- a/gui.lisp +++ b/gui.lisp @@ -226,16 +226,18 @@ (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))) diff --git a/modes.lisp b/modes.lisp index 593d610..949c9e7 100644 --- a/modes.lisp +++ b/modes.lisp @@ -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))) -- 2.11.4.GIT