]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/score-engraver.cc
patch::: 1.3.32.hwn2
[lilypond.git] / lily / score-engraver.cc
index 696acfa4041fce3ff65009ed8ca7cf14e94637c6..09c7ffd47fb9073c28844e412a8eef4b0071e0ee 100644 (file)
@@ -3,7 +3,7 @@
 
   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 "debug.hh"
 #include "dimension-cache.hh"
@@ -12,7 +12,7 @@
 #include "score-engraver.hh"
 #include "paper-score.hh"
 #include "musical-request.hh"
-#include "score-column.hh"
+#include "paper-column.hh"
 #include "command-request.hh"
 #include "paper-def.hh"
 
@@ -29,7 +29,7 @@ void
 Score_engraver::prepare (Moment w)
 {
   Global_translator::prepare (w);
-  set_columns (new Score_column (w),  new Score_column (w));
+  set_columns (new Paper_column (w),  new Paper_column (w));
 
   command_column_l_->set_elt_property ("breakable", SCM_BOOL_T);
   post_move_processing();
@@ -39,7 +39,7 @@ void
 Score_engraver::finish()
 {
   if ((breaks_i_%8))
-    *mlog << "[" << breaks_i_ << "]" << flush;
+    progress_indication ("[" + to_str ( breaks_i_) + "]");
    
   check_removal();
   removal_processing();
@@ -53,7 +53,7 @@ Score_engraver::do_creation_processing ()
 {
   scoreline_l_ = pscore_p_->line_l_;
 
-  scoreline_l_->set_bounds(LEFT, command_column_l_);
+  scoreline_l_->set_bound(LEFT, command_column_l_);
   
   command_column_l_->set_elt_property ("breakable", SCM_BOOL_T);
 
@@ -65,10 +65,15 @@ void
 Score_engraver::do_removal_processing()
 {
   Engraver_group_engraver::do_removal_processing();
-  scoreline_l_->set_bounds(RIGHT,command_column_l_);
+  scoreline_l_->set_bound(RIGHT,command_column_l_);
   command_column_l_->set_elt_property ("breakable", SCM_BOOL_T);
 
+  
   typeset_all ();
+
+
+  if (musical_column_l_->linked_b ())
+    programming_error ("Last column in score should be non-musical");
   set_columns (0,0);
 }
 
@@ -85,7 +90,6 @@ void
 Score_engraver::announce_element (Score_element_info info)
 {
   announce_info_arr_.push (info);
-  info.origin_trans_l_arr_.push (this);
   pscore_p_->typeset_element (info.elem_l_);
 }
 
@@ -129,24 +133,22 @@ Score_engraver::typeset_all()
           */
          Direction d = LEFT;
          do {
-           if (!s->spanned_drul_[d])
+           if (!s->get_bound (d))
              {
-               s->set_bounds(d, command_column_l_);
+               s->set_bound(d, command_column_l_);
                ::warning (_f ("unbound spanner `%s'", classname(s)));
              }
          } while (flip(&d) != LEFT);
        }
       else 
        {
-         Item *item_p = dynamic_cast <Item *> (elem_p);
-
-         if (!item_p->parent_l (X_AXIS))
+         if (!elem_p->parent_l (X_AXIS))
            {
-             bool br = (item_p->remove_elt_property ("breakable") != SCM_UNDEFINED);
+             bool br = to_boolean (elem_p->remove_elt_property ("breakable"));
              if (br)
-               command_column_l_->add_element(item_p);
+               command_column_l_->add_element(elem_p);
              else
-               musical_column_l_->add_element(item_p);
+               musical_column_l_->add_element(elem_p);
            }
        }
       if (!elem_p->parent_l(Y_AXIS))
@@ -158,11 +160,11 @@ Score_engraver::typeset_all()
 void
 Score_engraver::do_pre_move_processing()
 {
-  if (command_column_l_->get_elt_property ("breakable") !=  SCM_UNDEFINED)
+  if (to_boolean (command_column_l_->get_elt_property ("breakable")))
     {
       breaks_i_ ++;
       if (! (breaks_i_%8))
-       *mlog << "[" << breaks_i_ << "]" << flush;
+       progress_indication ("[" + to_str ( breaks_i_) + "]");
     }
   // this generates all items.
   Engraver_group_engraver::do_pre_move_processing();
@@ -171,35 +173,41 @@ Score_engraver::do_pre_move_processing()
 }
 
 void
-Score_engraver::set_columns (Score_column *new_command_l, 
-                            Score_column *new_musical_l)
+Score_engraver::set_columns (Paper_column *new_command_l, 
+                            Paper_column *new_musical_l)
 {
-  if (command_column_l_ && command_column_l_->linked_b()) 
+  Paper_column * news[] = {new_command_l, new_musical_l};
+  Paper_column **current[] = {&command_column_l_, &musical_column_l_};
+
+  for (int i=00; i< 2; i++) 
     {
-      pscore_p_->add_column (command_column_l_);
-      scoreline_l_->add_column (command_column_l_);
-    }
-  else 
-    command_column_l_ =0;
+      if (*current[i])
+       {
+         if ((*current[i])->linked_b()) 
+           {
+             pscore_p_->add_column ((*current[i]));
+             scoreline_l_->add_column ((*current[i]));
+           }
+         else
+           {
+             /*
+               We're forgetting about this column. Dump it, and make SCM
+               forget it.
 
-  if (new_command_l) 
-    command_column_l_ = new_command_l;
+               FIXME: we should have another way of not putting this
+               column into the spacing problem. Maybe we shouldn't
+               even prevent this.
 
-  if (musical_column_l_ && musical_column_l_->linked_b()) 
-    {
-      pscore_p_->add_column (musical_column_l_);
-      scoreline_l_->add_column (musical_column_l_);      
-    }
-  else 
-    musical_column_l_ = 0;
-  
-  if (new_musical_l) 
-    {
-      musical_column_l_ = new_musical_l;
+             */
+             scm_unprotect_object ((*current[i])->self_scm_);
+             *current[i]  =0;
+           }
+       }
+      if (news[i])
+       *current[i] = news[i];
     }
 }
 
-
 Staff_info
 Score_engraver::get_staff_info() const
 {
@@ -211,7 +219,6 @@ Score_engraver::get_staff_info() const
   return inf;
 }
 
-
 Music_output*
 Score_engraver::get_output_p ()
 {
@@ -233,9 +240,9 @@ Score_engraver::do_try_music (Music*r)
 
 
          SCM pen = command_column_l_->get_elt_property  ("penalty");
-         Real total_penalty = (pen == SCM_UNDEFINED)
-           ? 0.0
-           : gh_scm2double(pen); // ugh. Should typecheck.
+         Real total_penalty = gh_number_p (pen)
+           ? gh_scm2double(pen)
+           : 0.0;
 
          total_penalty += b->penalty_f_;
          if (b->penalty_f_ > 10000.0) //  ugh. arbitrary.