]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/tie-engraver.cc
2003 -> 2004
[lilypond.git] / lily / tie-engraver.cc
index 7806f311f7df25beb3b2719ab538862c04742c1c..7b4232d2ff1ab80e5a10115ba279ec494b066863 100644 (file)
@@ -3,7 +3,7 @@
   
   source file of the GNU LilyPond music typesetter
   
-  (c) 1998--2003 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+  (c) 1998--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
   
  */
 
@@ -17,6 +17,7 @@
 #include "grob-pitch-tuple.hh"
 #include "warn.hh"
 #include "note-head.hh"
+#include "staff-symbol-referencer.hh"
 
 /**
    Manufacture ties.  Acknowledge noteheads, and put them into a
@@ -46,12 +47,12 @@ class Tie_engraver : public Engraver
   
   Spanner * tie_column_;
   
-  
 protected:
   virtual void stop_translation_timestep ();
+  virtual void start_translation_timestep ();
   virtual void acknowledge_grob (Grob_info);
   virtual bool try_music (Music*);
-  virtual void process_acknowledged_grobs ();
+  virtual void process_music ();
   void typeset_tie (Grob*);
 public:
   TRANSLATOR_DECLARATIONS(Tie_engraver);
@@ -75,18 +76,16 @@ Tie_engraver::try_music (Music *mus)
       event_ = mus;
     }
   
-  if (event_)
-    {
-      SCM m = get_property ("automaticMelismata");
-      bool am = gh_boolean_p (m) &&gh_scm2bool (m);
-      if (am)
-       {
-  daddy_trans_->set_property ("tieMelismaBusy", m ? SCM_BOOL_T : SCM_BOOL_F);
-       }
-    }
   return true;
 }
 
+void
+Tie_engraver::process_music ()
+{
+  if (event_)
+    daddy_trans_->set_property ("tieMelismaBusy", SCM_BOOL_T);
+}
+
 void
 Tie_engraver::acknowledge_grob (Grob_info i)
 {
@@ -97,11 +96,17 @@ Tie_engraver::acknowledge_grob (Grob_info i)
       for  (int i = heads_to_tie_.size (); i--;)
        {
          Grob *th =  heads_to_tie_[i];
-         int staff_pos = gh_scm2int (h->get_grob_property ("staff-position"));
-         int left_staff_pos = gh_scm2int (th->get_grob_property ("staff-position"));
-         if (staff_pos == left_staff_pos)
+         Music * right_mus = unsmob_music (h->get_grob_property ("cause"));
+         Music * left_mus = unsmob_music (th->get_grob_property ("cause"));
+
+         /*
+           maybe should check positions too.
+          */
+         if (right_mus && left_mus
+             && gh_equal_p (right_mus->get_mus_property ("pitch"),
+                            left_mus->get_mus_property ("pitch")))
            {
-             Grob * p = new Spanner (get_property ("Tie"));
+             Grob * p = make_spanner ("Tie");
              Tie::set_interface (p); // cannot remove yet!
          
              Tie::set_head (p, LEFT, th);
@@ -111,24 +116,27 @@ Tie_engraver::acknowledge_grob (Grob_info i)
              announce_grob(p, last_event_->self_scm());
            }
        }
+
+      if (ties_.size () && ! tie_column_)
+       {
+         tie_column_ = make_spanner ("TieColumn");
+         announce_grob(tie_column_, SCM_EOL);
+       }
+
+      if (tie_column_)
+       for (int i = ties_.size (); i--;)
+         Tie_column::add_tie (tie_column_,ties_ [i]);
     }
 }
 
 void
-Tie_engraver::process_acknowledged_grobs ()
+Tie_engraver::start_translation_timestep ()
 {
-  if (ties_.size () > 1 && !tie_column_)
-    {
-      tie_column_ = new Spanner (get_property ("TieColumn"));
+  daddy_trans_->set_property ("tieMelismaBusy",
+                             gh_bool2scm (heads_to_tie_.size ()));
       
-      for (int i = ties_.size (); i--;)
-       Tie_column::add_tie (tie_column_,ties_ [i]);
-
-      announce_grob(tie_column_, SCM_EOL);
-    }
 }
 
-
 void
 Tie_engraver::stop_translation_timestep ()
 {
@@ -173,8 +181,8 @@ Tie_engraver::typeset_tie (Grob *her)
       new_head_drul[d] = Tie::head (her, (Direction)-d);
   } while (flip (&d) != LEFT);
 
-  index_set_cell (her->get_grob_property ("heads"), LEFT, new_head_drul[LEFT]->self_scm ());
-  index_set_cell (her->get_grob_property ("heads"), RIGHT, new_head_drul[RIGHT]->self_scm ());
+  index_set_cell (her->get_grob_property ("head-pair"), LEFT, new_head_drul[LEFT]->self_scm ());
+  index_set_cell (her->get_grob_property ("head-pair"), RIGHT, new_head_drul[RIGHT]->self_scm ());
 
   typeset_grob (her);
 }