]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/dynamic-engraver.cc
* lily/hairpin.cc: lengthen hairpin if space is available.
[lilypond.git] / lily / dynamic-engraver.cc
index 7f55c7ba6b0607c6922f78a44ee3ed5b47a1c1c7..71dfcce857cadd90f9e1be69bd26eb58b92d7110 100644 (file)
@@ -5,20 +5,24 @@
 
   (c) 1997--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
 */
-#include "warn.hh"
+
+#include "axis-group-interface.hh"
+#include "context.hh"
 #include "dimensions.hh"
-#include "hairpin.hh"
-#include "event.hh"
-#include "paper-column.hh"
-#include "note-column.hh"
-#include "item.hh"
-#include "side-position-interface.hh"
+#include "directional-element-interface.hh"
 #include "engraver.hh"
+#include "event.hh"
 #include "group-interface.hh"
-#include "directional-element-interface.hh"
-#include "context.hh"
-#include "axis-group-interface.hh"
+#include "hairpin.hh"
+#include "interval.hh"
+#include "item.hh"
+#include "slur.hh"
+#include "note-column.hh"
+#include "paper-column.hh"
 #include "script-interface.hh"
+#include "side-position-interface.hh"
+#include "staff-symbol-referencer.hh"
+#include "warn.hh"
 
 /*
   TODO:
@@ -39,8 +43,9 @@
  */
 class Dynamic_engraver : public Engraver
 {
-  Item * script_;
+  Item *script_;
   Spanner *line_spanner_;
+  Spanner *slur_;
   Spanner *cresc_;
 
   Spanner *finished_line_spanner_;
@@ -72,6 +77,7 @@ protected:
 Dynamic_engraver::Dynamic_engraver ()
 {
   script_ = 0;
+  slur_ = 0;
   finished_cresc_ = 0;
   line_spanner_ = 0;
   finished_line_spanner_ = 0;
@@ -84,7 +90,7 @@ Dynamic_engraver::Dynamic_engraver ()
 }
 
 bool
-Dynamic_engraver::try_music (Music * m)
+Dynamic_engraver::try_music (Music *m)
 {
   if (m->is_mus_type ("absolute-dynamic-event"))
     {
@@ -217,9 +223,19 @@ Dynamic_engraver::process_music ()
            start_type = "crescendo";
          
          SCM s = get_property ((start_type + "Spanner").to_str0 ());
-         if (!ly_c_symbol_p (s) || s == ly_symbol2scm ("hairpin"))
+         if (!scm_is_symbol (s) || s == ly_symbol2scm ("hairpin"))
            {
              cresc_  = make_spanner ("Hairpin", accepted_spanreqs_drul_[START]->self_scm ());
+             if (finished_cresc_)
+               {
+                 Pointer_group_interface::add_grob (finished_cresc_,
+                                                    ly_symbol2scm ("adjacent-hairpins"),
+                                                    cresc_);
+                 
+                 Pointer_group_interface::add_grob (cresc_,
+                                                    ly_symbol2scm ("adjacent-hairpins"),
+                                                    finished_cresc_);
+               }
              cresc_->set_property ("grow-direction",
                                    scm_int2num ((start_type == "crescendo")
                                                 ? BIGGER : SMALLER));
@@ -242,7 +258,7 @@ Dynamic_engraver::process_music ()
              /*
                FIXME: use get_markup () to check type.
              */
-             if (ly_c_string_p (s) || ly_c_pair_p (s))
+             if (scm_is_string (s) || ly_c_pair_p (s))
                {
                  cresc_->set_property ("edge-text",
                                        scm_cons (s, scm_makfrom0str ("")));
@@ -268,8 +284,9 @@ Dynamic_engraver::stop_translation_timestep ()
   typeset_all ();
   if (!current_cresc_ev_)
     {
+      
       finished_line_spanner_ = line_spanner_;
-      line_spanner_ =0;
+      line_spanner_ = 0;
       typeset_all ();
     }
 
@@ -305,7 +322,7 @@ Dynamic_engraver::finalize ()
 
 void
 Dynamic_engraver::typeset_all ()
-{  
+{
   if (finished_cresc_)
     {
       if (!finished_cresc_->get_bound (RIGHT))
@@ -313,7 +330,7 @@ Dynamic_engraver::typeset_all ()
          finished_cresc_->set_bound (RIGHT, script_
                                      ? script_
                                      : unsmob_grob (get_property ("currentMusicalColumn")));
-
+         
          if (finished_line_spanner_)
            add_bound_item (finished_line_spanner_,
                            finished_cresc_->get_bound (RIGHT));
@@ -358,45 +375,44 @@ Dynamic_engraver::typeset_all ()
 }
 
 void
-Dynamic_engraver::acknowledge_grob (Grob_info i)
+Dynamic_engraver::acknowledge_grob (Grob_info info)
 {
   if (!line_spanner_)
-    return ;
-  
-  if (Note_column::has_interface (i.grob_))
+    return;
+
+  if (Note_column::has_interface (info.grob_))
     {
       if (line_spanner_
          /* Don't refill killed spanner */
          && line_spanner_->is_live ())
        {
-         Side_position_interface::add_support (line_spanner_,i.grob_);
-         add_bound_item (line_spanner_,dynamic_cast<Item*> (i.grob_));
+         Side_position_interface::add_support (line_spanner_,info.grob_);
+         add_bound_item (line_spanner_,dynamic_cast<Item*> (info.grob_));
        }
 
       if (script_ && !script_->get_parent (X_AXIS))
        {
-         SCM head = scm_last_pair (i.grob_->get_property ("note-heads"));
+         SCM head = scm_last_pair (info.grob_->get_property ("note-heads"));
          if (ly_c_pair_p (head))
            script_->set_parent (unsmob_grob (ly_car (head)),  X_AXIS);
        }
-      
     }
-  else if (Script_interface::has_interface (i.grob_) && script_)
+  else if (Script_interface::has_interface (info.grob_) && script_)
     {
-      SCM p = i.grob_->get_property ("script-priority");
+      SCM p = info.grob_->get_property ("script-priority");
 
       /*
        UGH.
 
        DynamicText doesn't really have a script-priority field.
        */
-      if (ly_c_number_p (p)
-         && ly_scm2int (p) < ly_scm2int (script_->get_property ("script-priority")))
-       {
-         Side_position_interface::add_support (line_spanner_, i.grob_);
-
-       }
+      if (scm_is_number (p)
+         && scm_to_int (p)
+         < scm_to_int (script_->get_property ("script-priority")))
+       Side_position_interface::add_support (line_spanner_, info.grob_);
     }
+  else if (Slur::has_interface (info.grob_))
+    slur_ = dynamic_cast<Spanner*> (info.grob_);
 }
 
 ENTER_DESCRIPTION (Dynamic_engraver,
@@ -408,6 +424,6 @@ ENTER_DESCRIPTION (Dynamic_engraver,
                  
 /* creats*/       "DynamicLineSpanner DynamicText Hairpin TextSpanner",
 /* accepts */     "absolute-dynamic-event crescendo-event decrescendo-event",
-/* acks  */      "note-column-interface script-interface",
+/* acks  */      "note-column-interface script-interface slur-interface",
 /* reads */       "",
 /* write */       "");