]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/beam-engraver.cc
release: 1.1.30
[lilypond.git] / lily / beam-engraver.cc
index 3165cf66607c863992c029adb4a2182d3526ae41..d855e41dea98623217ba935724bc90f8e575d63c 100644 (file)
@@ -3,14 +3,14 @@
   
   source file of the GNU LilyPond music typesetter
   
-  (c) 1998 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+  (c) 1998--1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
   
  */
 
 #include "beam-engraver.hh"
 #include "musical-request.hh"
 #include "beam.hh"
-#include "grouping.hh"
+#include "rhythmic-grouping.hh"
 #include "stem.hh"
 #include "warn.hh"
 #include "time-description.hh"
@@ -22,6 +22,7 @@ Beam_engraver::Beam_engraver ()
   finished_grouping_p_ = 0;
   grouping_p_ =0;
   reqs_drul_[LEFT] = reqs_drul_[RIGHT] =0;
+  prev_start_req_ =0;
 }
 
 bool
@@ -29,7 +30,14 @@ Beam_engraver::do_try_music (Music *m)
 {
   if (Beam_req * c = dynamic_cast<Beam_req*>(m))
     {
-      reqs_drul_[c->spantype_] = c;
+      Direction d =c->spantype_;
+
+      if (d == STOP && !beam_p_)
+       {
+         m->warning (_ ("No Beam to end"));
+         return false;
+       }
+      reqs_drul_[d ] = c;
       return true;
     }
   return false;
@@ -42,7 +50,8 @@ Beam_engraver::do_process_requests ()
   if (reqs_drul_[STOP])
     {
       if (!beam_p_)
-       reqs_drul_[STOP]->warning (_("No beam to stop"));
+       reqs_drul_[STOP]->warning (_("No beam to end"));
+      prev_start_req_ =0;
       finished_beam_p_ = beam_p_;
       finished_grouping_p_ = grouping_p_;
 
@@ -52,6 +61,13 @@ Beam_engraver::do_process_requests ()
   
   if (reqs_drul_[START])
     {
+      if (beam_p_)
+       {
+         reqs_drul_[START]->warning (_ ("Already have a Beam"));
+         return;
+       }
+
+      prev_start_req_ = reqs_drul_[START];
       beam_p_ = new Beam;
       grouping_p_ = new Rhythmic_grouping;
 
@@ -63,19 +79,15 @@ Beam_engraver::do_process_requests ()
       if (prop.isnum_b ()) 
        beam_p_->quantisation_ = (Beam::Quantisation)(int)prop;
  
-      // silly try at interstaff beam
       // must set minVerticalAlign == maxVerticalAlign to get sane results
       // see input/test/beam-interstaff.ly
       prop = get_property ("minVerticalAlign", 0);
       if (prop.isnum_b ())
-       beam_p_->vertical_align_f_ = prop;
+       beam_p_->vertical_align_drul_[MIN] = prop;
 
       prop = get_property ("maxVerticalAlign", 0);
       if (prop.isnum_b ())
-       {
-         beam_p_->vertical_align_f_ += (Real)prop;
-         beam_p_->vertical_align_f_ /= (Real)2;
-       }
+       beam_p_->vertical_align_drul_[MAX] = prop;
 
       announce_element (Score_element_info (beam_p_, reqs_drul_[START]));
     }
@@ -115,9 +127,13 @@ void
 Beam_engraver::do_removal_processing ()
 {
   typeset_beam ();
-  finished_beam_p_ = beam_p_;
-  finished_grouping_p_ = grouping_p_;
-  typeset_beam ();
+  if (beam_p_)
+    {
+      prev_start_req_->warning (_ ("Unfinished beam"));
+      finished_beam_p_ = beam_p_;
+      finished_grouping_p_ = grouping_p_;
+      typeset_beam ();
+    }
 }
 
 void
@@ -133,9 +149,9 @@ Beam_engraver::acknowledge_element (Score_element_info info)
        Rhythmic_req *rhythmic_req = dynamic_cast <Rhythmic_req *> (info.req_l_);
        if (!rhythmic_req)
          {
-           String s=_("Stem must have Rhythmic structure.");
+           String s = _ ("Stem must have Rhythmic structure.");
            if (info.req_l_)
-             info.req_l_->warning(s);
+             info.req_l_->warning (s);
            else
              ::warning (s);
          
@@ -146,7 +162,7 @@ Beam_engraver::acknowledge_element (Score_element_info info)
        if (rhythmic_req->duration_.durlog_i_<= 2)
          {
            rhythmic_req->warning (_ ("stem doesn't fit in beam"));
-           reqs_drul_[LEFT]->warning (_("beam was started here"));
+           prev_start_req_->warning (_ ("beam was started here"));
            return;
          }
 
@@ -157,8 +173,8 @@ Beam_engraver::acknowledge_element (Score_element_info info)
 
        if (!grouping_p_->child_fit_b (start))
          {
-           String s (_("please fix me") + ": " 
-                     + _f ("stem at %s doesn't fit in beam", now_moment ().str ()));
+           String s (_ ("please fix me") + ": " 
+                     + _f ("stem at %s doesn't fit in beam", now_mom ().str ()));
 
            if (info.req_l_)
              info.req_l_->warning(s);
@@ -167,7 +183,7 @@ Beam_engraver::acknowledge_element (Score_element_info info)
          }
        else
          {
-           grouping_p_->add_child (start, rhythmic_req->duration ());
+           grouping_p_->add_child (start, rhythmic_req->length_mom ());
            stem_l->flag_i_ = rhythmic_req->duration_.durlog_i_;
            beam_p_->add_stem (stem_l);
          }