]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/dynamic-engraver.cc
* lily/pfb.cc (LY_DEFINE): ly:ttf->pfa, new function.
[lilypond.git] / lily / dynamic-engraver.cc
index 76dc123384b75fca2f8a6a088bdb1dae986efb1d..45c9c355c5807135a6d9c56e2aff1d04f37f5cef 100644 (file)
@@ -3,7 +3,7 @@
 
   source file of the GNU LilyPond music typesetter
 
-  (c) 1997--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+  (c) 1997--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
 */
 
 #include "axis-group-interface.hh"
 #include "dimensions.hh"
 #include "directional-element-interface.hh"
 #include "engraver.hh"
-#include "event.hh"
-#include "group-interface.hh"
 #include "hairpin.hh"
 #include "interval.hh"
-#include "item.hh"
-#include "new-slur.hh"
 #include "note-column.hh"
 #include "paper-column.hh"
 #include "script-interface.hh"
@@ -45,7 +41,6 @@ class Dynamic_engraver : public Engraver
 {
   Item *script_;
   Spanner *line_spanner_;
-  Spanner *slur_;
   Spanner *cresc_;
 
   Spanner *finished_line_spanner_;
@@ -77,12 +72,11 @@ protected:
 Dynamic_engraver::Dynamic_engraver ()
 {
   script_ = 0;
-  slur_ = 0;
   finished_cresc_ = 0;
   line_spanner_ = 0;
   finished_line_spanner_ = 0;
   current_cresc_ev_ = 0;
-  cresc_ =0;
+  cresc_ = 0;
 
   script_ev_ = 0;
   accepted_spanreqs_drul_[START] = 0;
@@ -136,7 +130,6 @@ Dynamic_engraver::process_music ()
     Note: line-spanner must always have at least same duration
     as (de)crecsendo, b.o. line-breaking.
   */
-
   
 
   /*
@@ -223,9 +216,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));
@@ -248,7 +251,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) || scm_is_pair (s))
                {
                  cresc_->set_property ("edge-text",
                                        scm_cons (s, scm_makfrom0str ("")));
@@ -257,13 +260,13 @@ Dynamic_engraver::process_music ()
                }
            }
 
-         cresc_->set_bound (LEFT, script_
-                            ? script_
-                            : unsmob_grob (get_property ("currentMusicalColumn")));
-
+         if (script_)
+           {
+             cresc_->set_bound (LEFT, script_);
+             add_bound_item (line_spanner_, cresc_->get_bound (LEFT));
+           }
+         
          Axis_group_interface::add_element (line_spanner_, cresc_);
-
-         add_bound_item (line_spanner_, cresc_->get_bound (LEFT));
        }
     }
 }
@@ -274,12 +277,17 @@ Dynamic_engraver::stop_translation_timestep ()
   typeset_all ();
   if (!current_cresc_ev_)
     {
-      
       finished_line_spanner_ = line_spanner_;
       line_spanner_ = 0;
       typeset_all ();
     }
 
+  if (cresc_ && !cresc_->get_bound (LEFT))
+    {
+      cresc_->set_bound (LEFT, unsmob_grob (get_property ("currentMusicalColumn")));
+      add_bound_item (line_spanner_, cresc_->get_bound (LEFT));
+    }
+  
   script_ev_ = 0;
   accepted_spanreqs_drul_[START] = 0;
   accepted_spanreqs_drul_[STOP] = 0;
@@ -313,27 +321,6 @@ Dynamic_engraver::finalize ()
 void
 Dynamic_engraver::typeset_all ()
 {
-  /* Simplistic slur collision handling.  This fixes simple collisions
-     like
-     
-         a\p( b)
-
-     which are unacceptable, but it most probably breaks for more
-     interesting cases.  Maybe make a new colission engraver.  */
-  if (finished_line_spanner_
-      && slur_
-      && get_slur_dir (slur_) == get_grob_direction (finished_line_spanner_)
-      && !intersection (slur_->spanned_rank_iv (),
-                       finished_line_spanner_->spanned_rank_iv ()).is_empty ())
-    {
-      Real ss = Staff_symbol_referencer::staff_space (finished_line_spanner_);
-      Real pad = robust_scm2double (finished_line_spanner_
-                                   ->get_property ("padding"), 0);
-      /* FIXME: 1ss padding hardcoded */
-      finished_line_spanner_->set_property ("padding",
-                                           scm_make_real (pad + ss));
-    }
-
   if (finished_cresc_)
     {
       if (!finished_cresc_->get_bound (RIGHT))
@@ -346,7 +333,7 @@ Dynamic_engraver::typeset_all ()
            add_bound_item (finished_line_spanner_,
                            finished_cresc_->get_bound (RIGHT));
        }
-      finished_cresc_ =0;
+      finished_cresc_ = 0;
     }
   
   script_ = 0;
@@ -397,16 +384,25 @@ Dynamic_engraver::acknowledge_grob (Grob_info info)
          /* Don't refill killed spanner */
          && line_spanner_->is_live ())
        {
-         Side_position_interface::add_support (line_spanner_,info.grob_);
-         add_bound_item (line_spanner_,dynamic_cast<Item*> (info.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 (info.grob_->get_property ("note-heads"));
-         if (ly_c_pair_p (head))
-           script_->set_parent (unsmob_grob (ly_car (head)),  X_AXIS);
+         if (scm_is_pair (head))
+           script_->set_parent (unsmob_grob (scm_car (head)),  X_AXIS);
+       }
+
+
+
+      if (cresc_ && !cresc_->get_bound (LEFT))
+       {
+         cresc_->set_bound (LEFT, info.grob_);
+         add_bound_item (line_spanner_, cresc_->get_bound (LEFT));
        }
+        
     }
   else if (Script_interface::has_interface (info.grob_) && script_)
     {
@@ -417,16 +413,14 @@ Dynamic_engraver::acknowledge_grob (Grob_info info)
 
        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")))
+      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 (New_slur::has_interface (info.grob_))
-    slur_ = dynamic_cast<Spanner*> (info.grob_);
 }
 
-ENTER_DESCRIPTION (Dynamic_engraver,
+ADD_TRANSLATOR (Dynamic_engraver,
 /* descr */       
 "This engraver creates hairpins, dynamic texts, and their vertical\n"
 "alignments.  The symbols are collected onto a DynamicLineSpanner grob\n"
@@ -435,6 +429,6 @@ ENTER_DESCRIPTION (Dynamic_engraver,
                  
 /* creats*/       "DynamicLineSpanner DynamicText Hairpin TextSpanner",
 /* accepts */     "absolute-dynamic-event crescendo-event decrescendo-event",
-/* acks  */      "note-column-interface script-interface new-slur-interface",
+/* acks  */      "note-column-interface script-interface",
 /* reads */       "",
 /* write */       "");