]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/phrasing-slur-engraver.cc
Run grand-replace (issue 3765)
[lilypond.git] / lily / phrasing-slur-engraver.cc
index 8495817d09591073c68a63b195710b83202e009f..ef11e66ac3516da74c48741a40305fdf37556f11 100644 (file)
 /*
-  phrasing-slur-engraver.cc -- implement Phrasing_slur_engraver
+  This file is part of LilyPond, the GNU music typesetter.
 
-  (c)  1997--2002 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+  Copyright (C) 1997--2014 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 "musical-request.hh"
-#include "slur.hh"
-#include "warn.hh"
-#include "note-column.hh"
-#include "translator-group.hh"
 #include "engraver.hh"
+
+#include "context.hh"
+#include "directional-element-interface.hh"
+#include "international.hh"
+#include "note-column.hh"
+#include "slur.hh"
+#include "slur-proto-engraver.hh"
 #include "spanner.hh"
+#include "stream-event.hh"
+#include "warn.hh"
 
-class Phrasing_slur_engraver : public Engraver
-{
-  Link_array<Span_req> requestses_;
-  Link_array<Span_req> new_phrasing_slur_reqs_;
-  Link_array<Grob> phrasing_slur_l_stack_;
-  Link_array<Grob> end_phrasing_slurs_;
-  Moment last_start_;
+#include "translator.icc"
 
+class Phrasing_slur_engraver : public Slur_proto_engraver
+{
 protected:
-  virtual bool try_music (Music*);
-  virtual void acknowledge_grob (Grob_info);
-  virtual void stop_translation_timestep ();
-  virtual void start_translation_timestep ();
-  virtual void finalize ();
-  virtual void process_acknowledged_grobs ();
+  DECLARE_TRANSLATOR_LISTENER (phrasing_slur);
+  DECLARE_ACKNOWLEDGER (slur);
 
 public:
-  TRANSLATOR_DECLARATIONS(Phrasing_slur_engraver);
-  
+  TRANSLATOR_DECLARATIONS (Phrasing_slur_engraver);
 };
 
-Phrasing_slur_engraver::Phrasing_slur_engraver ()
-{
-  last_start_ = Moment (-1);
-}
-
-bool
-Phrasing_slur_engraver::try_music (Music *req)
+Phrasing_slur_engraver::Phrasing_slur_engraver () :
+  Slur_proto_engraver (0, "PhrasingSlur", "phrasing slur", "phrasing-slur-event")
 {
-  if (Span_req *sl = dynamic_cast <Span_req *> (req))
-    {
-      String t =  ly_scm2string (sl->get_mus_property ("span-type"));
-      if (t == "abort")
-       {
-         for (int i = 0; i < phrasing_slur_l_stack_.size (); i++)
-           {
-             phrasing_slur_l_stack_[i]->suicide ();
-           }
-         phrasing_slur_l_stack_.clear ();
-         for (int i = 0; i < end_phrasing_slurs_.size (); i++)
-           {
-             end_phrasing_slurs_[i]->suicide ();
-           }
-         end_phrasing_slurs_.clear ();
-         requestses_.clear ();
-         new_phrasing_slur_reqs_.clear ();
-       }
-      else if (t == "phrasing-slur")
-       {
-         /*
-           Let's not start more than one phrasing slur per moment.
-          */
-         if (sl->get_span_dir () == START)
-           {
-             if (now_mom () > last_start_)
-               {
-                 new_phrasing_slur_reqs_.push (sl);
-                 last_start_ = now_mom ();
-                 return true;
-               }
-           }
-         else
-           {
-             new_phrasing_slur_reqs_.push (sl);
-             return true;
-           }
-       }
-    }
-  return false;
 }
 
+IMPLEMENT_TRANSLATOR_LISTENER (Phrasing_slur_engraver, phrasing_slur);
 void
-Phrasing_slur_engraver::acknowledge_grob (Grob_info info)
+Phrasing_slur_engraver::listen_phrasing_slur (Stream_event *ev)
 {
-  if (Note_column::has_interface (info.grob_))
-    {
-      Grob *e =info.grob_;
-      for (int i = 0; i < phrasing_slur_l_stack_.size (); i++)
-       Slur::add_column (phrasing_slur_l_stack_[i], e);
-      for (int i = 0; i < end_phrasing_slurs_.size (); i++)
-       Slur::add_column (end_phrasing_slurs_[i], e);
-    }
+  internal_listen_slur (ev);
 }
 
 void
-Phrasing_slur_engraver::finalize ()
+Phrasing_slur_engraver::acknowledge_slur (Grob_info info)
 {
-  for (int i = 0; i < phrasing_slur_l_stack_.size (); i++)
-    {
-#if 0
-      typeset_grob (phrasing_slur_l_stack_[i]);
-#else
-      /*
-       Let's not typeset unterminated stuff
-       */
-      phrasing_slur_l_stack_[i]->suicide ();
-#endif     
-    }
-  phrasing_slur_l_stack_.clear ();
-
-    for (int i=0; i < requestses_.size (); i++)
-      {
-       requestses_[i]->origin ()->warning (_ ("unterminated phrasing slur"));
-      }
+  acknowledge_extra_object (info);
 }
 
-void
-Phrasing_slur_engraver::process_acknowledged_grobs ()
-{
-  Link_array<Grob> start_phrasing_slurs;
-  for (int i=0; i< new_phrasing_slur_reqs_.size (); i++)
-    {
-      Span_req* phrasing_slur_req = new_phrasing_slur_reqs_[i];
-      // end phrasing slur: move the phrasing slur to other array
-      if (phrasing_slur_req->get_span_dir () == STOP)
-       {
-         if (phrasing_slur_l_stack_.empty ())
-           phrasing_slur_req->origin ()->warning (_f ("can't find start of phrasing slur"));
-         else
-           {
-             Grob* phrasing_slur = phrasing_slur_l_stack_.pop ();
-             end_phrasing_slurs_.push (phrasing_slur);
-             requestses_.pop ();
-           }
-       }
-      else  if (phrasing_slur_req->get_span_dir () == START)
-       {
-         // push a new phrasing_slur onto stack.
-         // (use temp. array to wait for all phrasing_slur STOPs)
-         Grob* phrasing_slur = new Spanner (get_property ("PhrasingSlur"));
-         Slur::set_interface (phrasing_slur); // can't remove.
-         start_phrasing_slurs.push (phrasing_slur);
-         requestses_.push (phrasing_slur_req);
-         announce_grob(phrasing_slur, phrasing_slur_req->self_scm());
-       }
-    }
-  for (int i=0; i < start_phrasing_slurs.size (); i++)
-    phrasing_slur_l_stack_.push (start_phrasing_slurs[i]);
-  new_phrasing_slur_reqs_.clear ();
-}
-
-void
-Phrasing_slur_engraver::stop_translation_timestep ()
-{
-  for (int i = 0; i < end_phrasing_slurs_.size (); i++)
-    {
-      typeset_grob (end_phrasing_slurs_[i]);
-    }
-  end_phrasing_slurs_.clear ();
-}
-
-void
-Phrasing_slur_engraver::start_translation_timestep ()
-{
-  new_phrasing_slur_reqs_.clear ();
-}
-
-
-
-ENTER_DESCRIPTION(Phrasing_slur_engraver,
-/* descr */       "Print phrasing slurs. Similar to Slur_engraver",
-/* creats*/       "PhrasingSlur",
-/* accepts */     "general-music",
-/* acks  */      "note-column-interface",
-/* reads */       "slurMelismaBusy",
-/* write */       "");
+ADD_ACKNOWLEDGER (Phrasing_slur_engraver, inline_accidental);
+ADD_ACKNOWLEDGER (Phrasing_slur_engraver, fingering)
+ADD_ACKNOWLEDGER (Phrasing_slur_engraver, note_column);
+ADD_ACKNOWLEDGER (Phrasing_slur_engraver, slur);
+ADD_ACKNOWLEDGER (Phrasing_slur_engraver, script);
+ADD_ACKNOWLEDGER (Phrasing_slur_engraver, dots);
+ADD_ACKNOWLEDGER (Phrasing_slur_engraver, text_script);
+ADD_END_ACKNOWLEDGER (Phrasing_slur_engraver, tie);
+ADD_ACKNOWLEDGER (Phrasing_slur_engraver, tuplet_number);
+
+ADD_TRANSLATOR (Phrasing_slur_engraver,
+                /* doc */
+                "Print phrasing slurs.  Similar to @ref{Slur_engraver}.",
+
+                /* create */
+                "PhrasingSlur ",
+
+                /* read */
+                "",
+
+                /* write */
+                ""
+               );