CVSROOT:        /cvsroot/lilypond
Module name:    lilypond
Branch:         
Changes by:     Han-Wen Nienhuys <[EMAIL PROTECTED]>    05/10/02 01:16:08

Modified files:
        .              : ChangeLog 
        Documentation/user: global.itely 
        input/mutopia/J.S.Bach: baerenreiter-sarabande.ly 
        input/regression: page-spacing.ly 
        lily           : line-interface.cc paper-system-scheme.cc 
        scm            : define-markup-commands.scm framework-eps.scm 
                         framework-ps.scm framework-socket.scm 
                         framework-tex.scm framework-texstr.scm 
                         lily-library.scm music-functions.scm 
                         page-layout.scm safe-lily.scm stencil.scm 

Log message:
        * scm/lily-library.scm (interval-translate): new function
        (interval-center): new function.
        
        * scm/page-layout.scm (paper-system-annotate): new function. Add
        arrows for dimensions.
        
        * scm/stencil.scm (dimension-arrows): new function.
        
        * Documentation/user/global.itely (Vertical spacing): mention 
annotatespacing
        
        * input/regression/page-spacing.ly: add annotatespacing
        
        * lily/paper-system-scheme.cc (LY_DEFINE): remove 
ly:paper-system-{extent,stencil}
        (LY_DEFINE): new function ly:paper-system-set-property!
        
        * Documentation/user/global.itely (Paper size): explain how to add
        sizes.

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/lilypond/lilypond/ChangeLog.diff?tr1=1.4148&tr2=1.4149&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/lilypond/lilypond/Documentation/user/global.itely.diff?tr1=1.36&tr2=1.37&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/lilypond/lilypond/input/mutopia/J.S.Bach/baerenreiter-sarabande.ly.diff?tr1=1.58&tr2=1.59&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/lilypond/lilypond/input/regression/page-spacing.ly.diff?tr1=1.2&tr2=1.3&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/lilypond/lilypond/lily/line-interface.cc.diff?tr1=1.26&tr2=1.27&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/lilypond/lilypond/lily/paper-system-scheme.cc.diff?tr1=1.9&tr2=1.10&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/lilypond/lilypond/scm/define-markup-commands.scm.diff?tr1=1.115&tr2=1.116&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/lilypond/lilypond/scm/framework-eps.scm.diff?tr1=1.14&tr2=1.15&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/lilypond/lilypond/scm/framework-ps.scm.diff?tr1=1.135&tr2=1.136&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/lilypond/lilypond/scm/framework-socket.scm.diff?tr1=1.2&tr2=1.3&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/lilypond/lilypond/scm/framework-tex.scm.diff?tr1=1.87&tr2=1.88&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/lilypond/lilypond/scm/framework-texstr.scm.diff?tr1=1.10&tr2=1.11&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/lilypond/lilypond/scm/lily-library.scm.diff?tr1=1.50&tr2=1.51&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/lilypond/lilypond/scm/music-functions.scm.diff?tr1=1.150&tr2=1.151&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/lilypond/lilypond/scm/page-layout.scm.diff?tr1=1.84&tr2=1.85&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/lilypond/lilypond/scm/safe-lily.scm.diff?tr1=1.38&tr2=1.39&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/lilypond/lilypond/scm/stencil.scm.diff?tr1=1.21&tr2=1.22&r1=text&r2=text

Patches:
Index: lilypond/ChangeLog
diff -u lilypond/ChangeLog:1.4148 lilypond/ChangeLog:1.4149
--- lilypond/ChangeLog:1.4148   Sat Oct  1 23:31:34 2005
+++ lilypond/ChangeLog  Sun Oct  2 01:16:07 2005
@@ -1,6 +1,19 @@
 2005-10-02  Han-Wen Nienhuys  <[EMAIL PROTECTED]>
 
+       * scm/lily-library.scm (interval-translate): new function
+       (interval-center): new function. 
+
+       * scm/page-layout.scm (paper-system-annotate): new function. Add
+       arrows for dimensions.
+ 
+       * scm/stencil.scm (dimension-arrows): new function.
+
+       * Documentation/user/global.itely (Vertical spacing): mention 
annotatespacing
+
+       * input/regression/page-spacing.ly: add annotatespacing
+
        * lily/paper-system-scheme.cc (LY_DEFINE): remove 
ly:paper-system-{extent,stencil}
+       (LY_DEFINE): new function ly:paper-system-set-property!
 
        * Documentation/user/global.itely (Paper size): explain how to add
        sizes.
Index: lilypond/Documentation/user/global.itely
diff -u lilypond/Documentation/user/global.itely:1.36 
lilypond/Documentation/user/global.itely:1.37
--- lilypond/Documentation/user/global.itely:1.36       Sat Oct  1 23:06:53 2005
+++ lilypond/Documentation/user/global.itely    Sun Oct  2 01:16:08 2005
@@ -340,6 +340,7 @@
 Increasing this will put systems whose bounding boxes almost touch
 farther apart.
 
+
 @cindex @code{horizontalshift}
 @item horizontalshift
 All systems (including titles and system separators) are shifted by
@@ -528,6 +529,16 @@
 The vertical spacing on a page can also be changed for each system 
individually.
 Some examples are found in the example file
 @inputfileref{input/regression/,page-spacing.ly}.
+
+When setting @code{annotatespacing} in the @code{\paper} block LilyPond
+will graphically indicate the dimensions of properties that may be set
+for page spacing,
+
[EMAIL PROTECTED]
+\paper { annotatespacing = ##t }
+{ c4 }
[EMAIL PROTECTED] lilypond
+
 
 
 @seealso
Index: lilypond/input/mutopia/J.S.Bach/baerenreiter-sarabande.ly
diff -u lilypond/input/mutopia/J.S.Bach/baerenreiter-sarabande.ly:1.58 
lilypond/input/mutopia/J.S.Bach/baerenreiter-sarabande.ly:1.59
--- lilypond/input/mutopia/J.S.Bach/baerenreiter-sarabande.ly:1.58      Wed Jul 
20 10:13:46 2005
+++ lilypond/input/mutopia/J.S.Bach/baerenreiter-sarabande.ly   Sun Oct  2 
01:16:08 2005
@@ -174,6 +174,8 @@
   linewidth =183.5 \mm
   betweensystemspace = 25\mm 
   betweensystempadding = 0\mm
+
+%%  annotatespacing = ##t
 }
 
 \book {
Index: lilypond/input/regression/page-spacing.ly
diff -u lilypond/input/regression/page-spacing.ly:1.2 
lilypond/input/regression/page-spacing.ly:1.3
--- lilypond/input/regression/page-spacing.ly:1.2       Tue Sep 27 11:33:27 2005
+++ lilypond/input/regression/page-spacing.ly   Sun Oct  2 01:16:08 2005
@@ -8,6 +8,7 @@
 setting properties on individual object. @code{\override} may still be
 used for global overrides.
 
+By setting @code{annotatespacing}, we can see the effect of each property.
 "
 
 }
@@ -66,6 +67,7 @@
   }
   \paper {
     raggedlastbottom = ##f
+    annotatespacing = ##t
     betweensystemspace = 1.0
     #(set! text-font-defaults
       (acons
Index: lilypond/lily/line-interface.cc
diff -u lilypond/lily/line-interface.cc:1.26 
lilypond/lily/line-interface.cc:1.27
--- lilypond/lily/line-interface.cc:1.26        Fri Aug 12 00:04:45 2005
+++ lilypond/lily/line-interface.cc     Sun Oct  2 01:16:08 2005
@@ -146,4 +146,10 @@
               "produced. If @code{dash-fraction} is negative, the line is made 
"
               "transparent.",
 
-              "dash-period dash-fraction thickness style arrow-length 
arrow-width")
+              /* properties */
+              "dash-period "
+              "dash-fraction "
+              "thickness "
+              "style "
+              "arrow-length "
+              "arrow-width")
Index: lilypond/lily/paper-system-scheme.cc
diff -u lilypond/lily/paper-system-scheme.cc:1.9 
lilypond/lily/paper-system-scheme.cc:1.10
--- lilypond/lily/paper-system-scheme.cc:1.9    Sat Oct  1 23:31:34 2005
+++ lilypond/lily/paper-system-scheme.cc        Sun Oct  2 01:16:08 2005
@@ -8,7 +8,16 @@
 
 #include "paper-system.hh"
 
+LY_DEFINE (ly_paper_system_set_property_x, "ly:paper-system-set-property!",
+          2, 1, 0, (SCM system, SCM sym, SCM value),
+          "Set property @var{sym} of @var{system} to @var{value}")
+{
+  Paper_system *ps = unsmob_paper_system (system);
+  SCM_ASSERT_TYPE (ps, system, SCM_ARG1, __FUNCTION__, "paper-system");
 
+  ps->internal_set_property (sym, value);
+  return SCM_UNSPECIFIED;
+}
 
 LY_DEFINE (ly_paper_system_property, "ly:paper-system-property",
           2, 1, 0, (SCM system, SCM sym, SCM dfault),
Index: lilypond/scm/define-markup-commands.scm
diff -u lilypond/scm/define-markup-commands.scm:1.115 
lilypond/scm/define-markup-commands.scm:1.116
--- lilypond/scm/define-markup-commands.scm:1.115       Sun Sep  4 11:36:40 2005
+++ lilypond/scm/define-markup-commands.scm     Sun Oct  2 01:16:08 2005
@@ -267,7 +267,7 @@
   (let* ((output (ly:score-embedded-format score layout)))
 
     (if (ly:music-output? output)
-       (ly:paper-system-stencil
+       (paper-system-stencil
         (vector-ref (ly:paper-score-paper-systems output) 0))
        (begin
          (ly:warning (_"no systems found in \\score markup, does it have a 
\\layout block?"))
@@ -1224,3 +1224,9 @@
 
     (apply ly:stencil-add
           (append stacked brackets))))
+
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; size indications arrow
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
Index: lilypond/scm/framework-eps.scm
diff -u lilypond/scm/framework-eps.scm:1.14 lilypond/scm/framework-eps.scm:1.15
--- lilypond/scm/framework-eps.scm:1.14 Mon Sep  5 13:52:40 2005
+++ lilypond/scm/framework-eps.scm      Sun Oct  2 01:16:08 2005
@@ -98,7 +98,7 @@
   (output-scopes scopes fields basename)
   
   (dump-stencils-as-EPSes
-   (map ly:paper-system-stencil (ly:paper-book-systems book))
+   (map paper-system-stencil (ly:paper-book-systems book))
    book
    basename))
 
Index: lilypond/scm/framework-ps.scm
diff -u lilypond/scm/framework-ps.scm:1.135 lilypond/scm/framework-ps.scm:1.136
--- lilypond/scm/framework-ps.scm:1.135 Tue Sep 27 10:50:17 2005
+++ lilypond/scm/framework-ps.scm       Sun Oct  2 01:16:08 2005
@@ -514,7 +514,7 @@
     (dump-stencil-as-EPS
      paper
      (stack-stencils Y DOWN 0.0
-                    (map ly:paper-system-stencil (reverse to-dump-systems)))
+                    (map paper-system-stencil (reverse to-dump-systems)))
      (format "~a.preview" basename)
      #t)
 
@@ -532,7 +532,7 @@
                                (not (paper-system-title? x))) systems))
             (dump-me
              (stack-stencils Y DOWN 0.0
-                             (map ly:paper-system-stencil
+                             (map paper-system-stencil
                                   (append titles (list non-title))))))
        (output-scopes scopes fields basename)
        (dump-stencil-as-EPS paper dump-me
Index: lilypond/scm/framework-socket.scm
diff -u lilypond/scm/framework-socket.scm:1.2 
lilypond/scm/framework-socket.scm:1.3
--- lilypond/scm/framework-socket.scm:1.2       Tue Jul 12 20:46:24 2005
+++ lilypond/scm/framework-socket.scm   Sun Oct  2 01:16:08 2005
@@ -23,7 +23,7 @@
 
     (if (pair? systems)
        (ly:outputter-dump-stencil outputter
-                                  (ly:paper-system-stencil (car systems))))
+                                  (paper-system-stencil (car systems))))
     ))
 
 (define-public output-classic-framework output-framework)
Index: lilypond/scm/framework-tex.scm
diff -u lilypond/scm/framework-tex.scm:1.87 lilypond/scm/framework-tex.scm:1.88
--- lilypond/scm/framework-tex.scm:1.87 Sat Oct  1 23:31:34 2005
+++ lilypond/scm/framework-tex.scm      Sun Oct  2 01:16:08 2005
@@ -222,7 +222,7 @@
           (ly:number->string
            (interval-length (paper-system-extent line Y)))))
 
-  (ly:outputter-dump-stencil putter (ly:paper-system-stencil line))
+  (ly:outputter-dump-stencil putter (paper-system-stencil line))
   (ly:outputter-dump-string
    putter
    (if last?
Index: lilypond/scm/framework-texstr.scm
diff -u lilypond/scm/framework-texstr.scm:1.10 
lilypond/scm/framework-texstr.scm:1.11
--- lilypond/scm/framework-texstr.scm:1.10      Mon Jul 11 11:51:43 2005
+++ lilypond/scm/framework-texstr.scm   Sun Oct  2 01:16:08 2005
@@ -40,7 +40,7 @@
     (ly:outputter-dump-string outputter (header basename))
     (for-each
      (lambda (system)
-       (ly:outputter-dump-stencil outputter (ly:paper-system-stencil system)))
+       (ly:outputter-dump-stencil outputter (paper-system-stencil system)))
      lines)
     (ly:outputter-dump-string outputter (footer))))
 
Index: lilypond/scm/lily-library.scm
diff -u lilypond/scm/lily-library.scm:1.50 lilypond/scm/lily-library.scm:1.51
--- lilypond/scm/lily-library.scm:1.50  Sat Oct  1 23:31:34 2005
+++ lilypond/scm/lily-library.scm       Sun Oct  2 01:16:08 2005
@@ -120,8 +120,11 @@
   (equal? #t (ly:paper-system-property system 'is-title)
          ))
 
+(define-public (paper-system-stencil system)
+  (ly:paper-system-property system 'stencil))
+
 (define-public (paper-system-extent system axis)
-  (ly:stencil-extent (ly:paper-system-property system 'stencil) axis))
+  (ly:stencil-extent (paper-system-stencil system) axis))
 
 ;;;;;;;;;;;;;;;;
 ;; alist
@@ -322,6 +325,16 @@
 
 (define-public interval-start car)
 (define-public interval-end cdr)
+
+(define-public (interval-center x)
+  "Center the number-pair X, when an interval"
+  (/ (+ (car x) (cdr x)) 2))
+
+(define-public interval-start car)
+(define-public interval-end cdr)
+(define-public (interval-translate iv amount)
+  (cons (+ amount (car iv))
+       (+ amount (cdr iv))))
 
 (define (other-axis a)
   (remainder (+ a 1) 2))
Index: lilypond/scm/music-functions.scm
diff -u lilypond/scm/music-functions.scm:1.150 
lilypond/scm/music-functions.scm:1.151
--- lilypond/scm/music-functions.scm:1.150      Thu Jul 21 14:45:55 2005
+++ lilypond/scm/music-functions.scm    Sun Oct  2 01:16:08 2005
@@ -16,9 +16,15 @@
   (make-procedure-with-setter ly:music-property
                              ly:music-set-property!))
 
+
+;; TODO move this
 (define-public ly:grob-property
   (make-procedure-with-setter ly:grob-property
                              ly:grob-set-property!))
+
+(define-public ly:paper-system-property
+  (make-procedure-with-setter ly:paper-system-property
+                             ly:paper-system-set-property!))
 
 (define-public (music-map function music)
   "Apply @var{function} to @var{music} and all of the music it contains.
Index: lilypond/scm/page-layout.scm
diff -u lilypond/scm/page-layout.scm:1.84 lilypond/scm/page-layout.scm:1.85
--- lilypond/scm/page-layout.scm:1.84   Sat Oct  1 23:31:34 2005
+++ lilypond/scm/page-layout.scm        Sun Oct  2 01:16:08 2005
@@ -37,6 +37,99 @@
   (ly:paper-system-property ps 'refpoint-Y-extent '(0 . 0)))
 
 
+
+(define (paper-system-annotate system layout)
+  "Add arrows and texts to indicate which lengths are set."
+  (let*
+      ((annotations (ly:make-stencil '() (cons 0 2) (cons 0 0)))
+       (text-props (cons
+                   '((font-size . -3)
+                     (font-family . typewriter)
+                     )
+                  (layout-extract-page-properties layout)))
+       (append-stencil
+       (lambda (a b)
+         (ly:stencil-combine-at-edge a X RIGHT b 0.5 0)))
+
+       (annotate-property
+       (lambda (name extent is-length?)
+
+         ;; do something sensible for 0,0 intervals. 
+         (set! extent (interval-widen extent 0.001))
+         (let*
+             ((annotation (interpret-markup
+                           layout text-props
+                           (make-column-markup
+                            (list
+                             (make-whiteout-markup (make-simple-markup name))
+                             (make-whiteout-markup
+                              (make-simple-markup
+                               (if is-length?
+                                   (format "~$" (interval-length extent))
+                                   (format "(~$,~$)" (car extent) (cdr 
extent)))))))))
+           
+              
+              (arrows
+               (ly:stencil-translate-axis 
+                (dimension-arrows (cons 0 (interval-length extent)))
+                (interval-start extent) Y))
+              )
+
+           (set! annotation
+                 (ly:stencil-aligned-to annotation Y CENTER))
+           (set! annotation
+                 (ly:stencil-translate annotation (cons 0 (interval-center 
extent))))
+
+
+           (set! annotations
+                 (append-stencil annotations
+                                 (append-stencil arrows annotation))))))
+
+
+       (bbox-extent (paper-system-extent system Y))
+       (refp-extent (ly:paper-system-property system 'refpoint-Y-extent))
+       (next-space (ly:paper-system-property system 'next-space
+                                            (ly:output-def-lookup layout 
'betweensystemspace)
+                                            ))
+       (next-padding (ly:paper-system-property system 'next-padding
+                                              (ly:output-def-lookup layout 
'betweensystempadding)
+                                              ))
+                    
+       )
+
+    (if (number-pair? bbox-extent) 
+       (annotate-property "Y-extent"
+                          bbox-extent #f))
+
+    ;; titles don't have a refpoint-Y-extent.
+    (if (number-pair? refp-extent)
+       (begin
+         (annotate-property "refpoint-Y-extent"
+                            refp-extent #f)
+       
+         (annotate-property "next-space"
+                            (interval-translate (cons (- next-space) 0) (car 
refp-extent))
+                      #t)))
+       
+    
+    (annotate-property "next-padding"
+                      (interval-translate (cons (- next-padding) 0) (car 
bbox-extent))
+                      #t)
+    
+
+    (set! (ly:paper-system-property system 'stencil)
+         (ly:stencil-add
+          (ly:paper-system-property system 'stencil)
+          (ly:make-stencil
+           (ly:stencil-expr annotations)
+           (ly:stencil-extent empty-stencil X)
+           (ly:stencil-extent empty-stencil Y)
+           )))
+    
+    ))
+
+
+
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
 (define (page-headfoot layout scopes number sym sepsym dir last?)
@@ -85,6 +178,9 @@
 create offsets.
  "
 
+  (if (eq? #t (ly:output-def-lookup layout 'annotatespacing))
+      (for-each (lambda (sys) (paper-system-annotate sys layout))
+               lines))
   (let* ((topmargin (ly:output-def-lookup layout 'topmargin))
 
        ;; TODO: naming vsize/hsize not analogous to TeX.
@@ -135,7 +231,7 @@
         (add-system
          (lambda (stencil-position)
            (let* ((system (car stencil-position))
-                  (stencil (ly:paper-system-stencil system))
+                  (stencil (paper-system-stencil system))
                   (y (cadr stencil-position))
                   (is-title (paper-system-title?
                              (car stencil-position))))
Index: lilypond/scm/safe-lily.scm
diff -u lilypond/scm/safe-lily.scm:1.38 lilypond/scm/safe-lily.scm:1.39
--- lilypond/scm/safe-lily.scm:1.38     Sat Oct  1 23:31:34 2005
+++ lilypond/scm/safe-lily.scm  Sun Oct  2 01:16:08 2005
@@ -100,7 +100,6 @@
    ly:layout-def?
    ly:paper-get-font
    ly:paper-get-number
-   ly:paper-system-stencil
    ly:paper-system?
    ly:output-def-lookup
    ly:parse-string
Index: lilypond/scm/stencil.scm
diff -u lilypond/scm/stencil.scm:1.21 lilypond/scm/stencil.scm:1.22
--- lilypond/scm/stencil.scm:1.21       Mon Jul 11 20:41:04 2005
+++ lilypond/scm/stencil.scm    Sun Oct  2 01:16:08 2005
@@ -115,3 +115,50 @@
          (c `(white-text ,(* 2 scale) ,text)))
     ;;urg -- extent is not from ps font, but we hope it's close
     (ly:make-stencil c (car b) (cdr b))))
+
+(define-public (dimension-arrows destination) 
+  "Draw twosided arrow from here to @var{destination}"
+  
+  (let*
+      ((e_x 1+0i)
+       (e_y 0+1i)
+       (rotate (lambda (z ang)
+                (* (make-polar 1 ang)
+                   z)))
+       (complex-to-offset (lambda (z)
+                           (list (real-part z) (imag-part z))))
+       
+       (z-dest (+ (* e_x (car destination)) (* e_y (cdr destination))))
+       (triangle-points '(-1+0.25i
+                         0
+                         -1-0.25i))
+       (p1s (map (lambda (z)
+                  (+ z-dest (rotate z (angle z-dest))))
+                triangle-points))
+       (p2s (map (lambda (z)
+                  (rotate z (angle (- z-dest))))
+                  triangle-points))
+       (null (cons 0 0)) 
+       (arrow-1  
+       (ly:make-stencil
+        `(polygon (quote ,(concatenate (map complex-to-offset p1s)))
+                  0.0
+                  #t) null null))
+       (arrow-2
+       (ly:make-stencil
+        `(polygon (quote ,(concatenate (map complex-to-offset p2s)))
+                  0.0
+                  #t) null null ) )
+       (line (ly:make-stencil
+             `(draw-line 0.1 0 0
+                         ,(car destination)
+                         ,(cdr destination))
+             (cons (min 0 (car destination))
+                   (min 0 (cdr destination)))
+             (cons (max 0 (car destination))
+                   (max 0 (cdr destination)))))
+                   
+       (result (ly:stencil-add arrow-2 arrow-1 line)))
+
+
+    result))


_______________________________________________
Lilypond-cvs mailing list
Lilypond-cvs@gnu.org
http://lists.gnu.org/mailman/listinfo/lilypond-cvs

Reply via email to