]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/new-dynamic-engraver.cc
Merge branch 'lilypond/translation' of ssh://jomand@git.sv.gnu.org/srv/git/lilypond
[lilypond.git] / lily / new-dynamic-engraver.cc
index 990dba04a0486ea91b844730930545f3f07f6dda..54aa8a8c6df363dca7a4ec59dfd95c0d2967cf53 100644 (file)
@@ -3,20 +3,22 @@
   
   source file of the GNU LilyPond music typesetter
   
-  (c) 2008 Han-Wen Nienhuys <hanwen@lilypond.org>
+  (c) 2008--2009 Han-Wen Nienhuys <hanwen@lilypond.org>
   
 */
 
 
 #include "engraver.hh"
 
+#include "hairpin.hh"
+#include "international.hh"
 #include "item.hh"
-#include "pointer-group-interface.hh"
-#include "text-interface.hh"
 #include "note-column.hh"
+#include "pointer-group-interface.hh"
 #include "self-alignment-interface.hh"
 #include "spanner.hh"
 #include "stream-event.hh"
+#include "text-interface.hh"
 
 #include "translator.icc"
 
@@ -31,6 +33,8 @@ protected:
   virtual void process_music ();
   virtual void stop_translation_timestep ();
 private:
+  SCM get_property_setting (Stream_event *evt, char const *evprop, char const *ctxprop);
+
   Drul_array<Stream_event *> accepted_spanevents_drul_;
   Spanner *current_spanner_;
   Spanner *finished_spanner_;
@@ -66,6 +70,14 @@ New_dynamic_engraver::listen_span_dynamic (Stream_event *ev)
   ASSIGN_EVENT_ONCE (accepted_spanevents_drul_[d], ev);
 }
 
+SCM
+New_dynamic_engraver::get_property_setting (Stream_event *evt, char const *evprop, char const *ctxprop)
+{
+  SCM spanner_type = evt->get_property (evprop);
+  if (spanner_type == SCM_EOL)
+    spanner_type = get_property (ctxprop);
+  return spanner_type;
+}
 
 void
 New_dynamic_engraver::process_music ()
@@ -103,7 +115,8 @@ New_dynamic_engraver::process_music ()
          return;
        }
       
-      SCM cresc_type = get_property ((start_type + "Spanner").c_str ());
+      SCM cresc_type = get_property_setting (current_span_event_, "span-type",
+                                       (start_type + "Spanner").c_str ());
 
       if (cresc_type == ly_symbol2scm ("text"))
        {
@@ -111,7 +124,8 @@ New_dynamic_engraver::process_music ()
            = make_spanner ("DynamicTextSpanner",
                            accepted_spanevents_drul_[START]->self_scm ());
 
-         SCM text = get_property ((start_type + "Text").c_str ());
+         SCM text = get_property_setting (current_span_event_, "span-text",
+                                       (start_type + "Text").c_str ());
          if (Text_interface::is_markup (text))
            {
              current_spanner_->set_property ("text", text);
@@ -122,9 +136,9 @@ New_dynamic_engraver::process_music ()
          if (cresc_type != ly_symbol2scm ("hairpin"))
            {
              // Fixme: should put value in error message.
-             ly_display_scm (cresc_type);
+             string as_string = ly_scm_write_string (cresc_type);
              current_span_event_
-               ->origin()->warning ("unknown crescendo style; defaulting to hairpin.");
+               ->origin()->warning (_f ("unknown crescendo style: %s\ndefaulting to hairpin.", as_string.c_str()));
            }
          current_spanner_ = make_spanner ("Hairpin",
                                           current_span_event_->self_scm ());
@@ -152,12 +166,14 @@ New_dynamic_engraver::process_music ()
       if (current_spanner_)
        {
          current_spanner_->set_bound (LEFT, script_);
-         set_nested_property (current_spanner_,
-                              scm_list_3 (ly_symbol2scm ("bound-details"),
-                                          ly_symbol2scm ("left"),
-                                          ly_symbol2scm ("attach-dir")
-                                          ),
-                              scm_from_int (RIGHT));
+
+         if (!Hairpin::has_interface (current_spanner_))
+           set_nested_property (current_spanner_,
+                                scm_list_3 (ly_symbol2scm ("bound-details"),
+                                            ly_symbol2scm ("left"),
+                                            ly_symbol2scm ("attach-dir")
+                                            ),
+                                scm_from_int (RIGHT));
 
        }
     }
@@ -212,11 +228,14 @@ ADD_TRANSLATOR (New_dynamic_engraver,
                /* create */
                "DynamicTextSpanner "
                "DynamicText "
-               "Hairpin "
-               "TextSpanner ",
+               "Hairpin ",
 
                /* read */
-               "currentMusicalColumn ",
+               "crescendoSpanner "
+               "crescendoText "
+               "currentMusicalColumn "
+               "decrescendoSpanner "
+               "decrescendoText ",
 
                /* write */
                ""