[gsharp-cvs] CVS update: gsharp/buffer.lisp gsharp/gui.lisp gsharp/measure.lisp gsharp/packages.lisp
Robert Strandh
rstrandh at common-lisp.net
Thu Jan 5 19:14:56 UTC 2006
Update of /project/gsharp/cvsroot/gsharp
In directory common-lisp.net:/tmp/cvs-serv20699
Modified Files:
buffer.lisp gui.lisp measure.lisp packages.lisp
Log Message:
Fixed a bug reported by Christophe Rhodes. The symptoms were that the
stems were not recomputed when the clef of the staff was changed. In
fact, all elements that display on a staff need to be invalidated when
the clef of the staff changes.
Again, I used only the CLIM Desktop to accomplish this modification.
Date: Thu Jan 5 20:14:49 2006
Author: rstrandh
Index: gsharp/buffer.lisp
diff -u gsharp/buffer.lisp:1.27 gsharp/buffer.lisp:1.28
--- gsharp/buffer.lisp:1.27 Sun Nov 20 20:17:22 2005
+++ gsharp/buffer.lisp Thu Jan 5 20:14:45 2006
@@ -66,7 +66,7 @@
;;; Staff
(defclass staff (gsharp-object name-mixin)
- ()
+ ((buffer :initarg :buffer :accessor buffer))
(:default-initargs :name "default staff"))
;;; fiveline
@@ -945,8 +945,17 @@
(left-offset :initform *default-left-offset* :initarg :left-offset :accessor left-offset)
(left-margin :initform *default-left-margin* :initarg :left-margin :accessor left-margin)))
+(defun set-buffer-of-staves (buffer)
+ (loop for staff in (staves buffer)
+ do (setf (buffer staff) buffer)))
+
+(defmethod (setf staves) :after (staves (buffer buffer))
+ (declare (ignore staves))
+ (set-buffer-of-staves buffer))
+
(defmethod initialize-instance :after ((b buffer) &rest args)
(declare (ignore args))
+ (set-buffer-of-staves b)
(with-slots (segments) b
(when (null segments)
(add-segment (make-instance 'segment :staff (car (staves b))) b 0))
@@ -1034,10 +1043,12 @@
(assert (not (null staves)))
(if (eq staff (car staves))
(push newstaff (cdr staves))
- (add-staff-after newstaff staff (cdr staves))))
+ (add-staff-after newstaff staff (cdr staves)))
+ staves)
(defmethod add-staff-after-staff (staff newstaff (buffer buffer))
- (add-staff-after newstaff staff (staves buffer)))
+ (setf (staves buffer)
+ (add-staff-after newstaff staff (staves buffer))))
(defmethod rename-staff (staff-name (staff staff) (buffer buffer))
(assert (not (find-staff staff-name buffer nil)) () 'staff-already-in-buffer)
Index: gsharp/gui.lisp
diff -u gsharp/gui.lisp:1.50 gsharp/gui.lisp:1.51
--- gsharp/gui.lisp:1.50 Tue Jan 3 15:25:46 2006
+++ gsharp/gui.lisp Thu Jan 5 20:14:45 2006
@@ -1090,20 +1090,9 @@
(layer (layer (current-cursor))))
(remove-staff-from-layer staff layer)))
-(defun invalidate-slice-using-staff (slice staff)
- (declare (ignore staff)) ; maybe use this later
- (loop for bar in (bars slice)
- do (loop for element in (elements bar)
- do (mark-modified element))))
-
(define-gsharp-command com-more-sharps ()
(let ((staff (car (staves (layer (current-cursor))))))
- (loop for segment in (segments (current-buffer))
- do (loop for layer in (layers segment)
- do (when (member staff (staves layer))
- (invalidate-slice-using-staff (head layer) staff)
- (invalidate-slice-using-staff (body layer) staff)
- (invalidate-slice-using-staff (tail layer) staff))))
+ (invalidate-everything-using-staff (current-buffer) staff)
(let ((keysig (keysig staff)))
(cond ((eq (aref keysig 3) :flat) (setf (aref keysig 3) :natural))
((eq (aref keysig 0) :flat) (setf (aref keysig 0) :natural))
@@ -1122,12 +1111,7 @@
(define-gsharp-command com-more-flats ()
(let ((staff (car (staves (layer (current-cursor))))))
- (loop for segment in (segments (current-buffer))
- do (loop for layer in (layers segment)
- do (when (member staff (staves layer))
- (invalidate-slice-using-staff (head layer) staff)
- (invalidate-slice-using-staff (body layer) staff)
- (invalidate-slice-using-staff (tail layer) staff))))
+ (invalidate-everything-using-staff (current-buffer) staff)
(let ((keysig (keysig staff)))
(cond ((eq (aref keysig 6) :sharp) (setf (aref keysig 6) :natural))
((eq (aref keysig 2) :sharp) (setf (aref keysig 2) :natural))
Index: gsharp/measure.lisp
diff -u gsharp/measure.lisp:1.21 gsharp/measure.lisp:1.22
--- gsharp/measure.lisp:1.21 Tue Jan 3 15:25:46 2006
+++ gsharp/measure.lisp Thu Jan 5 20:14:45 2006
@@ -13,6 +13,23 @@
(define-added-mixin rstaff () staff
((rank :accessor staff-rank)))
+(defun invalidate-slice-using-staff (slice staff)
+ (declare (ignore staff)) ; maybe use this later
+ (loop for bar in (bars slice)
+ do (loop for element in (elements bar)
+ do (mark-modified element))))
+
+(defun invalidate-everything-using-staff (buffer staff)
+ (loop for segment in (segments buffer)
+ do (loop for layer in (layers segment)
+ do (when (member staff (staves layer))
+ (invalidate-slice-using-staff (head layer) staff)
+ (invalidate-slice-using-staff (body layer) staff)
+ (invalidate-slice-using-staff (tail layer) staff)))))
+
+(defmethod (setf clef) :before (clef (staff staff))
+ (invalidate-everything-using-staff (buffer staff) staff))
+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; Note
Index: gsharp/packages.lisp
diff -u gsharp/packages.lisp:1.39 gsharp/packages.lisp:1.40
--- gsharp/packages.lisp:1.39 Wed Jan 4 18:35:51 2006
+++ gsharp/packages.lisp Thu Jan 5 20:14:45 2006
@@ -137,7 +137,8 @@
#:group-notes-by-staff #:final-relative-note-xoffset
#:final-accidental #:final-relative-accidental-xoffset
#:timeline #:timelines #:elasticity
- #:smallest-gap #:elasticity-function))
+ #:smallest-gap #:elasticity-function
+ #:invalidate-everything-using-staff))
(defpackage :gsharp-postscript
(:use :clim :clim-lisp)
More information about the Gsharp-cvs
mailing list