]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/timing-engraver.cc
release: 1.3.92
[lilypond.git] / lily / timing-engraver.cc
index 3fa208f15d6269026d7a76f5408a104a6f4fcbe1..c727c5889625c2aab8410811bd2b51e29ee5e4d2 100644 (file)
@@ -3,30 +3,64 @@
 
   source file of the GNU LilyPond music typesetter
 
-  (c)  1997--1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+  (c)  1997--2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
 */
+#include <iostream.h>
 
-#include "score-engraver.hh"
-#include "timing-engraver.hh"
+#include "translator-group.hh"
 #include "command-request.hh"
 #include "score-element-info.hh"
 #include "multi-measure-rest.hh"
+#include "timing-translator.hh"
+#include "engraver.hh"
 
-void
-Timing_engraver::fill_staff_info (Staff_info &inf)
-{
-  inf.time_C_ = &time_;
-}
-
+/**
+  Do time bookkeeping
+ */
+class Timing_engraver : public Timing_translator, public Engraver
+{   
+  Bar_req * bar_req_l_;
+protected:
+  virtual bool do_try_music (Music * );
+  virtual void do_post_move_processing ();
+  virtual void do_process_music ();
+  virtual void do_pre_move_processing ();
+public:
+  VIRTUAL_COPY_CONS(Translator);
+};
 
 ADD_THIS_TRANSLATOR(Timing_engraver);
 
-
 void
 Timing_engraver::do_post_move_processing( )
 {
   bar_req_l_ = 0;
   Timing_translator::do_post_move_processing ();
+
+  SCM nonauto = get_property ("barNonAuto");
+
+  SCM which = get_property ("whichBar");
+  if (!gh_string_p (which))
+    which = now_mom () ? SCM_EOL : ly_str02scm ("|");
+  
+  if (!gh_string_p (which) && !to_boolean (nonauto))
+    {
+      SCM always = get_property ("barAlways");
+      if (!measure_position ()
+         || (to_boolean (always)))
+       {
+         which=get_property ("defaultBarType" );
+       }
+    }
+
+  daddy_trans_l_->set_property ("whichBar", which);
+}
+
+void
+Timing_engraver::do_pre_move_processing ()
+{
+  Timing_translator::do_pre_move_processing ();
+  daddy_trans_l_->set_property ("whichBar", SCM_EOL);  
 }
 
 bool
@@ -34,7 +68,7 @@ Timing_engraver::do_try_music (Music*m)
 {
   if (Bar_req  * b= dynamic_cast <Bar_req *> (m))
     {
-      if (bar_req_l_ && bar_req_l_->equal_b (b)) // huh?
+      if (bar_req_l_ && !bar_req_l_->equal_b (b)) 
        return false;
       
       bar_req_l_ = b;
@@ -44,26 +78,10 @@ Timing_engraver::do_try_music (Music*m)
   return Timing_translator::do_try_music (m);
 }
 
-
-String
-Timing_engraver::which_bar ()
+void
+Timing_engraver::do_process_music ()
 {
-  if (!bar_req_l_)
-    {
-      if (!now_mom ())
-       return "|";
-
-      Scalar nonauto = get_property ("barNonAuto", 0);
-      if (!nonauto.to_bool ())
-       {
-         Scalar always = get_property ("barAlways", 0);
-         if (!time_.whole_in_measure_ || always.to_bool ())
-           return get_property ("defaultBarType" ,0);
-       }
-      return "";
-    }
-  else
-    {
-      return bar_req_l_->type_str_;
-    }
+  if (bar_req_l_)
+    daddy_trans_l_->set_property ("whichBar", bar_req_l_->get_mus_property ("type"));
 }
+