]> git.donarmstrong.com Git - lilypond.git/commitdiff
* lily/note-head.cc (calc_stem_attachment): new function.
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Sun, 16 Oct 2005 13:52:42 +0000 (13:52 +0000)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Sun, 16 Oct 2005 13:52:42 +0000 (13:52 +0000)
(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.

20 files changed:
input/regression/arpeggio-bracket.ly
input/regression/arpeggio-collision.ly
input/regression/arpeggio.ly
input/regression/auto-beam-bar.ly
input/regression/auto-beam-no-beam.ly
input/regression/auto-beam-triplet.ly
input/regression/auto-beam-tuplets.ly
input/regression/auto-beam.ly
input/regression/auto-change.ly
input/regression/backend-excercise.ly
lily/bar-line.cc
lily/grob.cc
lily/include/note-head.hh
lily/ligature-engraver.cc
lily/line-spanner.cc
lily/note-head.cc
lily/stem.cc
scm/define-grob-properties.scm
scm/define-grobs.scm
scm/output-lib.scm

index 050bd3b3f08756e2dfba1fdaf8270a5e2670bba8..fc0122858bc7e5ba59c0c33e51f30799afb90e38 100644 (file)
@@ -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
index cfe7694921df8349738b37e484a3814bae542538..9e13f8bc5e4de43fcf2cd562e5c4e78d76a73baa 100644 (file)
@@ -1,4 +1,4 @@
-\version "2.6.0"
+\version "2.7.13"
 
 \header  {
 texidoc = "Arpeggio stays clear of accidentals and flipped note heads."
index 7e5aa36ff58431390618f4801935d010d15566c9..163c2743cbb92f54657844db67e4a9fdceb74e1a 100644 (file)
@@ -1,5 +1,5 @@
 
-\version "2.6.0"
+\version "2.7.13"
 \header{
   texidoc="
 Arpeggios are supported, both cross-staff and broken single staff.
index 45113cc54be203afb4efce3a9d3e1c26e40564c9..70ba750ef7da4dae240952fc79f3c2a74ec5b12b 100644 (file)
@@ -1,5 +1,5 @@
 
-\version "2.6.0"
+\version "2.7.13"
 
 \header{
 texidoc="No auto beams will be put over (manual) repeat bars."
index 4b7c753e45b50cc430bbb674c575d25bd79d1f3f..b2a33cf4b844456ae0b85ff423441a003dd54b74 100644 (file)
@@ -6,7 +6,7 @@
 
     }
 
-\version "2.6.0"
+\version "2.7.13"
 \layout {
     raggedright = ##t
 }
index f8e159577528b09bc8977cca9703a9802c8181e3..b732ee7ae254a6b5228910344bd61261bc79ab39 100644 (file)
@@ -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''{
index 9766ef243416d25cff8cf16112bedb46000ac307..dfc57b98789e42f5da4e3b3e9bf643da790c04d5 100644 (file)
@@ -1,5 +1,5 @@
 
-\version "2.6.0"
+\version "2.7.13"
 
 \header {
   texidoc = "Tuplet-spanner should not put (visible) brackets on
index 138d9678ff91e48df150966adda884a8e0a760ae..4d7317c2914a647b47b14f0f5682a13788ac7418 100644 (file)
@@ -3,7 +3,7 @@
 beam."
 }
 
-\version "2.6.0"
+\version "2.7.13"
 
 \layout  {
   raggedright = ##t 
index 080c01f0d0627b2cc87413f05ae17a8d275ec862..2148042df056bbc5a728a9e8de2162b997378e80 100644 (file)
@@ -1,5 +1,5 @@
 
-\version "2.6.0"
+\version "2.7.13"
 
 \header {
 
index 2b11d73601a82d7b5c50fd7d311201cf6b0760e5..1232cd9dcc14cc947a71e8bc5b4b4ce186786fa4 100644 (file)
@@ -2,7 +2,7 @@
   texidoc = "Excercise all output functions"
 }
 
-\version "2.6.0"
+\version "2.7.13"
 
 \paper { raggedright = ##t }
 
index 4a9047929f212df512ae7c4436334d277738d12e..49e435fe3fb4911976afee2ffaa5002a27e821de 100644 (file)
@@ -196,5 +196,6 @@ ADD_INTERFACE (Bar_line,
               "hair-thickness "
               "thick-thickness "
               "glyph "
+              "glyph-name "
               "bar-size "
               );
index b85e61824d12a5ece5211269e2e000a6e54e8f4e..3cde28542814acc827193021c7118de4faa44f55 100644 (file)
@@ -732,7 +732,6 @@ ADD_INTERFACE (Grob, "grob-interface",
               "meta "
               "minimum-X-extent "
               "minimum-Y-extent "
-              "print-function "
               "spacing-procedure "
               "staff-symbol "
               "stencil "
index 6575b568eb2eb03a387765bba455ceadab44afe1..bb6546de8237d576abf6404cce97167709c380e3 100644 (file)
@@ -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 *);
index cd975b71e98c8f72244ee7e380b44b9210f03ee3..1480a4d3c3985e8c0b4063b12144729cff4d0a92 100644 (file)
@@ -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);
        }
     }
index 358f7311f6650bf91f26717bc54fa1e9f88a95fc..5b8d2fefcf51522f9a721f6295b97a6c21175fdd 100644 (file)
@@ -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;
 }
index 2b31367ef07c369f70a7f9771de2457446dcacef..2517f5048b562866b46cdacd7d24310095681fee 100644 (file)
@@ -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");
+              );
 
index 7b90d475e13251b3b01c4902f26b2cb0c09b6c90..758afae3c7f8ce359b12c5c38eaa2cf55834cb74 100644 (file)
@@ -938,6 +938,7 @@ ADD_INTERFACE (Stem, "stem-interface",
               "avoid-note-head "
               "beam "
               "beaming "
+              "details "
               "direction "
               "duration-log "
               "flag-style "
index 5a15927a730f402cd3a9255122b44e5e2719ef06..4ebb7665d82d8c678be36d0c9fc96d38acd65ee6 100644 (file)
@@ -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.")
 
index 0c83785411ea9bbf204f9222d390f97414f73998..d32ea32ef924811cfc90453e238411413efbfa4f 100644 (file)
     (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
 
     (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
        (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
index 2546012680d7ace5cf2528abd589acf696e12634..d0dde3f4d5deb6eab23b0b4515bf54d1ebfa0231 100644 (file)
@@ -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.
 
 
 ;; 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)