]> git.donarmstrong.com Git - lilypond.git/commitdiff
*** empty log message ***
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Tue, 29 Mar 2005 14:15:39 +0000 (14:15 +0000)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Tue, 29 Mar 2005 14:15:39 +0000 (14:15 +0000)
ChangeLog
input/regression/molecule-hacking.ly [deleted file]
lily/music-wrapper-iterator.cc
lily/stencil-scheme.cc
ly/init.ly
scm/define-markup-commands.scm
scm/fret-diagrams.scm
scm/output-lib.scm
scm/safe-lily.scm
scm/stencil.scm
scripts/convert-ly.py

index 455523bac9162e4dd6adbb4f105ab37e022e5e38..942de40c3c7dda75018154c2b6ab93087f894ec1 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -7,6 +7,13 @@
 
 2005-03-29  Han-Wen Nienhuys  <hanwen@xs4all.nl>
 
+       * lily/stencil-scheme.cc (LY_DEFINE): change to
+       ly:stencil-aligned-to, non mutating.
+
+       * scm/safe-lily.scm (lambda): remove ly:stencil-set-extent!
+
+       * lily/stencil-scheme.cc: remove ly:stencil-set-extent!
+
        * lily/quote-iterator.cc (derived_mark): call
        Music_wrapper_iterator::derived_mark() too.
 
diff --git a/input/regression/molecule-hacking.ly b/input/regression/molecule-hacking.ly
deleted file mode 100644 (file)
index 1bbf1e8..0000000
+++ /dev/null
@@ -1,71 +0,0 @@
-
-\version "2.5.2"
-
-\header { texidoc=" You can write stencil callbacks in Scheme, thus
-providing custom glyphs for notation elements.  A simple example is
-adding parentheses to existing stencil callbacks.
-
-The parenthesized beam is less successful due to implementation of the
-Beam. The note head is also rather naive, since the extent of the
-parens are also not seen by accidentals.
-"
-       
-}
-
-#(define (parenthesize-callback callback)
-   "Construct a function that will do CALLBACK and add parentheses.
-Example usage:
-
-  \\property NoteHead \\override #'print-function
-                  =
-                     #(parenthesize-callback Note_head::print)
-                   
-"
-
-   
-   (define (parenthesize-stencil grob)
-     "This function adds parentheses to the original callback for
-GROB.  The dimensions of the stencil is not affected.
-"
-     
-     (let* ((fn (ly:get-default-font grob))
-           (pclose (ly:font-get-glyph fn "accidentals.rightparen"))
-           (popen (ly:font-get-glyph fn "accidentals.leftparen"))
-           (subject (callback grob))
-
-           ; remember old size
-           (subject-dim-x (ly:stencil-extent subject 0))
-           (subject-dim-y (ly:stencil-extent subject 1)))
-
-        ; add parens
-        (set! subject
-            (ly:stencil-combine-at-edge 
-             (ly:stencil-combine-at-edge subject 0 1 pclose 0.2)
-             0 -1 popen  0.2))
-
-       ; revert old size.
-       (ly:stencil-set-extent! subject 0 subject-dim-x)
-       (ly:stencil-set-extent! subject 1 subject-dim-y)
-       subject))
-   parenthesize-stencil)
-    
-
-\layout { raggedright = ##t }
-\relative c' {
-    c4 e
-
-    \override NoteHead  #'print-function
-    =
-    #(parenthesize-callback Note_head::print)
-    g bes
-    \revert NoteHead #'print-function
-    \override Beam  #'print-function
-    =
-    #(parenthesize-callback Beam::print)
-
-    a8 gis8 a2.
-    
-}
-
-
-
index 560d8aba3fe9cd7d04270d71b4977e9ba51adafa..e20a6261f5692e60d18fdc6624834c089a4a8277 100644 (file)
@@ -7,7 +7,6 @@
 */
 
 #include "music-wrapper-iterator.hh"
-
 #include "music-wrapper.hh"
 
 Music_wrapper_iterator::Music_wrapper_iterator ()
index 842200c6a07d2c206779f346997f117db346b405..cfec55292ad2453535673a8f4dd9c1af046c33c4 100644 (file)
 /*
   TODO: naming add/combine.
 */
-/*
-  UGH. Junk all mutators.
-*/
-LY_DEFINE (ly_stencil_set_extent_x, "ly:stencil-set-extent!",
-          3, 0, 0, (SCM stil, SCM axis, SCM np),
-          "Set the extent of @var{stil} "
-          "(@var{extent} must be a pair of numbers) "
-          "in @var{axis} direction (0 or 1 for x- and y-axis respectively).")
-{
-  Stencil *s = unsmob_stencil (stil);
-  SCM_ASSERT_TYPE (s, stil, SCM_ARG1, __FUNCTION__, "stencil");
-  SCM_ASSERT_TYPE (is_axis (axis), axis, SCM_ARG2, __FUNCTION__, "axis");
-  SCM_ASSERT_TYPE (is_number_pair (np), np, SCM_ARG3, __FUNCTION__,
-                  "number pair");
-
-  Interval iv = ly_scm2interval (np);
-  s->dim_[Axis (scm_to_int (axis))] = iv;
-
-  return SCM_UNSPECIFIED;
-}
 
 LY_DEFINE (ly_translate_stencil_axis, "ly:stencil-translate-axis",
           3, 0, 0, (SCM stil, SCM amount, SCM axis),
@@ -244,19 +224,21 @@ LY_DEFINE (ly_make_stencil, "ly:make-stencil",
   return s.smobbed_copy ();
 }
 
-LY_DEFINE (ly_stencil_align_to_x, "ly:stencil-align-to!",
+LY_DEFINE (ly_stencil_aligned_to, "ly:stencil-aligned-to",
           3, 0, 0, (SCM stil, SCM axis, SCM dir),
           "Align @var{stil} using its own extents. "
           "@var{dir} is a number -1, 1 are left and right respectively. "
-          "Other values are interpolated (so 0 means the center")
+          "Other values are interpolated (so 0 means the center).")
 {
   SCM_ASSERT_TYPE (unsmob_stencil (stil), stil, SCM_ARG1, __FUNCTION__, "stencil");
   SCM_ASSERT_TYPE (is_axis (axis), axis, SCM_ARG2, __FUNCTION__, "axis");
   SCM_ASSERT_TYPE (scm_is_number (dir), dir, SCM_ARG3, __FUNCTION__, "number");
 
-  unsmob_stencil (stil)->align_to ((Axis)scm_to_int (axis),
-                                  scm_to_double (dir));
-  return stil;
+  Stencil target = *unsmob_stencil (stil);
+
+  target.align_to ((Axis)scm_to_int (axis),
+                  scm_to_double (dir));
+  return target.smobbed_copy ();
 }
 
 LY_DEFINE (ly_stencil_fonts, "ly:stencil-fonts",
index 789a7337ef777cd42c38570b8cbc2852fd40893e..8fa1a1ad0cae63b73b5dcba9a3dca6c586e6c9af 100644 (file)
@@ -1,5 +1,9 @@
 %% Toplevel initialisation file. 
 
+% switch on debugging.
+#(if (and #t (defined? 'set-debug-cell-accesses!))
+  (set-debug-cell-accesses! 5000))
+
 #(define-public midi-debug  #f)
 
 
@@ -13,8 +17,6 @@
 #(define $globalheader #f)
 #(define version-seen? #f)
 
-#(if (defined? 'set-debug-cell-accesses!) (set-debug-cell-accesses 5000))
-
 \maininput
 %% there is a problem at the end of the input file
 
index bd8d08c5875d78130892252e99032ebc83546fab..3039e18a97b869d767682aea36ffec61a43d394e 100644 (file)
@@ -47,11 +47,10 @@ the PDF backend."
        (begin
          (ly:warn "No systems found in \\score markup. Did you forget \\layout?")
          empty-markup)
-       (begin
-         (let* ((stencil (ly:paper-system-stencil (vector-ref systems 0)))) 
-
-           (ly:stencil-align-to! stencil Y CENTER)
-           stencil)))))
+       (let* ((stencil (ly:paper-system-stencil (vector-ref systems 0)))) 
+         
+         (ly:stencil-aligned-to stencil Y CENTER)
+         ))))
 
 (def-markup-command (simple layout props str) (string?)
   "A simple text string; @code{\\markup @{ foo @}} is equivalent with
@@ -393,46 +392,41 @@ of the @code{#'direction} layout property."
 (def-markup-command (center-align layout props args) (markup-list?)
   "Put @code{args} in a centered column. "
   (let* ((mols (map (lambda (x) (interpret-markup layout props x)) args))
-         (cmols (map (lambda (x) (ly:stencil-align-to! x X CENTER)) mols)))
+         (cmols (map (lambda (x) (ly:stencil-aligned-to x X CENTER)) mols)))
     (stack-lines -1 0.0 (chain-assoc-get 'baseline-skip props) cmols)))
 
 (def-markup-command (vcenter layout props arg) (markup?)
   "Align @code{arg} to its Y center. "
   (let* ((mol (interpret-markup layout props arg)))
-    (ly:stencil-align-to! mol Y CENTER)
-    mol))
+    (ly:stencil-aligned-to mol Y CENTER)
+    ))
 
 (def-markup-command (hcenter layout props arg) (markup?)
   "Align @code{arg} to its X center. "
   (let* ((mol (interpret-markup layout props arg)))
-    (ly:stencil-align-to! mol X CENTER)
-    mol))
+    (ly:stencil-aligned-to mol X CENTER)))
 
 (def-markup-command (right-align layout props arg) (markup?)
   "Align @var{arg} on its right edge. "
   (let* ((m (interpret-markup layout props arg)))
-    (ly:stencil-align-to! m X RIGHT)
-    m))
+    (ly:stencil-aligned-to m X RIGHT)))
 
 (def-markup-command (left-align layout props arg) (markup?)
   "Align @var{arg} on its left edge. "
   (let* ((m (interpret-markup layout props arg)))
-    (ly:stencil-align-to! m X LEFT)
-    m))
+    (ly:stencil-aligned-to m X LEFT)))
 
 (def-markup-command (general-align layout props axis dir arg)  (integer? number? markup?)
   "Align @var{arg} in @var{axis} direction to the @var{dir} side."
   (let* ((m (interpret-markup layout props arg)))
-    (ly:stencil-align-to! m axis dir)
-    m))
+    (ly:stencil-aligned-to m axis dir)))
 
 (def-markup-command (halign layout props dir arg) (number? markup?)
   "Set horizontal alignment. If @var{dir} is @code{-1}, then it is
 left-aligned, while @code{+1} is right. Values in between interpolate
 alignment accordingly."
   (let* ((m (interpret-markup layout props arg)))
-    (ly:stencil-align-to! m X dir)
-    m))
+    (ly:stencil-aligned-to m X dir)))
 
 (def-markup-command (musicglyph layout props glyph-name) (string?)
   "This is converted to a musical symbol, e.g. @code{\\musicglyph
@@ -477,15 +471,17 @@ and/or @code{extra-offset} properties. "
   "Make a fraction of two markups."
   (let* ((m1 (interpret-markup layout props arg1))
          (m2 (interpret-markup layout props arg2)))
-    (ly:stencil-align-to! m1 X CENTER)
-    (ly:stencil-align-to! m2 X CENTER)    
+    (set! m1 (ly:stencil-aligned-to m1 X CENTER))
+    (set! m2 (ly:stencil-aligned-to m2 X CENTER))
     (let* ((x1 (ly:stencil-extent m1 X))
            (x2 (ly:stencil-extent m2 X))
            (line (ly:round-filled-box (interval-union x1 x2) '(-0.05 . 0.05) 0.0))
            ;; should stack mols separately, to maintain LINE on baseline
            (stack (stack-lines -1 0.2 0.6 (list m1 line m2))))
-      (ly:stencil-align-to! stack Y CENTER)
-      (ly:stencil-align-to! stack X LEFT)
+      (set! stack
+           (ly:stencil-aligned-to stack Y CENTER))
+      (set! stack
+           (ly:stencil-aligned-to stack X LEFT))
       ;; should have EX dimension
       ;; empirical anyway
       (ly:stencil-translate-axis stack 0.75 Y))))
@@ -737,8 +733,9 @@ thickness and padding around the markup."
 (def-markup-command (strut layout props) ()
   "Create a box of the same height as the space in the current font."
   (let ((m (Text_interface::interpret_markup layout props " ")))
-    (ly:stencil-set-extent! m X '(1000 . -1000))
-    m))
+    (ly:make-stencil (ly:stencil-expr m)
+                    (ly:stencil-extent m X)
+                    '(1000 . -1000))))
 
 (define number->mark-letter-vector (make-vector 25 #\A))
 
index fad5f4739eb9f8513694359b2053dc646ee63b52..9ce20549a806fa854af0a2f89f37727b60869e4c 100644 (file)
@@ -134,16 +134,6 @@ with magnification @varr{mag} of the string @var{text}."
                  (- size th) 0))) 
                  
 
-(define (centered-stencil stencil)
- "Center stencil @var{stencil} in both the X and Y directions"
- (let* ((output-stencil stencil))
-;     (if (= (cadr (ly:version)) 3)
-        (begin
-          (ly:stencil-align-to! output-stencil Y 0)
-          (ly:stencil-align-to! output-stencil X 0)
-          output-stencil)))
-;       (ly:stencil-align-to (ly:stencil-align-to text-stencil X 0) Y 0))))
-
 (define (draw-dots layout props string-count fret-range size finger-code dot-position dot-radius dot-list)
   "Make dots for fret diagram."
   (let* ((scale-dot-radius (* size dot-radius))
@@ -383,8 +373,8 @@ part of the place-fret element is present, @var{finger-value} will be displayed
              (set! fret-diagram-stencil
                    (ly:stencil-combine-at-edge fret-diagram-stencil X label-dir
                                               (label-fret layout props string-count fret-range size) label-space 0)))
-         (ly:stencil-align-to! fret-diagram-stencil X alignment)
-         fret-diagram-stencil))
+         (ly:stencil-aligned-to fret-diagram-stencil X alignment)
+        ))
          
 (def-markup-command (fret-diagram layout props definition-string)
   (string?)
index 91f3ed3494a39c26d2ea8eba86068b071b8b9472..e4731f46473da14593998d09079f46fd28581e31 100644 (file)
       (let ((x (/ (- (cdr (ly:stencil-extent slur 0)) 
                      (/ (cdr (ly:stencil-extent text 0)) 2.0))
                   -2.0)))
-       
-        (ly:stencil-set-extent! text 0 (cons x x))
-        (ly:stencil-align-to! text 0 1)))))
-
-;; (ly:stencil-combine-at-edge slur 1 1 text -0.6)
 
+       (set! text
+             (ly:make-stencil (ly:stencil-expr text)
+                              (cons x x)
+                              (ly:stencil-extent text Y)))
+       
+        (ly:stencil-aligned-to text X RIGHT)))))
 
 
 (define-public guitar-tuning '(4 -1 -5 -10 -15 -20))
        (text-stencil
        (Text_interface::interpret_markup layout props text)))
 
-    (ly:stencil-align-to! text-stencil X CENTER)
-    (ly:stencil-align-to! text-stencil Y CENTER)
-    (ly:stencil-add text-stencil circle)
+    
+    (ly:stencil-add
+     (centered-stencil text-stencil)
+     circle)
   ))
 
 
index 7b361756d1ce61e0d605e8ff49e4ded2129a3234..e790c3b86affc7aaf4562b630913b57b8905a662 100644 (file)
    ly:spanner-get-bound
    ly:spanner?
    ly:stencil-add
-   ly:stencil-align-to!
+   ly:stencil-aligned-to
    ly:stencil-combine-at-edge
    ly:stencil-expr
    ly:stencil-extent
    ly:stencil-moved-to-edge
-   ly:stencil-set-extent!
    ly:stencil-translate
    ly:stencil-translate-axis
    ly:stencil?
index 8880f6d02d9c1664b6b31379c5b125e4b1e4c659..aca5ce885265d325bfdc6d74086a5bf94fbd1a0c 100644 (file)
          (car stils) axis dir (stack-stencils-padding-list axis dir (cdr padding) (cdr stils))
          (car padding)))))
 
+(define-public (centered-stencil stencil)
+  "Center stencil @var{stencil} in both the X and Y directions"
+
+  (ly:stencil-aligned-to
+   (ly:stencil-aligned-to stencil X CENTER)
+   Y CENTER))
+
 (define-public (stack-lines dir padding baseline stils)
   "Stack vertically with a baseline-skip."
   (if (null? stils)
index 6efc9b67a84460b9ec08f8be2994051cd6a3ca73..de413b63254d185934114a774c12f6844d001278 100644 (file)
@@ -2443,6 +2443,20 @@ conversions.append (((2, 5, 13),
                     '\\encoding: smart recode latin1..utf-8. Remove ly:point-and-click'))
 
 
+def conv (str):
+       if re.search ("ly:stencil-set-extent!", str):
+               sys.stderr.write ('\n')
+               sys.stderr.write (NOT_SMART % "ly:stencil-set-extent!")
+               sys.stderr.write ('\n')
+               sys.stderr.write ('use (set! VAR (ly:make-stencil (ly:stencil-expr VAR) X-EXT Y-EXT))\n')
+               raise FatalConversionError ()
+       return str
+
+conversions.append (((2, 5, 17),
+                    conv,
+                    'ly:stencil-set-extent! removed'))
+                   
+
 ################################
 #      END OF CONVERSIONS
 ################################