]> git.donarmstrong.com Git - lilypond.git/commitdiff
Cleanup of accidental-engraver.cc / accidental.cc
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Thu, 28 Dec 2006 17:08:01 +0000 (18:08 +0100)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Thu, 28 Dec 2006 17:08:01 +0000 (18:08 +0100)
Clarify naming in accidental-engraver.cc.

Use AccidentalCautionary as grob for cautionaries, obviating
cautionary-style and cautionary properties. Use 'font-size and
'parenthesized instead. Use restore-first iso. general list of
alterations. Store alteration in property 'alteration
iso. 'accidentals.

Add conversion rules.

13 files changed:
input/regression/accidental-cautionary.ly
input/regression/accidental-suggestions.ly
lily/accidental-engraver.cc
lily/accidental.cc
lily/ambitus-engraver.cc
lily/include/accidental-interface.hh
lily/pitched-trill-engraver.cc
lily/slur-scoring.cc
make/ly-targets.make
make/lysdoc-targets.make
python/convertrules.py
scm/define-grob-properties.scm
scm/define-grobs.scm

index d93d253c045208208d43a2eea7798ae081968469..b48c8b610d156e80901c38d5d4403c54d0c362a9 100644 (file)
@@ -1,4 +1,4 @@
-\version "2.10.0"
+\version "2.11.5"
 \header {
 
 texidoc = "Cautionary accidentals are indicated using either
@@ -13,9 +13,9 @@ parentheses (default) or smaller accidentals.
 {
     c''4
     cis''?4
-    \override Staff.Accidental  #'cautionary-style = #'smaller
+    \once \override Staff.AccidentalCautionary #'font-size = #-2
     cis''?4
-    \override Staff.Accidental  #'cautionary-style = #'parentheses
+    \once \override Staff.AccidentalCautionary #'parenthesized = ##t
     cis''?4
 }
 
index 8ad68e34a1b73f42f007514a4fe79b5afcf40f3f..06abaedb661f8d7bf49d4c85ad1183553d3a52f8 100644 (file)
@@ -7,7 +7,7 @@ denoting Musica Ficta."
  
 }
 
-\version "2.10.0"
+\version "2.11.5"
 \paper {
   ragged-right = ##t
 }
@@ -16,10 +16,8 @@ denoting Musica Ficta."
   \time 2/4 
   \set suggestAccidentals = ##t 
   cis^> gis'-|
-  \override AccidentalSuggestion #'cautionary-style = #'parentheses
+  \override AccidentalSuggestion #'parenthesized = ##t
   cis,_"paren" gis'
-  \override AccidentalSuggestion #'cautionary-style = #'()
-  cis,_"no caut style"  gis'
 
 }
   
index c33bab98939a7c0092e1df44654e3718af38a4e4..c7f956f9af5da3be856d3fb0972fe0ba05e56a6f 100644 (file)
@@ -53,7 +53,7 @@ class Accidental_engraver : public Engraver
   int get_bar_number ();
   void update_local_key_signature (SCM new_signature);
   void create_accidental (Accidental_entry *entry, bool, bool);
-  Grob *make_standard_accidental (Stream_event *note, Grob *note_head, Engraver *trans);
+  Grob *make_standard_accidental (Stream_event *note, Grob *note_head, Engraver *trans, bool);
   Grob *make_suggested_accidental (Stream_event *note, Grob *note_head, Engraver *trans);
 
 protected:
@@ -375,27 +375,23 @@ Accidental_engraver::create_accidental (Accidental_entry *entry,
   if (as_suggestion)
     a = make_suggested_accidental (note, support, entry->origin_engraver_);
   else
-    a = make_standard_accidental (note, support, entry->origin_engraver_);
+    a = make_standard_accidental (note, support, entry->origin_engraver_, cautionary);
 
-  SCM accs = scm_cons (scm_from_int (pitch->get_alteration () * Rational (4)),
-                      SCM_EOL);
   if (restore_natural)
     {
       if (to_boolean (get_property ("extraNatural")))
-       accs = scm_cons (scm_from_int (0), accs);
+       a->set_property ("restore-first", SCM_BOOL_T);
     }
-  
-  if (cautionary)
-    a->set_property ("cautionary", SCM_BOOL_T);
 
-  a->set_property ("accidentals", accs);
+  a->set_property ("alteration",  scm_from_int (pitch->get_alteration () * Rational (4)));
   entry->accidental_ = a;
 }
 
 Grob *
 Accidental_engraver::make_standard_accidental (Stream_event *note,
                                               Grob *note_head,
-                                              Engraver *trans)
+                                              Engraver *trans,
+                                              bool cautionary)
 {
   (void)note;
 
@@ -404,7 +400,11 @@ Accidental_engraver::make_standard_accidental (Stream_event *note,
     level, so that we get the property settings for
     Accidental from the respective Voice.
   */
-  Grob *a = trans->make_item ("Accidental", note_head->self_scm ());
+  Grob *a = 0;
+  if (cautionary)
+    a = trans->make_item ("AccidentalCautionary", note_head->self_scm ());
+  else
+    a = trans->make_item ("Accidental", note_head->self_scm ());
 
   /*
     We add the accidentals to the support of the arpeggio,
@@ -420,6 +420,9 @@ Accidental_engraver::make_standard_accidental (Stream_event *note,
     Side_position_interface::add_support (a, right_objects_[i]);
 
   a->set_parent (note_head, Y_AXIS);
+  if (cautionary)
+    a->set_property ("cautionary", SCM_BOOL_T);
+
 
   if (!accidental_placement_)
     accidental_placement_ = make_item ("AccidentalPlacement",
@@ -427,7 +430,7 @@ Accidental_engraver::make_standard_accidental (Stream_event *note,
   Accidental_placement::add_accidental (accidental_placement_, a);
 
   note_head->set_object ("accidental-grob", a->self_scm ());
-
+  
   return a;
 }
 
@@ -593,8 +596,13 @@ ADD_TRANSLATOR (Accidental_engraver,
                "This engraver usually lives at Staff level, but "
                "reads the settings for Accidental at @code{Voice} level, "
                "so you can @code{\\override} them at @code{Voice}. ",
-               "Accidental AccidentalSuggestion",
 
+               /* grobs */
+               "Accidental "
+               "AccidentalCautionary"
+               "AccidentalSuggestion",
+
+               /* props */
                "autoAccidentals "
                "autoCautionaries "
                "internalBarNumber "
index 6b9718f61c9ef923c6aaf4aed9bc194a47fcd775..8359c553d0ab4648a5944d34bcead556588ac2fb 100644 (file)
 #include "pitch.hh"
 #include "stencil.hh"
 
-/*
-  TODO: insert support for smaller cautionaries, tie-break-reminders.
-  Either here or in new-accidental-engraver.
-
-  'accidentals should go, for a single 'accidental property -- see
-  accidental-placement.cc
-*/
 Stencil
 parenthesize (Grob *me, Stencil m)
 {
@@ -57,28 +50,23 @@ Accidental_interface::after_line_breaking (SCM smob)
 }
 
 vector<Box>
-Accidental_interface::accurate_boxes (Grob *a, Grob **common)
+Accidental_interface::accurate_boxes (Grob *me, Grob **common)
 {
   Box b;
-  b[X_AXIS] = a->extent (a, X_AXIS);
-  b[Y_AXIS] = a->extent (a, Y_AXIS);
+  b[X_AXIS] = me->extent (me, X_AXIS);
+  b[Y_AXIS] = me->extent (me, Y_AXIS);
 
   vector<Box> boxes;
 
-  bool parens = false;
-  if (to_boolean (a->get_property ("cautionary")))
-    {
-      SCM cstyle = a->get_property ("cautionary-style");
-      parens = ly_is_equal (cstyle, ly_symbol2scm ("parentheses"));
-    }
+  bool parens = to_boolean (me->get_property ("parenthesized"));
 
-  SCM accs = a->get_property ("accidentals");
-  SCM scm_style = a->get_property ("style");
+  SCM scm_style = me->get_property ("style");
   if (!scm_is_symbol (scm_style)
-      && !parens
-      && scm_ilength (accs) == 1)
+      && !to_boolean (me->get_property ("restore-first"))
+      && !parens)
     {
-      switch (scm_to_int (scm_car (accs)))
+      int acc = scm_to_int (me->get_property ("alteration"));
+      switch (acc)
        {
        case FLAT:
          {
@@ -129,8 +117,9 @@ Accidental_interface::accurate_boxes (Grob *a, Grob **common)
   if (!boxes.size ())
     boxes.push_back (b);
 
-  Offset o (a->relative_coordinate (common[X_AXIS], X_AXIS),
-           a->relative_coordinate (common[Y_AXIS], Y_AXIS));
+  Offset o (me->relative_coordinate (common[X_AXIS], X_AXIS),
+           me->relative_coordinate (common[Y_AXIS], Y_AXIS));
+
   for (vsize i = boxes.size (); i--;)
     boxes[i].translate (o);
 
@@ -186,6 +175,7 @@ Accidental_interface::get_fontcharname (string style, int alteration)
     style = ""; // currently same as default
   if (style == "default")
     style = "";
+  
   return style + to_string (alteration);
 }
 
@@ -194,16 +184,7 @@ SCM
 Accidental_interface::print (SCM smob)
 {
   Grob *me = unsmob_grob (smob);
-  bool smaller = false;
-  bool parens = false;
-
-  bool caut = to_boolean (me->get_property ("cautionary"));
-  if (caut)
-    {
-      SCM cstyle = me->get_property ("cautionary-style");
-      parens = ly_is_equal (cstyle, ly_symbol2scm ("parentheses"));
-      smaller = ly_is_equal (cstyle, ly_symbol2scm ("smaller"));
-    }
+  bool parens = to_boolean (me->get_property ("parenthesized"));
 
   SCM scm_style = me->get_property ("style");
   string style;
@@ -215,49 +196,71 @@ Accidental_interface::print (SCM smob)
     */
     style = "";
 
-  Font_metric *fm = 0;
-  if (smaller)
-    {
-      SCM ac = Font_interface::music_font_alist_chain (me);
-      /*
-       TODO: should calc font-size by adding -2 to current font-size
-      */
-      ac = scm_cons (scm_list_1 (scm_cons
-                                (ly_symbol2scm ("font-size"),
-                                 scm_from_int (-2))),
-                    ac);
-      fm = select_font (me->layout (), ac);
-    }
-  else
-    fm = Font_interface::get_default_font (me);
+  Font_metric *fm = Font_interface::get_default_font (me);
 
-  Stencil mol;
-  for (SCM s = me->get_property ("accidentals");
-       scm_is_pair (s); s = scm_cdr (s))
+  SCM stencils = me->get_property ("stencils");
+  if (!scm_is_pair (stencils)
+      || !unsmob_stencil (scm_car (stencils)))
+    return SCM_EOL;
+  
+  Stencil mol (*unsmob_stencil (scm_car (stencils)));
+  if (to_boolean (me->get_property ("restore-first")))
     {
-      int alteration = scm_to_int (scm_car (s));
-      string font_char = get_fontcharname (style, alteration);
+      string font_char = get_fontcharname (style, 0);
       Stencil acc (fm->find_by_name ("accidentals." + font_char));
 
       if (acc.is_empty ())
        me->warning (_f ("accidental `%s' not found", font_char));
       else
-       mol.add_at_edge (X_AXIS, RIGHT, acc, 0.1, 0);
+       mol.add_at_edge (X_AXIS, LEFT, acc, 0.1, 0);
     }
-
+  
   if (parens)
     mol = parenthesize (me, mol);
 
   return mol.smobbed_copy ();
 }
+  
+MAKE_SCHEME_CALLBACK (Accidental_interface, calc_stencils, 1);
+SCM
+Accidental_interface::calc_stencils (SCM smob)
+{
+  Grob *me = unsmob_grob (smob);
+
+  SCM scm_style = me->get_property ("style");
+  string style;
+  if (scm_is_symbol (scm_style))
+    style = ly_symbol2string (scm_style);
+  else
+    /*
+      preferably no name for the default style.
+    */
+    style = "";
+
+
+  Font_metric *fm = Font_interface::get_default_font (me);
+  SCM acc = me->get_property ("alteration");
+  if (scm_is_number (acc))
+    {
+      string font_char = get_fontcharname (style, scm_to_int (acc));
+      
+      Stencil acc_stencil (fm->find_by_name ("accidentals." + font_char));
+
+      return scm_list_1 (acc_stencil.smobbed_copy ());
+    }
+  else
+    return SCM_EOL;
+}
 
+  
 ADD_INTERFACE (Accidental_interface,
               "a single accidental",
-              "accidentals "
+              
+              /* props */
+              "alteration "
               "avoid-slur "
-              "cautionary "
-              "cautionary-style "
               "forced "
               "style "
+              "parenthesized " 
               "tie "
               );
index 8f617652bfdd55a161b4c2a62a9f9523817d4e43..ab2897f16de90b09d30af7bdfc6df0e388776345 100644 (file)
@@ -158,8 +158,7 @@ Ambitus_engraver::finalize ()
            }
          else
            {
-             SCM l = scm_list_1 (scm_from_int (int (Real (Rational (4) * p.get_alteration ()))));
-             accidentals_[d]->set_property ("accidentals", l);
+             accidentals_[d]->set_property ("alteration", scm_from_int (int (Real (Rational (4) * p.get_alteration ()))));
            }
        }
       while (flip (&d) != DOWN);
index 8fd57a5fd91f6a7b9eab3390c9a0811c80f2aa67..13646895e63443e91477fcdcb2ff6910505ad292 100644 (file)
@@ -19,6 +19,7 @@ class Accidental_interface
 {
 public:
   DECLARE_SCHEME_CALLBACK (print, (SCM));
+  DECLARE_SCHEME_CALLBACK (calc_stencils, (SCM));
   DECLARE_SCHEME_CALLBACK (after_line_breaking, (SCM));
   
   DECLARE_GROB_INTERFACE();
index d29f6f42caf33ba91dc14b48a86ef3739ed29813..811decb67d8b0b265b7f5ad48cf890ab5d08a014 100644 (file)
@@ -110,8 +110,8 @@ Pitched_trill_engraver::make_trill (Stream_event *ev)
       trill_accidental_ = make_item ("TrillPitchAccidental", ev->self_scm ());
 
       // fixme: naming -> alterations
-      trill_accidental_->set_property ("accidentals", scm_list_1 (scm_from_int (Rational (4) 
-                                                                               * p->get_alteration ())));
+      trill_accidental_->set_property ("alteration", scm_from_int (Rational (4) 
+                                                                  * p->get_alteration ()));
       Side_position_interface::add_support (trill_accidental_, trill_head_);
       
       trill_head_->set_object ("accidental-grob", trill_accidental_->self_scm ());
index bbd257f932bc1254ba3b0e630dea3d727d3e073e..85c06bf95ac6c9a51cdcad1e5cf28a63cc418e50 100644 (file)
@@ -791,14 +791,14 @@ Slur_score_state::get_extra_encompass_infos () const
                  parens = ly_is_equal (cstyle, ly_symbol2scm ("parentheses"));
                }
 
-             SCM accs = g->get_property ("accidentals");
+             SCM alt = g->get_property ("alteration");
              SCM scm_style = g->get_property ("style");
              if (!scm_is_symbol (scm_style)
                  && !parens
-                 && scm_ilength (accs) == 1)
+                 && !to_boolean (g->get_property ("restore-first")))
                {
                  /* End copy accidental.cc */
-                 switch (scm_to_int (scm_car (accs)))
+                 switch (scm_to_int (alt))
                    {
                    case FLAT:
                    case DOUBLE_FLAT:
index d01701d8593b223465114cf46e6b2dc19a3d1caf..a2d621b154c81eb103453a8ea076d0830fb3bb0b 100644 (file)
@@ -6,9 +6,3 @@ local-convert-ly:
 
 local-help: local-ly-help
 
-local-ly-help:
-       @echo -e "\
-  convert-ly  convert all LilyPond sources\n\
-"\
-#
-
index 2de20828a9a47da176be745f9e5f9e08f95f953e..cf5a9d2e677a324d1350581352dc5b6edd3ffdae 100644 (file)
@@ -3,3 +3,4 @@
 local-WWW: $(outdir)/collated-files.html $(outdir)/collated-files.pdf
 
 #.PRECIOUS: $(outdir)/$(NAME).texi
+
index a2ac08534b12706c02d643d7ad5c7b1b83d6b6ff..165e0a52d8ecfbce4aacc87358256f400929d619 100644 (file)
@@ -2885,3 +2885,20 @@ def conv (str):
 
 conversions.append (((2, 11, 2), conv, """ly:clone-parser -> ly:parser-clone"""))
 
+
+
+def conv (str):
+    str = re.sub ("Accidental\s*#'cautionary-style\s*=\s*#'smaller",
+                   "AccidentalCautionary #'font-size = #-2", str)
+    str = re.sub ("Accidental\s*#'cautionary-style\s*=\s*#'parentheses",
+                   "AccidentalCautionary #'parenthesized = ##t", str)
+
+    str = re.sub ("([A-Za-z]+)\s*#'cautionary-style\s*=\s*#'parentheses",
+                   r"\1 #'parenthesized = ##t", str)
+    str = re.sub ("([A-Za-z]+)\s*#'cautionary-style\s*=\s*#'smaller",
+                   r"\1 #'font-size = #-2", str)
+
+    return str
+
+conversions.append (((2, 11, 5), conv, """ly:clone-parser -> ly:parser-clone"""))
+
index 96a444d78e8aa7595d461612d8a45e6b52c7abd4..7ae1a0e4fe3d42e9ef0b573c63563496851f1753 100644 (file)
@@ -25,7 +25,7 @@
      (X-offset ,number? "The horizontal amount that this object is moved relative to its X-parent")
      (Y-offset ,number? "The vertical amount that this object is moved
 relative to its Y-parent")
-     (accidentals ,list? "List of alteration numbers")
+     (alteration ,number? "alteration numbers for accidental")
      (after-line-breaking ,boolean? "Dummy property, used to trigger callback for after-line-breaking")
      (alteration-alist ,list? "List of @code{(@var{pitch}
 . @var{accidental})} pairs for key signature.")
@@ -98,10 +98,6 @@ tuplet bracket.")
 #t means visible, #f means killed.")
      (c0-position ,integer? "An integer indicating the position of
 middle C.")
-     (cautionary-style ,symbol? "How to print cautionary
-accidentals. Choices are @code{smaller} or
-@code{parentheses}.")
-     (cautionary ,boolean? "Is this a cautionary accidental?")
      (concaveness ,number? "A beam is concave when its inner stems are
 closer to the beam than the two outside stems. This number is a
 measure of the closeness of the inner stems. It is used for damping
@@ -304,6 +300,7 @@ with a negative penalty.")
 This affects the choices of the page breaker; it will avoid a page
 turn at a column with a positive penalty and prefer a page turn at a column
 with a negative penalty.")
+     (parenthesized ,boolean? "Parenthesize this grob.")
      (line-break-penalty ,number? "Penalty for a line break at this column.
 This affects the choices of the line breaker; it will avoid a line
 break at a column with a positive penalty and prefer a line break at a column
@@ -317,6 +314,7 @@ quicker the slur attains it @code{height-limit}.")
      (remove-empty ,boolean? "If set, remove group if it contains no
 @code{interesting-items}")
      (remove-first ,boolean? "Remove the first staff of a orchestral score?")
+     (restore-first ,boolean? "Print a natural before the accidental.")
      (rhythmic-location ,rhythmic-location? "Where (bar number, measure position) in the score.")
      (right-padding ,ly:dimension? "Space to insert on the right side  of an object (eg. between note and its accidentals.)")
      (rotation ,list? "Number of degrees to rotate this object, and what point
index 1b0ec25293b3b8369e8d3f0e4bc3622e949a6e6d..ef150b8f48f3acee54c23efdc2e694138355dfc3 100644 (file)
        (avoid-slur . inside)
        (cautionary-style . parentheses)
        (stencil . ,ly:accidental-interface::print)
+       (stencils . ,ly:accidental-interface::calc-stencils)
        (after-line-breaking
         . ,ly:accidental-interface::after-line-breaking)
        (meta . ((class . Item)
                 (interfaces . (accidental-interface
                                font-interface))))))
+    (AccidentalCautionary
+     . (
+       (avoid-slur . inside)
+       (parenthesized . #t)
+       (stencil . ,ly:accidental-interface::print)
+       (stencils . ,ly:accidental-interface::calc-stencils)
+       (after-line-breaking
+        . ,ly:accidental-interface::after-line-breaking)
+       (meta . ((class . Item)
+                (interfaces . (accidental-interface
+                               font-interface))))))
+
     
     (AccidentalSuggestion
      . (
                        ,(ly:make-simple-closure (list ly:self-alignment-interface::centered-on-x-parent))
                        ,(ly:make-simple-closure (list ly:self-alignment-interface::x-aligned-on-self)))))
        (self-alignment-X . ,CENTER)
-       (cautionary . #t)
-       (cautionary-style . smaller)
+       (font-size . -2)
        (Y-offset . ,ly:side-position-interface::y-aligned-side)
-       (cautionary-style . parentheses)
        (direction . ,UP)
        (staff-padding . 0.25)
+       (outside-staff-priority . 0)
        (script-priority . 0)
+       (stencils . ,ly:accidental-interface::calc-stencils)
        (side-axis . ,X)
        (meta . ((class . Item)
                 (interfaces . (side-position-interface
        (padding . 0.5)
        (X-offset . ,ly:side-position-interface::x-aligned-side)
        (direction . ,LEFT)
-       (cautionary-style . parentheses)
        (stencil . ,ly:accidental-interface::print)
+       (stencils . ,ly:accidental-interface::calc-stencils)
+       
        (after-line-breaking . ,ly:accidental-interface::after-line-breaking)
        (side-axis . ,X)
        (meta . ((class . Item)
        (font-size . -4)
        (side-axis . ,X)
        (stencil . ,ly:accidental-interface::print)
+       (stencils . ,ly:accidental-interface::calc-stencils)
        (meta . ((class . Item)
                 (interfaces . (item-interface
                                trill-pitch-accidental-interface
                                note-head-interface
                                rhythmic-head-interface
                                font-interface
-                               accidental-interface
                                axis-group-interface))))))
 
     (TrillPitchHead