From: Han-Wen Nienhuys Date: Sun, 16 Oct 2005 13:52:42 +0000 (+0000) Subject: * lily/note-head.cc (calc_stem_attachment): new function. X-Git-Tag: release/2.7.13~14 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=1f4ae685939466899fdf85121a58801c867f9381;p=lilypond.git * lily/note-head.cc (calc_stem_attachment): new function. (internal_print): use callback to get glyph-name. * lily/stem.cc (calc_stem_end_position): new function. (calc_length): new function. document details for stem. remove Stem::get_direction() * lily/bar-line.cc (before_line_breaking): remove function. remove bar-size-procedure, break-glyph-function * lily/grob.cc (get_stencil): simplify: use callback mechanism to calculate stencil. (get_print_stencil): rename from get_stencil: create stencil with transparency, color and cause. * scm/define-grobs.scm: change print-function to stencil callback everywhere. * lily/grob.cc: elucidate doc about after/before-line-breaking * lily/stem.cc (height): idem. * lily/grob.cc: change after/before-line-breaking-callback to after/before-line-breaking dummy properties. * lily/grob.cc (other_axis_parent_positioning): new function. (same_axis_parent_positioning): new function * lily/stem.cc (calc_stem_end_position): use callback. (calc_positioning_done): idem. (calc_direction): idem. (calc_stem_end_position): idem (calc_stem_info): idem. * scm/define-grob-properties.scm (all-user-grob-properties): doc callbacks property. --- diff --git a/input/regression/arpeggio-bracket.ly b/input/regression/arpeggio-bracket.ly index 050bd3b3f0..fc0122858b 100644 --- a/input/regression/arpeggio-bracket.ly +++ b/input/regression/arpeggio-bracket.ly @@ -1,7 +1,7 @@ \layout { raggedright= ##t } -\version "2.6.0" +\version "2.7.13" \header{ texidoc=" A square bracket on the left indicates that the player should not diff --git a/input/regression/arpeggio-collision.ly b/input/regression/arpeggio-collision.ly index cfe7694921..9e13f8bc5e 100644 --- a/input/regression/arpeggio-collision.ly +++ b/input/regression/arpeggio-collision.ly @@ -1,4 +1,4 @@ -\version "2.6.0" +\version "2.7.13" \header { texidoc = "Arpeggio stays clear of accidentals and flipped note heads." diff --git a/input/regression/arpeggio.ly b/input/regression/arpeggio.ly index 7e5aa36ff5..163c2743cb 100644 --- a/input/regression/arpeggio.ly +++ b/input/regression/arpeggio.ly @@ -1,5 +1,5 @@ -\version "2.6.0" +\version "2.7.13" \header{ texidoc=" Arpeggios are supported, both cross-staff and broken single staff. diff --git a/input/regression/auto-beam-bar.ly b/input/regression/auto-beam-bar.ly index 45113cc54b..70ba750ef7 100644 --- a/input/regression/auto-beam-bar.ly +++ b/input/regression/auto-beam-bar.ly @@ -1,5 +1,5 @@ -\version "2.6.0" +\version "2.7.13" \header{ texidoc="No auto beams will be put over (manual) repeat bars." diff --git a/input/regression/auto-beam-no-beam.ly b/input/regression/auto-beam-no-beam.ly index 4b7c753e45..b2a33cf4b8 100644 --- a/input/regression/auto-beam-no-beam.ly +++ b/input/regression/auto-beam-no-beam.ly @@ -6,7 +6,7 @@ } -\version "2.6.0" +\version "2.7.13" \layout { raggedright = ##t } diff --git a/input/regression/auto-beam-triplet.ly b/input/regression/auto-beam-triplet.ly index f8e1595775..b732ee7ae2 100644 --- a/input/regression/auto-beam-triplet.ly +++ b/input/regression/auto-beam-triplet.ly @@ -4,7 +4,7 @@ texidoc = "Automatic beaming is also done on tuplets." } -\version "2.6.0" +\version "2.7.13" \layout { raggedright= ##t } \relative c''{ diff --git a/input/regression/auto-beam-tuplets.ly b/input/regression/auto-beam-tuplets.ly index 9766ef2434..dfc57b9878 100644 --- a/input/regression/auto-beam-tuplets.ly +++ b/input/regression/auto-beam-tuplets.ly @@ -1,5 +1,5 @@ -\version "2.6.0" +\version "2.7.13" \header { texidoc = "Tuplet-spanner should not put (visible) brackets on diff --git a/input/regression/auto-beam.ly b/input/regression/auto-beam.ly index 138d9678ff..4d7317c291 100644 --- a/input/regression/auto-beam.ly +++ b/input/regression/auto-beam.ly @@ -3,7 +3,7 @@ beam." } -\version "2.6.0" +\version "2.7.13" \layout { raggedright = ##t diff --git a/input/regression/auto-change.ly b/input/regression/auto-change.ly index 080c01f0d0..2148042df0 100644 --- a/input/regression/auto-change.ly +++ b/input/regression/auto-change.ly @@ -1,5 +1,5 @@ -\version "2.6.0" +\version "2.7.13" \header { diff --git a/input/regression/backend-excercise.ly b/input/regression/backend-excercise.ly index 2b11d73601..1232cd9dcc 100644 --- a/input/regression/backend-excercise.ly +++ b/input/regression/backend-excercise.ly @@ -2,7 +2,7 @@ texidoc = "Excercise all output functions" } -\version "2.6.0" +\version "2.7.13" \paper { raggedright = ##t } diff --git a/lily/bar-line.cc b/lily/bar-line.cc index 4a9047929f..49e435fe3f 100644 --- a/lily/bar-line.cc +++ b/lily/bar-line.cc @@ -196,5 +196,6 @@ ADD_INTERFACE (Bar_line, "hair-thickness " "thick-thickness " "glyph " + "glyph-name " "bar-size " ); diff --git a/lily/grob.cc b/lily/grob.cc index b85e61824d..3cde285428 100644 --- a/lily/grob.cc +++ b/lily/grob.cc @@ -732,7 +732,6 @@ ADD_INTERFACE (Grob, "grob-interface", "meta " "minimum-X-extent " "minimum-Y-extent " - "print-function " "spacing-procedure " "staff-symbol " "stencil " diff --git a/lily/include/note-head.hh b/lily/include/note-head.hh index 6575b568eb..bb6546de82 100644 --- a/lily/include/note-head.hh +++ b/lily/include/note-head.hh @@ -23,6 +23,7 @@ public: DECLARE_SCHEME_CALLBACK (brew_ez_stencil, (SCM)); DECLARE_SCHEME_CALLBACK (extent, (SCM, SCM)); DECLARE_SCHEME_CALLBACK (stem_x_shift, (SCM, SCM)); + DECLARE_SCHEME_CALLBACK (calc_stem_attachment, (SCM)); static bool has_interface (Grob *); static Real stem_attachment_coordinate (Grob *, Axis a); static int get_balltype (Grob *); diff --git a/lily/ligature-engraver.cc b/lily/ligature-engraver.cc index cd975b71e9..1480a4d3c3 100644 --- a/lily/ligature-engraver.cc +++ b/lily/ligature-engraver.cc @@ -247,7 +247,7 @@ Ligature_engraver::acknowledge_note_head (Grob_info info) primitives_.push (info); if (info.grob ()) { - info.grob ()->set_property ("print-function", + info.grob ()->set_callback (ly_symbol2scm ("stencil"), brew_ligature_primitive_proc); } } diff --git a/lily/line-spanner.cc b/lily/line-spanner.cc index 358f7311f6..5b8d2fefcf 100644 --- a/lily/line-spanner.cc +++ b/lily/line-spanner.cc @@ -95,7 +95,7 @@ Line_spanner::after_line_breaking (SCM g) /* Can't do suicide, since this mucks up finding the trend. */ - me->set_property ("print-function", SCM_EOL); + me->set_property ("transparent", SCM_BOOL_T); } return SCM_EOL; } diff --git a/lily/note-head.cc b/lily/note-head.cc index 2b31367ef0..2517f5048b 100644 --- a/lily/note-head.cc +++ b/lily/note-head.cc @@ -35,14 +35,14 @@ internal_print (Grob *me, String *font_char) if (!scm_is_symbol (style)) style = ly_symbol2scm ("default"); - SCM log = scm_from_int (Note_head::get_balltype (me)); String suffix = to_string (min (robust_scm2int (me->get_property ("duration-log"), 2), 2)); if (style != ly_symbol2scm ("default")) { - SCM proc = me->get_property ("glyph-name-procedure"); - if (ly_is_procedure (proc)) - suffix = ly_scm2string (scm_call_2 (proc, log, style)); + SCM gn = me->get_property ("glyph-name"); + if (scm_is_string (gn)) + suffix = ly_scm2string (gn); } + Font_metric *fm = Font_interface::get_default_font (me); String idx = "noteheads.s" + suffix; @@ -102,41 +102,44 @@ Note_head::print (SCM smob) Real Note_head::stem_attachment_coordinate (Grob *me, Axis a) { - SCM brewer = me->get_property ("print-function"); + Offset off = robust_scm2offset (me->get_property ("stem-attachment"), + Offset (0,0)); + + return off [a]; +} + +MAKE_SCHEME_CALLBACK(Note_head, calc_stem_attachment, 1); +SCM +Note_head::calc_stem_attachment (SCM smob) +{ + Grob *me = unsmob_grob (smob); Font_metric *fm = Font_interface::get_default_font (me); + String key; + internal_print (me, &key); - if (brewer == Note_head::print_proc) + Offset att; + + int k = fm->name_to_index (key); + if (k >= 0) { - String key; - internal_print (me, &key); - - int k = fm->name_to_index (key); - if (k >= 0) + Box b = fm->get_indexed_char (k); + Offset wxwy = fm->attachment_point (key); + for (int i = X_AXIS ; i < NO_AXES; i++) { - Box b = fm->get_indexed_char (k); - Offset wxwy = fm->attachment_point (key); + Axis a = Axis (i); + Interval v = b[a]; if (!v.is_empty ()) - return 2 * (wxwy[a] - v.center ()) / v.length (); + { + att[a] = (2 * (wxwy[a] - v.center ()) / v.length ()); + } } } - /* - Fallback - */ - SCM v = me->get_property ("stem-attachment-function"); - if (!ly_is_procedure (v)) - return 0.0; - - SCM result = scm_call_2 (v, me->self_scm (), scm_from_int (a)); - if (!scm_is_pair (result)) - return 0.0; - - result = (a == X_AXIS) ? scm_car (result) : scm_cdr (result); - - return robust_scm2double (result, 0); + return ly_offset2scm (att); } + int Note_head::get_balltype (Grob *me) { @@ -151,6 +154,7 @@ ADD_INTERFACE (Note_head, "note-head-interface", "note-names " "glyph-name-procedure " "accidental-grob " + "stem-attachment" "style " - "stem-attachment-function"); + ); diff --git a/lily/stem.cc b/lily/stem.cc index 7b90d475e1..758afae3c7 100644 --- a/lily/stem.cc +++ b/lily/stem.cc @@ -938,6 +938,7 @@ ADD_INTERFACE (Stem, "stem-interface", "avoid-note-head " "beam " "beaming " + "details " "direction " "duration-log " "flag-style " diff --git a/scm/define-grob-properties.scm b/scm/define-grob-properties.scm index 5a15927a73..4ebb7665d8 100644 --- a/scm/define-grob-properties.scm +++ b/scm/define-grob-properties.scm @@ -252,9 +252,6 @@ stem. The stem will stop at the innermost beams.") (glyph ,string? "a string determining what (style) of glyph is typeset. Valid choices depend on the function that is reading this property.") - (glyph-name-procedure ,procedure? "Return the name of a character -within font, to use for printing a symbol.") - (gap ,ly:dimension? "Size of a gap in a variable symbol.") (gap-count ,integer? "Number of gapped beams for tremolo.") (grace-space-factor ,number? "Space grace notes at this fraction @@ -365,9 +362,6 @@ as a real penalty.") "Pair of staff coordinates @code{(@var{left} . @var{right})}, where both @var{left} and @var{right} are in the staff-space unit of the current staff.") - (print-function ,procedure? "Function taking grob as argument, -returning a @code{Stencil} object.") - (ratio ,number? "Parameter for slur shape. The higher this number, the quicker the slur attains it @code{height-limit}.") (remove-first ,boolean? "Remove the first staff of a orchestral score?") @@ -426,11 +420,7 @@ expressed in global staffspace.") staff spaces, counted from the middle line.") (stemlet-length ,number? "How long should a stem over a rest be?") - (stem-attachment-function ,procedure? "A function that calculates -where a stem attaches to the note head? This is a fallback when this -information is not specified in the font. The function takes a grob -and axis argument, and returns a (@var{x} . @var{y}) pair, specifying -location in terms of note head bounding box.") + (stem-attachment ,number-pair? "A (@var{x} . @var{y}) pair where the stem attaches to the notehead.") (stem-end-position ,number? "Where does the stem end (the end is opposite to the support-head.") diff --git a/scm/define-grobs.scm b/scm/define-grobs.scm index 0c83785411..d32ea32ef9 100644 --- a/scm/define-grobs.scm +++ b/scm/define-grobs.scm @@ -109,8 +109,9 @@ (AmbitusNoteHead . ( (duration-log . 2) - (callbacks . ( (stencil . ,Note_head::print))) - (glyph-name-procedure . ,find-notehead-symbol) + (callbacks . ((stencil . ,Note_head::print) + (glyph-name . ,note-head::calc-glyph-name) + )) (Y-offset-callbacks . (,Staff_symbol_referencer::callback)) (meta . ((class . Item) (interfaces . (font-interface @@ -959,12 +960,15 @@ (NoteHead . ( - (callbacks . ((stencil . ,Note_head::print))) + (callbacks . ((stencil . ,Note_head::print) + (stem-attachment . ,Note_head::calc_stem_attachment) + (glyph-name . ,note-head::calc-glyph-name) + )) + + ;; WTF is this? (ligature-primitive-callback . ,Note_head::print) - (glyph-name-procedure . ,find-notehead-symbol) (Y-offset-callbacks . (,Staff_symbol_referencer::callback)) (X-offset-callbacks . (,Note_head::stem_x_shift)) - (stem-attachment-function . ,note-head-style->attachment-coordinates) (meta . ((class . Item) (interfaces . (rhythmic-grob-interface rhythmic-head-interface @@ -1502,7 +1506,7 @@ (callbacks . ((stencil . ,Text_interface::print))) (Y-offset-callbacks . (,Staff_symbol_referencer::callback)) (font-size . -2) - (stem-attachment-function . ,tablature-stem-attachment-function) + (stem-attachment . (1.0 . 1.35)) (font-series . bold) (meta . ((class . Item) (interfaces diff --git a/scm/output-lib.scm b/scm/output-lib.scm index 2546012680..d0dde3f4d5 100644 --- a/scm/output-lib.scm +++ b/scm/output-lib.scm @@ -9,7 +9,7 @@ ;;; Tablature functions, by Jiba (jiba@tuxfamily.org) ;; The TabNoteHead stem attachment function. -(define (tablature-stem-attachment-function style duration) +(define (note-head::calc-tablature-stem-attachment grob) (cons 0.0 1.35)) ;; The TabNoteHead tablatureFormat callback. @@ -110,41 +110,45 @@ ;; silly, use alist? -(define-public (find-notehead-symbol duration style) - (case style - ((xcircle) "2xcircle") - ((harmonic) "0harmonic") - ((baroque) - ;; Oops, I actually would not call this "baroque", but, for - ;; backwards compatibility to 1.4, this is supposed to take - ;; brevis, longa and maxima from the neo-mensural font and all - ;; other note heads from the default font. -- jr - (if (< duration 0) - (string-append (number->string duration) "neomensural") - (number->string duration))) - ((mensural) - (string-append (number->string duration) (symbol->string style))) - ((petrucci) - (if (< duration 0) - (string-append (number->string duration) "mensural") - (string-append (number->string duration) (symbol->string style)))) - ((neomensural) - (string-append (number->string duration) (symbol->string style))) - ((default) - ;; The default font in mf/feta-bolletjes.mf defines a brevis, but - ;; neither a longa nor a maxima. Hence let us, for the moment, - ;; take these from the neo-mensural font. TODO: mf/feta-bolletjes - ;; should define at least a longa for the default font. The longa - ;; should look exactly like the brevis of the default font, but - ;; with a stem exactly like that of the quarter note. -- jr - (if (< duration -1) - (string-append (number->string duration) "neomensural") - (number->string duration))) - (else - (if (string-match "vaticana*|hufnagel*|medicaea*" (symbol->string style)) - (symbol->string style) - (string-append (number->string (max 0 duration)) - (symbol->string style)))))) +(define-public (note-head::calc-glyph-name grob) + (let* + ((style (ly:grob-property grob 'style)) + (log (min 2 (ly:grob-property grob 'duration-log)))) + + (case style + ((xcircle) "2xcircle") + ((harmonic) "0harmonic") + ((baroque) + ;; Oops, I actually would not call this "baroque", but, for + ;; backwards compatibility to 1.4, this is supposed to take + ;; brevis, longa and maxima from the neo-mensural font and all + ;; other note heads from the default font. -- jr + (if (< log 0) + (string-append (number->string log) "neomensural") + (number->string log))) + ((mensural) + (string-append (number->string log) (symbol->string style))) + ((petrucci) + (if (< log 0) + (string-append (number->string log) "mensural") + (string-append (number->string log) (symbol->string style)))) + ((neomensural) + (string-append (number->string log) (symbol->string style))) + ((default) + ;; The default font in mf/feta-bolletjes.mf defines a brevis, but + ;; neither a longa nor a maxima. Hence let us, for the moment, + ;; take these from the neo-mensural font. TODO: mf/feta-bolletjes + ;; should define at least a longa for the default font. The longa + ;; should look exactly like the brevis of the default font, but + ;; with a stem exactly like that of the quarter note. -- jr + (if (< log -1) + (string-append (number->string log) "neomensural") + (number->string log))) + (else + (if (string-match "vaticana*|hufnagel*|medicaea*" (symbol->string style)) + (symbol->string style) + (string-append (number->string (max 0 log)) + (symbol->string style))))))) ;; TODO junk completely? (define (note-head-style->attachment-coordinates grob axis)