]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/score-engraver.cc
patch::: 1.3.86.jcn2
[lilypond.git] / lily / score-engraver.cc
index 83d2c47eef16eb8394e4125533a8f62133e3ef86..66b759e7d237bc7c9cd31c67ce45afd7fbdd1b35 100644 (file)
@@ -1,22 +1,22 @@
 /*
-  score-grav.cc -- implement Score_engraver
+  score-engraver.cc -- implement Score_engraver
 
   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 "dimension-cache.hh"
-#include "super-element.hh"
-#include "line-of-score.hh"
 #include "debug.hh"
+
+#include "line-of-score.hh"
 #include "item.hh"
 #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"
+#include "axis-group-interface.hh"
 
 Score_engraver::Score_engraver()
 {
@@ -31,9 +31,21 @@ void
 Score_engraver::prepare (Moment w)
 {
   Global_translator::prepare (w);
-  set_columns (new Score_column (w),  new Score_column (w));
 
+  SCM props = get_property (ly_symbol2scm ("basicPaperColumnProperties"));
+  set_columns (new Paper_column (props),  new Paper_column (props));
+  
+  command_column_l_->set_elt_property ("when", w.make_scm());
+  musical_column_l_->set_elt_property ("when", w.make_scm());
   command_column_l_->set_elt_property ("breakable", SCM_BOOL_T);
+  
+  Score_element_info i1(command_column_l_, 0), i2 (musical_column_l_,0);
+
+  i1.origin_trans_l_ = this;
+  i2.origin_trans_l_ = this;
+  announce_element (i1);
+  announce_element (i2);
+  
   post_move_processing();
 }
 
@@ -41,7 +53,7 @@ void
 Score_engraver::finish()
 {
   if ((breaks_i_%8))
-    *mlog << "[" << breaks_i_ << "]" << flush;
+    progress_indication ("[" + to_str ( breaks_i_) + "]");
    
   check_removal();
   removal_processing();
@@ -55,7 +67,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);
 
@@ -67,17 +79,18 @@ 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 ();
+
   set_columns (0,0);
 }
 
 void
 Score_engraver::process()
 {
-  process_requests();
+  process_music();
   do_announces();
   pre_move_processing();
   check_removal();
@@ -87,8 +100,7 @@ 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_);
+  pscore_p_->line_l_->typeset_element (info.elem_l_);
 }
 
 /* All elements are propagated to the top upon announcement. If
@@ -131,28 +143,24 @@ 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_);
-               ::warning (_f ("unbound spanner `%s'", classname(s)));
+               s->set_bound(d, command_column_l_);
+               ::warning (_f ("unbound spanner `%s'", s->name().ch_C()));
              }
          } 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);
-             if (br)
-               command_column_l_->add_element(item_p);
-             else
-               musical_column_l_->add_element(item_p);
+             bool br = to_boolean (elem_p->get_elt_property ("breakable"));
+             Axis_group_interface::add_element (br ? command_column_l_ : musical_column_l_, elem_p);
+
            }
        }
       if (!elem_p->parent_l(Y_AXIS))
-       scoreline_l_->add_element (elem_p);
+       Axis_group_interface::add_element (scoreline_l_, elem_p);
     }
   elem_p_arr_.clear();
 }
@@ -160,60 +168,51 @@ Score_engraver::typeset_all()
 void
 Score_engraver::do_pre_move_processing()
 {
-  if (command_column_l_->get_elt_property ("breakable") !=  SCM_UNDEFINED)
-    {
-      breaks_i_ ++;
-      if (! (breaks_i_%8))
-       *mlog << "[" << breaks_i_ << "]" << flush;
-    }
   // this generates all items.
   Engraver_group_engraver::do_pre_move_processing();
   
   typeset_all();
+  if (to_boolean (command_column_l_->get_elt_property ("breakable")))
+    {
+      breaks_i_ ++;
+      if (! (breaks_i_%8))
+       progress_indication ("[" + to_str ( breaks_i_) + "]");
+    }
 }
 
 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()) 
-    {
-      pscore_p_->add_column (command_column_l_);
-      scoreline_l_->add_column (command_column_l_);
-    }
-  else 
-    command_column_l_ =0;
-
-  if (new_command_l) 
-    command_column_l_ = new_command_l;
+  Paper_column * news[] = {new_command_l, new_musical_l};
+  Paper_column **current[] = {&command_column_l_, &musical_column_l_};
 
-  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) 
+  for (int i=00; i< 2; i++) 
     {
-      musical_column_l_ = new_musical_l;
+      if (*current[i])
+       {
+         scoreline_l_->add_column ((*current[i]));
+#if 0
+         /*
+           TODO: delay this decision.
+          */
+         if (!Paper_column::used_b (*current[i]))
+           {
+             (*current[i])->suicide ();
+             *current[i]  =0;
+           }
+#endif
+       }
+      if (news[i])
+       *current[i] = news[i];
     }
-}
-
-
-Staff_info
-Score_engraver::get_staff_info() const
-{
-  Staff_info inf = Engraver_group_engraver::get_staff_info();
 
-  inf.command_l_ = command_column_l_;
-  inf.musical_l_ = musical_column_l_;
-  
-  return inf;
+  if (new_musical_l)
+    set_property ("currentMusicalColumn", new_musical_l->self_scm ());
+  if (new_command_l)
+    set_property ("currentCommandColumn", new_command_l->self_scm ());  
 }
 
-
 Music_output*
 Score_engraver::get_output_p ()
 {
@@ -235,9 +234,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.
@@ -269,5 +268,9 @@ Score_engraver::do_add_processing ()
   assert (!daddy_trans_l_);
   pscore_p_ = new Paper_score;
   pscore_p_->paper_l_ = dynamic_cast<Paper_def*>(output_def_l_);
+
+  SCM props = get_property(ly_symbol2scm ("basicLineOfScoreProperties"));
+
+  pscore_p_->typeset_line (new Line_of_score (props));
 }