]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/new-fingering-engraver.cc
install info; remove useless offline-root directory
[lilypond.git] / lily / new-fingering-engraver.cc
index f965e63e53d4b86eb307c2112ba162b3e9a9b90c..db99dede95b2979324c3d7858911928bb67ac069 100644 (file)
@@ -1,14 +1,26 @@
 /*
-  fingering-engraver.cc -- implement New_fingering_engraver
+  This file is part of LilyPond, the GNU music typesetter.
 
-  source file of the GNU LilyPond music typesetter
+  Copyright (C) 1998--2011 Han-Wen Nienhuys <hanwen@xs4all.nl>
 
-  (c) 1998--2006 Han-Wen Nienhuys <hanwen@xs4all.nl>
+  LilyPond is free software: you can redistribute it and/or modify
+  it under the terms of the GNU General Public License as published by
+  the Free Software Foundation, either version 3 of the License, or
+  (at your option) any later version.
+
+  LilyPond is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  GNU General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with LilyPond.  If not, see <http://www.gnu.org/licenses/>.
 */
 
 #include "engraver.hh"
 
 #include "international.hh"
+#include "item.hh"
 #include "rhythmic-head.hh"
 #include "script-interface.hh"
 #include "self-alignment-interface.hh"
@@ -20,7 +32,6 @@
 #include "translator.icc"
 
 
-
 struct Finger_tuple
 {
   Grob *head_;
@@ -48,11 +59,11 @@ operator< (Finger_tuple const &a, Finger_tuple const &b)
 class New_fingering_engraver : public Engraver
 {
   vector<Finger_tuple> fingerings_;
-  vector<Finger_tuple> string_fingerings_;
+  vector<Finger_tuple> stroke_fingerings_;
   vector<Finger_tuple> articulations_;
   vector<Finger_tuple> string_numbers_;
 
-  vector<Grob*> heads_;
+  vector<Grob *> heads_;
   Grob *stem_;
 
   void position_all ();
@@ -92,22 +103,22 @@ New_fingering_engraver::acknowledge_rhythmic_head (Grob_info inf)
                       &fingerings_,
                       ev, note_ev);
       else if (ev->in_event_class ("text-script-event"))
-       ev->origin ()->warning (_ ("can't add text scripts to individual note heads"));
+       ev->origin ()->warning (_ ("cannot add text scripts to individual note heads"));
       else if (ev->in_event_class ("script-event"))
        add_script (inf.grob (), ev, note_ev);
       else if (ev->in_event_class ("string-number-event"))
        add_fingering (inf.grob (),
                       ly_symbol2scm ("StringNumber"), &string_numbers_,
                       ev, note_ev);
-      else if (ev->in_event_class ("string-finger-event"))
+      else if (ev->in_event_class ("stroke-finger-event"))
        add_fingering (inf.grob (),
-                      ly_symbol2scm ("StringFinger"), &string_fingerings_,
+                      ly_symbol2scm ("StrokeFinger"), &stroke_fingerings_,
                       ev, note_ev);
       else if (ev->in_event_class ("harmonic-event"))
        {
          inf.grob ()->set_property ("style", ly_symbol2scm ("harmonic"));
          Grob *d = unsmob_grob (inf.grob ()->get_object ("dot"));
-         if (d)
+         if (d && !to_boolean (get_property ("harmonicDots")))
            d->suicide ();
        }
     }
@@ -124,10 +135,8 @@ New_fingering_engraver::acknowledge_stem (Grob_info inf)
 void
 New_fingering_engraver::add_script (Grob *head,
                                    Stream_event *event,
-                                   Stream_event *note)
+                                   Stream_event * /* note */)
 {
-  (void) note;
-
   Finger_tuple ft;
 
   Grob *g = make_item ("Script", event->self_scm ());
@@ -135,7 +144,11 @@ New_fingering_engraver::add_script (Grob *head,
                          event->get_property ("articulation-type"), 0);
   ft.script_ = g;
   ft.script_->set_parent (head, X_AXIS);
-  
+
+  SCM forced_dir = event->get_property ("direction");
+  if (to_dir (forced_dir))
+    ft.script_->set_property ("direction", forced_dir);
+
   articulations_.push_back (ft);
 }
 
@@ -150,8 +163,7 @@ New_fingering_engraver::add_fingering (Grob *head,
 
   ft.script_ = internal_make_item (grob_sym, event->self_scm (),
                                   ly_symbol2string (grob_sym).c_str (),
-                                  __FILE__, __LINE__, __FUNCTION__
-                                  );
+                                  __FILE__, __LINE__, __FUNCTION__);
 
   Side_position_interface::add_support (ft.script_, head);
 
@@ -248,6 +260,14 @@ New_fingering_engraver::position_scripts (SCM orientations,
       Grob *f = ft.script_;
       f->set_parent (ft.head_, X_AXIS);
       f->set_parent (ft.head_, Y_AXIS);
+      f->set_property ("avoid-slur", SCM_BOOL_F);
+      if (hordir == LEFT
+         && unsmob_grob (ft.head_->get_object ("accidental-grob")))
+       Side_position_interface::add_support (f,
+                                             unsmob_grob (ft.head_->get_object ("accidental-grob")));
+      else if (unsmob_grob (ft.head_->get_object ("dot")))
+       Side_position_interface::add_support (f,
+                                             unsmob_grob (ft.head_->get_object ("dot")));
 
       Self_alignment_interface::set_align_self (f, Y_AXIS);
       Self_alignment_interface::set_center_parent (f, Y_AXIS);
@@ -256,8 +276,6 @@ New_fingering_engraver::position_scripts (SCM orientations,
       f->set_property ("direction", scm_from_int (hordir));
     }
 
-  int finger_prio = 200;
-
   Direction d = DOWN;
   Drul_array< vector<Finger_tuple> > vertical (down, up);
   do
@@ -266,6 +284,7 @@ New_fingering_engraver::position_scripts (SCM orientations,
        {
          Finger_tuple ft = vertical[d][i];
          Grob *f = ft.script_;
+         int finger_prio = robust_scm2int (f->get_property ("script-priority"), 200);
          f->set_parent (ft.head_, X_AXIS);
          f->set_property ("script-priority",
                           scm_from_int (finger_prio + d * ft.position_));
@@ -273,7 +292,7 @@ New_fingering_engraver::position_scripts (SCM orientations,
          Self_alignment_interface::set_align_self (f, X_AXIS);
          Self_alignment_interface::set_center_parent (f, X_AXIS);
          Side_position_interface::set_axis (f, Y_AXIS);
-      
+
          f->set_property ("direction", scm_from_int (d));
        }
     }
@@ -283,12 +302,11 @@ New_fingering_engraver::position_scripts (SCM orientations,
 void
 New_fingering_engraver::stop_translation_timestep ()
 {
-  position_all();
+  position_all ();
   stem_ = 0;
   heads_.clear ();
 }
 
-
 void
 New_fingering_engraver::position_all ()
 {
@@ -306,13 +324,13 @@ New_fingering_engraver::position_all ()
       string_numbers_.clear ();
     }
 
-  if (string_fingerings_.size ())
+  if (stroke_fingerings_.size ())
     {
-      position_scripts (get_property ("stringFingerOrientations"),
-                       &string_fingerings_);
-      string_fingerings_.clear ();
+      position_scripts (get_property ("strokeFingerOrientations"),
+                       &stroke_fingerings_);
+      stroke_fingerings_.clear ();
     }
-  
+
   for (vsize i = articulations_.size (); i--;)
     {
       Grob *script = articulations_[i].script_;
@@ -334,25 +352,27 @@ New_fingering_engraver::New_fingering_engraver ()
   stem_ = 0;
 }
 
-
 ADD_ACKNOWLEDGER (New_fingering_engraver, rhythmic_head);
 ADD_ACKNOWLEDGER (New_fingering_engraver, stem);
 
 ADD_TRANSLATOR (New_fingering_engraver,
-               /* doc */ "Create fingering-scripts for notes in a new chord.  "
-               "This engraver is ill-named, since it "
-               "also takes care of articulations and harmonic note heads",
+               /* doc */
+               "Create fingering scripts for notes in a new chord.  This"
+               " engraver is ill-named, since it also takes care of"
+               " articulations and harmonic note heads.",
+
                /* create */
                "Fingering "
                "StringNumber "
-               "StringFinger "
-               "Script "
-               ,
+               "StrokeFinger "
+               "Script ",
+
                /* read */
-               
                "fingeringOrientations "
-               "stringFingerOrientations "
-               "stringNumberOrientations "
-               ,
-               
-               /* write */ "");
+               "harmonicDots "
+               "strokeFingerOrientations "
+               "stringNumberOrientations ",
+
+               /* write */
+               ""
+               );