]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/tab-tie-follow-engraver.cc
Issue 5167/6: Changes: show \markup xxx = ... \etc assignments
[lilypond.git] / lily / tab-tie-follow-engraver.cc
index fbeb93266e14c481899384ecf24cafe14a136139..75a7b5b2ea710bd42ec5283eb7b8de6549045e30 100644 (file)
@@ -1,7 +1,7 @@
 /*
   This file is part of LilyPond, the GNU music typesetter.
 
-  Copyright (C) 2010 Carl D. Sorensen
+  Copyright (C) 2010--2015 Carl D. Sorensen
 
   LilyPond is free software: you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
@@ -26,85 +26,111 @@ using namespace std;
 
 #include "context.hh"
 #include "item.hh"
+#include "spanner.hh"
 
 #include "translator.icc"
 
 /*
-   Change tab-note-head properties for a note_head at the right end of a tie
+   Change tab-note-head properties when a tie is followed by a
+   slurs or glissando.
 */
 class Tab_tie_follow_engraver : public Engraver
 {
-  vector<Grob*> ties_;
-  vector<Grob*> note_heads_;
+  vector<Spanner *> slurs_;
+  vector<Spanner *> glissandi_;
+  vector<Item *> note_heads_;
 
 public:
   TRANSLATOR_DECLARATIONS (Tab_tie_follow_engraver);
 
 protected:
-  DECLARE_ACKNOWLEDGER (tie);
-  DECLARE_ACKNOWLEDGER (tab_note_head);
-  void process_acknowledged ();
+  void acknowledge_glissando (Grob_info);
+  void acknowledge_slur (Grob_info);
+  void acknowledge_tab_note_head (Grob_info);
 
   void stop_translation_timestep ();
 };
 
-Tab_tie_follow_engraver::Tab_tie_follow_engraver ()
+Tab_tie_follow_engraver::Tab_tie_follow_engraver (Context *c)
+  : Engraver (c)
 {
 }
 
 void
-Tab_tie_follow_engraver::acknowledge_tie (Grob_info info)
+Tab_tie_follow_engraver::acknowledge_glissando (Grob_info info)
 {
-   ties_.push_back (info.grob ());
+  glissandi_.push_back (info.spanner ());
 }
 
 void
 Tab_tie_follow_engraver::acknowledge_tab_note_head (Grob_info info)
 {
-  note_heads_.push_back (info.grob ());
+  note_heads_.push_back (info.item ());
 }
 
 void
-Tab_tie_follow_engraver::process_acknowledged ()
+Tab_tie_follow_engraver::acknowledge_slur (Grob_info info)
 {
-  if (ties_.size () && note_heads_.size ())
+  slurs_.push_back (info.spanner ());
+}
+
+void
+Tab_tie_follow_engraver::stop_translation_timestep ()
+{
+  for (vsize k = 0; k < note_heads_.size (); k++)
     {
-      SCM proc = ly_lily_module_constant ("ly:spanner-bound");
-      for (vsize i = 0; i < ties_.size (); i++)
+      bool spanner_start = false;
+      for (vsize j = 0; j < slurs_.size (); j++)
         {
-          SCM right_bound = scm_call_2 (proc,
-                                        ties_[i]->self_scm (),
-                                        scm_from_int (RIGHT));
-
-          for (vsize k = 0; k < note_heads_.size (); k++)
-            if (right_bound == note_heads_[k]->self_scm ())
-              note_heads_[k]->set_property ("tie-follow", SCM_BOOL_T);
-         }
+          Item *left_item = slurs_[j]->get_bound (LEFT);
+          if (left_item)
+            {
+              SCM left_cause = left_item->get_property ("cause");
+              Item *slur_cause = unsmob<Item> (left_cause);
+              if (slur_cause == note_heads_[k])
+                {
+                  note_heads_[k]->set_property ("span-start", SCM_BOOL_T);
+                  spanner_start = true;
+                  break;
+                }
+            }
+        }
+      if (!spanner_start)
+        for (vsize j = 0; j < glissandi_.size (); j++)
+          {
+            Item *left_bound = glissandi_[j]->get_bound (LEFT);
+            if (left_bound == note_heads_[k])
+              {
+                note_heads_[k]->set_property ("span-start", SCM_BOOL_T);
+                break;
+              }
+          }
     }
+  slurs_.clear ();
+  glissandi_.clear ();
+  note_heads_.clear ();
 }
 
+
 void
-Tab_tie_follow_engraver::stop_translation_timestep ()
+Tab_tie_follow_engraver::boot ()
 {
-  ties_.clear ();
-  note_heads_.clear();
+  ADD_ACKNOWLEDGER (Tab_tie_follow_engraver, slur);
+  ADD_ACKNOWLEDGER (Tab_tie_follow_engraver, glissando);
+  ADD_ACKNOWLEDGER (Tab_tie_follow_engraver, tab_note_head);
 }
 
-ADD_ACKNOWLEDGER (Tab_tie_follow_engraver, tie);
-ADD_ACKNOWLEDGER (Tab_tie_follow_engraver, tab_note_head);
-
 ADD_TRANSLATOR (Tab_tie_follow_engraver,
-               /* doc */
-               "Adjust TabNoteHead properties when a tie is followed"
-               " by a slur or glissando.",
+                /* doc */
+                "Adjust TabNoteHead properties when a tie is followed"
+                " by a slur or glissando.",
 
-               /* create */
-               " ",
+                /* create */
+                " ",
 
-               /* read */
+                /* read */
                 " ",
 
-               /* write */
+                /* write */
                 " "
-                );
-
+               );