]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/multi-measure-rest-engraver.cc
release: 1.2.6
[lilypond.git] / lily / multi-measure-rest-engraver.cc
index f1df3cf2e325b15013c0d317c8e24a2dfabdf919..51ff44654231651913b3ddc33fbe5a4ae4449007 100644 (file)
@@ -1,7 +1,7 @@
 /*
   multi_measure_rest-engraver.cc -- implement Multi_measure_rest_engraver
 
-  (c) 1998 Jan Nieuwenhuizen <janneke@gnu.org>
+  (c) 1998--1999 Jan Nieuwenhuizen <janneke@gnu.org>
        Han-Wen Nienhuys <hanwen@cs.uu.nl>
 */
 
 #include "multi-measure-rest-engraver.hh"
 #include "score-column.hh"
 #include "time-description.hh"
-//#include "paper-score.hh"
-//#include "p-score.hh"
-//#include "paper-def.hh"
-//#include "main.hh"
-//#include "global-translator.hh"
 #include "bar.hh"
 
 
@@ -24,9 +19,11 @@ ADD_THIS_TRANSLATOR (Multi_measure_rest_engraver);
 Multi_measure_rest_engraver::Multi_measure_rest_engraver ()
 {
   start_measure_i_ = 0;
-  rest_stop_mom_ =0;
-  // rest_item_creation_mom_ = 0;
+  rest_moments_[START] =
+    rest_moments_[STOP] =0;
   multi_measure_req_l_ = 0;
+
+  lastrest_p_ =0;
   mmrest_p_ = 0;
 }
 
@@ -45,20 +42,28 @@ Multi_measure_rest_engraver::acknowledge_element (Score_element_info i)
 bool
 Multi_measure_rest_engraver::do_try_music (Music* req_l)
 {
- if (Multi_measure_rest_req *mr = dynamic_cast<Multi_measure_rest_req *> (req_l))
-   {
-     if (multi_measure_req_l_)
-       if (!multi_measure_req_l_->equal_b (mr)
-          || rest_start_mom_ != now_moment ())
-        return false;
-  
-     multi_measure_req_l_ = mr;
-     rest_start_mom_ = now_moment ();
-     
-     rest_stop_mom_ = rest_start_mom_ + multi_measure_req_l_->duration_.length ();
-     return true;
-   }
- return false;
+  Rhythmic_req *r=0;
+  if (Multi_measure_rest_req *mr = 
+      dynamic_cast<Multi_measure_rest_req *> (req_l))
+    r=mr;
+  else if (Repetitions_req *rr = 
+          dynamic_cast<Repetitions_req *> (req_l))
+    r=rr;
+  if (r)
+    {
+      if (multi_measure_req_l_)
+       if (!multi_measure_req_l_->equal_b (r)
+           || rest_moments_[START] != now_mom ())
+         return false;
+      
+      multi_measure_req_l_ = r;
+      rest_moments_[START] = now_mom ();
+      
+      rest_moments_[STOP] = rest_moments_[START] +
+       multi_measure_req_l_->duration_.length_mom ();
+      return true;
+    }
+  return false;
 }
 
 void
@@ -68,7 +73,9 @@ Multi_measure_rest_engraver::do_process_requests ()
     {
       Time_description const *time = get_staff_info().time_C_;
       mmrest_p_ = new Multi_measure_rest;
-      // rest_item_creation_mom_ = time->when_mom ();
+      if(dynamic_cast<Repetitions_req *> (multi_measure_req_l_))
+       mmrest_p_->set_elt_property (alt_symbol_scm_sym, 
+                                    ly_ch_C_to_scm ("scripts-repeatsign"));
       announce_element (Score_element_info (mmrest_p_, multi_measure_req_l_));
       start_measure_i_ = time->bars_i_;
     }
@@ -77,14 +84,17 @@ Multi_measure_rest_engraver::do_process_requests ()
 void
 Multi_measure_rest_engraver::do_pre_move_processing ()
 {
-  Moment now (now_moment ());
-  //urg lily dumps core if i want to let her print all (SkipBars=0) rests...
-#if 0
-  if (mmrest_p_ && (now >= rest_start_mom_) && (mmrest_p_->column_arr_.size () >= 2))
+  Moment now (now_mom ());
+  Time_description const *time = get_staff_info().time_C_;
+  if (mmrest_p_ && (now >= rest_moments_[START]) 
+    && !time->whole_in_measure_
+    && (mmrest_p_->column_arr_.size () >= 2))
     {
       typeset_element (mmrest_p_);
+      /*
+       must keep mmrest_p_ around to set measures_i_
+       */
     }
-#endif
   if (lastrest_p_)
     {
       typeset_element (lastrest_p_);
@@ -96,23 +106,17 @@ void
 Multi_measure_rest_engraver::do_post_move_processing ()
 {
   Time_description const *time = get_staff_info().time_C_;
-  Moment now (now_moment ());
+  Moment now (now_mom ());
 
-  /*
-   when our time's up, calculate the number of bars rest and
-   make way for new request
-   however, linger around a bit to catch this last column when
-   its announced
-   */
-  if (mmrest_p_ && (now >= rest_stop_mom_)) //&& (!time->whole_in_measure_))
+  if (mmrest_p_ && !time->whole_in_measure_)
     {
       lastrest_p_ = mmrest_p_;
       lastrest_p_->measures_i_ = time->bars_i_ - start_measure_i_;
-      //urg lily dumps core if i want to let her print all (SkipBars=0) rests...
-#if 0
-      if (lastrest_p_->column_arr_.size () >= 2)
-        lastrest_p_ = 0;
-#endif
+      mmrest_p_ = 0;
+    }
+
+  if (now >= rest_moments_[STOP])
+    {
       multi_measure_req_l_ = 0;
       mmrest_p_ = 0;
     }