]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/line-of-score.cc
release: 1.5.33
[lilypond.git] / lily / line-of-score.cc
index 464cd4e6abd75458a467a484181d8e0869f2731d..de47ec41d4e60748b2d4c97deb6ef7fc35326eef 100644 (file)
@@ -3,7 +3,7 @@
 
   source file of the GNU LilyPond music typesetter
 
-  (c) 1996--2001 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+  (c) 1996--2002 Han-Wen Nienhuys <hanwen@cs.uu.nl>
 */
 
 #include "input-smob.hh"
@@ -51,7 +51,7 @@ void
 Line_of_score::typeset_grob (Grob * elem_p)
 {
   elem_p->pscore_l_ = pscore_l_;
-  Pointer_group_interface::add_element (this, "all-elements",elem_p);
+  Pointer_group_interface::add_grob (this, ly_symbol2scm ("all-elements"),elem_p);
   scm_gc_unprotect_object (elem_p->self_scm ());
 }
 
@@ -63,6 +63,7 @@ Line_of_score::output_lines ()
     {
       unsmob_grob (ly_car (s))->do_break_processing ();
     }
+
   /*
     fixups must be done in broken line_of_scores, because new elements
     are put over there.  */
@@ -77,7 +78,6 @@ Line_of_score::output_lines ()
        }
       count += scm_ilength (all);
     }
-
   
   /*
     needed for doing items.
@@ -127,13 +127,16 @@ Line_of_score::output_lines ()
     }
 }
 
+
+
+
 /*
   Find the loose columns in POSNS, and drape them around the columns
   specified in BETWEEN-COLS.  */
 void
 set_loose_columns (Line_of_score* which, Column_x_positions const *posns)
 {
-  for (int i = 0; i<posns->loose_cols_.size (); i++)
+  for (int i = 0; i < posns->loose_cols_.size (); i++)
     {
       int divide_over = 1;
       Item *loose = dynamic_cast<Item*> (posns->loose_cols_[i]);
@@ -145,28 +148,38 @@ set_loose_columns (Line_of_score* which, Column_x_positions const *posns)
       
       Item * left = 0;
       Item * right = 0;
-      while (1)
+      do
        {
-         
          SCM between = loose->get_grob_property ("between-cols");
          if (!gh_pair_p (between))
            break;
 
-         if (!left)
+
+         Item * l=dynamic_cast<Item*> (unsmob_grob (ly_car (between)));
+         Item * r=dynamic_cast<Item*> (unsmob_grob (ly_cdr (between)));
+
+         if (!(l && r))
+           break ;
+         
+         if (!left && l)
            {
-             left = dynamic_cast<Item*> (unsmob_grob (ly_car (between)));
-             left = left->column_l ();
+             left = l->column_l ();
            }
-         divide_over ++;       
-         loose = dynamic_cast<Item*> (unsmob_grob (ly_cdr (between)));
-         loose = loose->column_l ();
-       }
 
-      right = loose;
+         divide_over ++;
 
-      Real rx = right->relative_coordinate (right->parent_l (X_AXIS), X_AXIS);
-      Real lx = left->relative_coordinate (left->parent_l (X_AXIS), X_AXIS);
+         loose = right = r->column_l ();
+       }
+      while (1);
+      
+    
+#if 0
+      Real rx = right->relative_coordinate (right->get_parent (X_AXIS), X_AXIS);
+      Real lx = left->relative_coordinate (left->get_parent (X_AXIS), X_AXIS);
 
+      /*
+       divide space equally over loose columns.
+       */
       int j = 1;
       loose = col;
       while (1)
@@ -183,7 +196,45 @@ set_loose_columns (Line_of_score* which, Column_x_positions const *posns)
          j ++; 
          loose = dynamic_cast<Item*> (unsmob_grob (ly_cdr (between)));
        }
+#else
+      /*
+       We divide the remaining space of the column over the left and
+       right side. At the moment, we  
+       
+      */
+      Grob * common = right->common_refpoint (left, X_AXIS);
       
+      Real rx =        right->extent(common, X_AXIS)[LEFT];
+      Real lx =  left->extent(common, X_AXIS)[RIGHT];
+      Real total_dx = rx - lx;
+      Interval cval =col->extent (col, X_AXIS);
+
+      /*
+       
+       We put it in the middle. This is not an ideal solution -- the
+       break alignment code inserts a fixed space before the clef
+       (about 1 SS), while the space following the clef is
+       flexible. In tight situations, the clef will almost be on top
+       of the following note. 
+       
+      */
+      Real dx = rx-lx - cval.length ();
+      if (total_dx < 2* cval.length ())
+       {
+         /*
+           todo: this is discontinuous. I'm too tired to
+           invent a sliding mechanism. Duh.
+
+           TODO.
+          */
+         dx *= 0.25;
+       }
+      else
+       dx *= 0.5;
+
+      col->line_l_ = which;
+      col->translate_axis (lx + dx - cval[LEFT], X_AXIS); 
+#endif
     }
 }
 
@@ -365,7 +416,7 @@ Line_of_score::post_processing (bool last_line)
   /*
     generate all molecules  to trigger all font loads.
 
- (ugh. This is not very memory efficient.)  */
   (ugh. This is not very memory efficient.)  */
   for (SCM s = get_grob_property ("all-elements"); gh_pair_p (s); s = ly_cdr (s))
     {
       unsmob_grob (ly_car (s))->get_molecule ();
@@ -461,7 +512,7 @@ Link_array<Grob>
 Line_of_score::column_l_arr ()const
 {
   Link_array<Grob> acs
-    = Pointer_group_interface__extract_elements (this, (Grob*) 0, "columns");
+    = Pointer_group_interface__extract_grobs (this, (Grob*) 0, "columns");
   bool bfound = false;
   for (int i= acs.size (); i -- ;)
     {