[gsharp-cvs] CVS update: gsharp/buffer.lisp gsharp/gui.lisp gsharp/packages.lisp

Robert Strandh rstrandh at common-lisp.net
Wed Nov 2 19:28:10 UTC 2005


Update of /project/gsharp/cvsroot/gsharp
In directory common-lisp.net:/tmp/cvs-serv19750

Modified Files:
	buffer.lisp gui.lisp packages.lisp 
Log Message:
Put back some more constructors. 

Two things need to be fixed ultimately: 

  * Clefs should not be named objects.  Instead, the exact type should
    probably be identified by subclassing

  * There is not compelling reason for bars to be subclassed.  The 
    distinction between melody and lyrics (and percussion, ultimately)
    is enough to enforce at the level of the layer. 



Date: Wed Nov  2 20:28:09 2005
Author: rstrandh

Index: gsharp/buffer.lisp
diff -u gsharp/buffer.lisp:1.21 gsharp/buffer.lisp:1.22
--- gsharp/buffer.lisp:1.21	Wed Nov  2 06:01:10 2005
+++ gsharp/buffer.lisp	Wed Nov  2 20:28:08 2005
@@ -406,6 +406,19 @@
 	 (setf text (make-array length :adjustable t :element-type 'fixnum
 				:fill-pointer length :initial-contents text))))))
 
+(defun make-lyrics-element (staff &rest args
+			    &key (notehead :filled) (lbeams 0) (rbeams 0)
+			    (dots 0) (xoffset 0))
+  (declare (type staff staff)
+	   (type (member :whole :half :filled) notehead)
+	   (type (integer 0 5) lbeams)
+	   (type (integer 0 5) rbeams)
+	   (type (integer 0 3) dots)
+	   (type number xoffset)
+	   (ignore notehead lbeams rbeams dots xoffset))
+  (apply #'make-instance 'lyrics-element
+	 :staff staff args))
+
 (defmethod print-object :after ((elem lyrics-element) stream)
   (with-slots (staff text) elem
      (format stream ":staff ~W :text ~W " staff text)))
@@ -500,6 +513,9 @@
 (defclass melody-bar (bar)
   ((print-character :allocation :class :initform #\|)))
 
+(defun make-melody-bar ()
+  (make-instance 'melody-bar))
+
 (defun read-melody-bar-v3 (stream char n)
   (declare (ignore char n))
   (apply #'make-instance 'melody-bar (read-delimited-list #\] stream t)))
@@ -511,6 +527,9 @@
 (defclass lyrics-bar (bar)
   ((print-character :allocation :class :initform #\C)))
 
+(defun make-lyrics-bar ()
+  (make-instance 'lyrics-bar))
+
 (defun read-lyrics-bar-v3 (stream char n)
   (declare (ignore char n))
   (apply #'make-instance 'lyrics-bar (read-delimited-list #\] stream t)))
@@ -594,7 +613,7 @@
       (setf bars (delete bar bars :test #'eq))
       (unless bars
 	;; make sure there is one bar left
-	(add-bar (make-instance 'melody-bar) slice 0)))
+	(add-bar (make-melody-bar) slice 0)))
     (setf slice nil)))
 
 (defmethod remove-bar ((bar lyrics-bar))
@@ -604,7 +623,7 @@
       (setf bars (delete bar bars :test #'eq))
       (unless bars
 	;; make sure there is one bar left
-	(add-bar (make-instance 'lyrics-bar) slice 0)))
+	(add-bar (make-lyrics-bar) slice 0)))
     (setf slice nil)))
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -663,7 +682,7 @@
 (defmethod make-layer (name (initial-staff fiveline-staff))
   (flet ((make-initialized-slice ()
 	   (let ((slice (make-instance 'slice)))
-	     (add-bar (make-instance 'melody-bar) slice 0)
+	     (add-bar (make-melody-bar) slice 0)
 	     slice)))
     (let* ((head (make-initialized-slice))
 	   (body (make-initialized-slice))
@@ -692,7 +711,7 @@
 (defmethod make-layer (name (initial-staff lyrics-staff))
   (flet ((make-initialized-slice ()
 	   (let ((slice (make-instance 'slice)))
-	     (add-bar (make-instance 'lyrics-bar) slice 0)
+	     (add-bar (make-lyrics-bar) slice 0)
 	     slice)))
     (let* ((head (make-initialized-slice))
 	   (body (make-initialized-slice))


Index: gsharp/gui.lisp
diff -u gsharp/gui.lisp:1.37 gsharp/gui.lisp:1.38
--- gsharp/gui.lisp:1.37	Wed Nov  2 06:01:10 2005
+++ gsharp/gui.lisp	Wed Nov  2 20:28:09 2005
@@ -1118,12 +1118,11 @@
 (defun insert-lyrics-element ()
   (let* ((state (input-state *application-frame*))
 	 (cursor (cursor *application-frame*))
-	 (element (make-instance 'lyrics-element
+	 (element (make-lyrics-element (car (staves (layer (cursor *application-frame*))))
 		    :rbeams (if (eq (notehead state) :filled) (rbeams state) 0)
 		    :lbeams (if (eq (notehead state) :filled) (lbeams state) 0)
 		    :dots (dots state)
-		    :notehead (notehead state)
-		    :staff (car (staves (layer (cursor *application-frame*)))))))
+		    :notehead (notehead state))))
     (insert-element element cursor)
     (forward-element cursor)
     element))


Index: gsharp/packages.lisp
diff -u gsharp/packages.lisp:1.23 gsharp/packages.lisp:1.24
--- gsharp/packages.lisp:1.23	Wed Nov  2 06:01:10 2005
+++ gsharp/packages.lisp	Wed Nov  2 20:28:09 2005
@@ -51,7 +51,8 @@
 	   #:slice #:elements
 	   #:nb-elements #:elementno #:add-element
 	   #:remove-element #:bar #:make-bar
-	   #:melody-bar #:lyrics-bar
+	   #:melody-bar #:make-melody-bar
+	   #:lyrics-bar #:make-lyrics-bar
 	   #:layer #:lyrics-layer #:melody-layer
 	   #:bars #:nb-bars #:barno #:add-bar #:remove-bar
 	   #:slice




More information about the Gsharp-cvs mailing list