]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/arpeggio-engraver.cc
Run grand-replace (issue 3765)
[lilypond.git] / lily / arpeggio-engraver.cc
index d71064c7c69fe242db79471f5fcaec3eec152510..d2d1ed67b458a21b9a5890f4c738eab4982c6238 100644 (file)
-/*   
-  arpeggio-engraver.cc -- implement Arpeggio_engraver
-  
-  source file of the GNU LilyPond music typesetter
-  
-  (c) 2000--2005 Jan Nieuwenhuizen <janneke@gnu.org>
- */
+/*
+  This file is part of LilyPond, the GNU music typesetter.
+
+  Copyright (C) 2000--2014 Jan Nieuwenhuizen <janneke@gnu.org>
+
+  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 "group-interface.hh"
+
 #include "arpeggio.hh"
-#include "stem.hh"
+#include "item.hh"
+#include "note-column.hh"
+#include "pointer-group-interface.hh"
 #include "rhythmic-head.hh"
+#include "separation-item.hh"
 #include "side-position-interface.hh"
-#include "note-column.hh"
+#include "stem.hh"
+#include "stream-event.hh"
+
+#include "translator.icc"
 
 class Arpeggio_engraver : public Engraver
 {
 public:
   TRANSLATOR_DECLARATIONS (Arpeggio_engraver);
-  
+
+  void acknowledge_stem (Grob_info);
+  void acknowledge_rhythmic_head (Grob_info);
+  void acknowledge_note_column (Grob_info);
+
 protected:
-  virtual void acknowledge_grob (Grob_info);
-  virtual void process_music ();
-  virtual void stop_translation_timestep ();
-  virtual bool try_music (Music *);
+  void process_music ();
+  void stop_translation_timestep ();
+  DECLARE_TRANSLATOR_LISTENER (arpeggio);
 private:
-  Item *arpeggio_; 
-  Music *arpeggio_req_;
+  Item *arpeggio_;
+  Stream_event *arpeggio_event_;
 };
 
 Arpeggio_engraver::Arpeggio_engraver ()
 {
   arpeggio_ = 0;
-  arpeggio_req_ = 0;
+  arpeggio_event_ = 0;
 }
 
-bool
-Arpeggio_engraver::try_music (Music *m)
+IMPLEMENT_TRANSLATOR_LISTENER (Arpeggio_engraver, arpeggio);
+void Arpeggio_engraver::listen_arpeggio (Stream_event *ev)
 {
-  if (!arpeggio_req_)
-    {
-      arpeggio_req_ = m;
-    }
-  return true;
+  ASSIGN_EVENT_ONCE (arpeggio_event_, ev);
 }
 
 void
-Arpeggio_engraver::acknowledge_grob (Grob_info info)
+Arpeggio_engraver::acknowledge_stem (Grob_info info)
 {
   if (arpeggio_)
     {
-      if (Stem::has_interface (info.grob_))
-       {
-         if (!arpeggio_->get_parent  (Y_AXIS))
-           arpeggio_->set_parent (info.grob_, Y_AXIS);
-      
-         Pointer_group_interface::add_grob (arpeggio_,
-                                            ly_symbol2scm ("stems"),
-                                            info.grob_);
-       }
-      
-      /*
-       We can't catch local key items (accidentals) from Voice context,
-       see Local_key_engraver
-      */
-      else if (Rhythmic_head::has_interface (info.grob_))
-       {
-         Side_position_interface::add_support (arpeggio_, info.grob_);
-       }
-      else if (Note_column::has_interface (info.grob_ ))
-       {
-         info.grob_->set_property ("arpeggio", arpeggio_->self_scm ());
-       }
+      if (!arpeggio_->get_parent (Y_AXIS))
+        arpeggio_->set_parent (info.grob (), Y_AXIS);
+
+      Pointer_group_interface::add_grob (arpeggio_,
+                                         ly_symbol2scm ("stems"),
+                                         info.grob ());
     }
 }
+void
+Arpeggio_engraver::acknowledge_rhythmic_head (Grob_info info)
+{
+  if (arpeggio_)
+
+    /*
+      We can't catch local key items (accidentals) from Voice context,
+      see Local_key_engraver
+    */
+    Side_position_interface::add_support (arpeggio_, info.grob ());
+}
+
+void
+Arpeggio_engraver::acknowledge_note_column (Grob_info info)
+{
+  if (arpeggio_)
+    Separation_item::add_conditional_item (info.grob (), arpeggio_);
+}
 
 void
 Arpeggio_engraver::process_music ()
 {
-  if (arpeggio_req_)
+  if (arpeggio_event_)
     {
-      arpeggio_ = make_item ("Arpeggio",arpeggio_req_->self_scm ());
+      arpeggio_ = make_item ("Arpeggio", arpeggio_event_->self_scm ());
     }
 }
 
@@ -88,13 +106,23 @@ void
 Arpeggio_engraver::stop_translation_timestep ()
 {
   arpeggio_ = 0;
-  arpeggio_req_ = 0;
+  arpeggio_event_ = 0;
 }
 
+ADD_ACKNOWLEDGER (Arpeggio_engraver, stem);
+ADD_ACKNOWLEDGER (Arpeggio_engraver, rhythmic_head);
+ADD_ACKNOWLEDGER (Arpeggio_engraver, note_column);
+
 ADD_TRANSLATOR (Arpeggio_engraver,
-/* descr */       "Generate an Arpeggio from a Arpeggio_req",
-/* creats*/       "Arpeggio",
-/* accepts */     "arpeggio-event",
-/* acks  */       "stem-interface rhythmic-head-interface note-column-interface",
-/* reads */       "",
-/* write */       "");
+                /* doc */
+                "Generate an Arpeggio symbol.",
+
+                /* create */
+                "Arpeggio",
+
+                /* read */
+                "",
+
+                /* write */
+                ""
+               );