]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/a2-engraver.cc
release: 1.3.147
[lilypond.git] / lily / a2-engraver.cc
index 5df8930a30054f7e3cd364dc260e3e666fa6f36b..f52b9f03875d22bde03f4fa5c0c066a61c1b492b 100644 (file)
@@ -3,7 +3,7 @@
 
   source file of the GNU LilyPond music typesetter
   
-  (c) 2000 Jan Nieuwenhuizen <janneke@gnu.org>
+  (c) 2000--2001 Jan Nieuwenhuizen <janneke@gnu.org>
 */
 
 #include "engraver.hh"
@@ -14,7 +14,7 @@
 #include "translator-group.hh"
 #include "side-position-interface.hh"
 #include "directional-element-interface.hh"
-
+#include "multi-measure-rest.hh"
 
 class A2_engraver : public Engraver
 {
@@ -55,7 +55,7 @@ A2_engraver::create_grobs ()
                  && daddy_trans_l_->id_str_.left_str (3) == "one")))
        {
          text_p_ = new Item (get_property ("TextScript"));
-         Side_position::set_axis (text_p_, Y_AXIS);
+         Side_position_interface::set_axis (text_p_, Y_AXIS);
          announce_grob (text_p_, 0);
       
          Direction dir = UP;
@@ -80,7 +80,7 @@ A2_engraver::create_grobs ()
                text = get_property ("aDueText");
            }
          
-         Side_position::set_direction (text_p_, dir);
+         Side_position_interface::set_direction (text_p_, dir);
          text_p_->set_grob_property ("text", text);
        }
     }
@@ -97,14 +97,14 @@ A2_engraver::acknowledge_grob (Grob_info i)
       if (Note_head::has_interface (i.elem_l_))
        {
          Grob*t = text_p_;
-         Side_position::add_support (t, i.elem_l_);
-         if (Side_position::get_axis (t) == X_AXIS
+         Side_position_interface::add_support (t, i.elem_l_);
+         if (Side_position_interface::get_axis (t) == X_AXIS
              && !t->parent_l (Y_AXIS))
            t->set_parent (i.elem_l_, Y_AXIS);
        }
       if (Stem::has_interface (i.elem_l_))
        {
-         Side_position::add_support (text_p_, i.elem_l_);
+         Side_position_interface::add_support (text_p_, i.elem_l_);
        }
     }
          
@@ -129,19 +129,33 @@ A2_engraver::acknowledge_grob (Grob_info i)
     state_ = SPLIT_INTERVAL;
   else if (unirhythm)
     state_ = UNIRHYTHM;
+
+  Direction d = CENTER;
+  if (daddy_trans_l_->id_str_.left_str (3) == "one")
+    d =  UP;
+  else if (daddy_trans_l_->id_str_.left_str (3) == "two")
+    d = DOWN;
+
+  /* Must only set direction for VoiceCombines, not for StaffCombines:
+     we can't detect that here, so, ugh, yet another property */
+  if (!to_boolean (get_property ("noDirection"))
+      && (Stem::has_interface (i.elem_l_)
+         || Slur::has_interface (i.elem_l_)
+         // || Tie::has_interface (i.elem_l_)
+         || i.elem_l_->has_interface (ly_symbol2scm ("tie-interface"))
          
-  if (Stem::has_interface (i.elem_l_)
-      || Slur::has_interface (i.elem_l_)
-      /*
-       Usually, dynamics are removed by *_devnull_engravers for the
-       second voice.  On the one hand, we don't want all dynamics for
-       the first voice to be placed above the staff.  On the other
-       hand, colliding of scripts may be worse */
-#if 0
-      || i.elem_l_->has_interface (ly_symbol2scm ("dynamic-interface"))
-      || i.elem_l_->has_interface (ly_symbol2scm ("text-interface"))
-#endif
-      )
+         /*
+           Usually, dynamics are removed by *_devnull_engravers for the
+           second voice.  On the one hand, we don't want all dynamics for
+           the first voice to be placed above the staff.  On the other
+           hand, colliding of scripts may be worse.
+           So, we don't set directions for these when we're playing solo.
+         */
+         || (i.elem_l_->has_interface (ly_symbol2scm ("dynamic-interface"))
+             && state_ != SOLO)
+         || (i.elem_l_->has_interface (ly_symbol2scm ("text-interface"))
+             && state_ != SOLO)
+         ))
     {
       /*
        Hmm.  We must set dir when solo, in order to get
@@ -152,16 +166,23 @@ A2_engraver::acknowledge_grob (Grob_info i)
          || (unirhythm == SCM_BOOL_T && split_interval == SCM_BOOL_T
              && (unison != SCM_BOOL_T || solo_adue != SCM_BOOL_T)))
        {
-         if (daddy_trans_l_->id_str_.left_str (3) == "one")
-           {
-             i.elem_l_->set_grob_property ("direction", gh_int2scm (1));
-           }
-         else if (daddy_trans_l_->id_str_.left_str (3) == "two")
-           {
-             i.elem_l_->set_grob_property ("direction", gh_int2scm (-1));
-           }
+       
+         /*
+           Blunt axe method: every grob gets a propertysetting.
+          */
+         i.elem_l_->set_grob_property ("direction", gh_int2scm (d));
        }
     }
+
+  /*
+    todo: should we have separate state variable for being "rest while
+    other has solo?"  */
+  if ( Multi_measure_rest::has_interface (i.elem_l_) && d )
+    if (state_ == UNIRHYTHM
+       && unisilence != SCM_BOOL_T)
+    {
+      i.elem_l_->set_grob_property ("staff-position", gh_int2scm (d * 6));
+    }
 }
 
 void 
@@ -169,7 +190,7 @@ A2_engraver::stop_translation_timestep ()
 {
   if (text_p_)
     {
-      Side_position::add_staff_support (text_p_);
+      Side_position_interface::add_staff_support (text_p_);
       typeset_grob (text_p_);
       text_p_ = 0;
     }