From: Han-Wen Nienhuys Date: Tue, 29 Mar 2005 14:15:39 +0000 (+0000) Subject: *** empty log message *** X-Git-Tag: release/2.5.17~1 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=4e4a3b4106cb4982f0c06ca26bad2f2641c0382e;p=lilypond.git *** empty log message *** --- diff --git a/ChangeLog b/ChangeLog index 455523bac9..942de40c3c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -7,6 +7,13 @@ 2005-03-29 Han-Wen Nienhuys + * 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 index 1bbf1e879b..0000000000 --- a/input/regression/molecule-hacking.ly +++ /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. - -} - - - diff --git a/lily/music-wrapper-iterator.cc b/lily/music-wrapper-iterator.cc index 560d8aba3f..e20a6261f5 100644 --- a/lily/music-wrapper-iterator.cc +++ b/lily/music-wrapper-iterator.cc @@ -7,7 +7,6 @@ */ #include "music-wrapper-iterator.hh" - #include "music-wrapper.hh" Music_wrapper_iterator::Music_wrapper_iterator () diff --git a/lily/stencil-scheme.cc b/lily/stencil-scheme.cc index 842200c6a0..cfec55292a 100644 --- a/lily/stencil-scheme.cc +++ b/lily/stencil-scheme.cc @@ -16,26 +16,6 @@ /* 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", diff --git a/ly/init.ly b/ly/init.ly index 789a7337ef..8fa1a1ad0c 100644 --- a/ly/init.ly +++ b/ly/init.ly @@ -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 diff --git a/scm/define-markup-commands.scm b/scm/define-markup-commands.scm index bd8d08c587..3039e18a97 100644 --- a/scm/define-markup-commands.scm +++ b/scm/define-markup-commands.scm @@ -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)) diff --git a/scm/fret-diagrams.scm b/scm/fret-diagrams.scm index fad5f4739e..9ce20549a8 100644 --- a/scm/fret-diagrams.scm +++ b/scm/fret-diagrams.scm @@ -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?) diff --git a/scm/output-lib.scm b/scm/output-lib.scm index 91f3ed3494..e4731f4647 100644 --- a/scm/output-lib.scm +++ b/scm/output-lib.scm @@ -64,12 +64,13 @@ (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)) @@ -126,9 +127,10 @@ (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) )) diff --git a/scm/safe-lily.scm b/scm/safe-lily.scm index 7b361756d1..e790c3b86a 100644 --- a/scm/safe-lily.scm +++ b/scm/safe-lily.scm @@ -126,12 +126,11 @@ 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? diff --git a/scm/stencil.scm b/scm/stencil.scm index 8880f6d02d..aca5ce8852 100644 --- a/scm/stencil.scm +++ b/scm/stencil.scm @@ -22,6 +22,13 @@ (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) diff --git a/scripts/convert-ly.py b/scripts/convert-ly.py index 6efc9b67a8..de413b6325 100644 --- a/scripts/convert-ly.py +++ b/scripts/convert-ly.py @@ -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 ################################