]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/rest-collision.cc
release: 1.1.1
[lilypond.git] / lily / rest-collision.cc
index 54392d55858bd8858326d2f1a36276d8c027681f..095c6ac4695620804dfd895388847bf459a68c27 100644 (file)
@@ -3,12 +3,11 @@
 
   source file of the GNU LilyPond music typesetter
 
-  (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
+  (c)  1997--1998 Han-Wen Nienhuys <hanwen@cs.uu.nl>
 */
 
 #include "debug.hh"
 #include "rest-collision.hh"
-#include "rest-column.hh"
 #include "note-column.hh"
 #include "stem.hh"
 #include "note-head.hh"
@@ -19,7 +18,7 @@
 IMPLEMENT_IS_TYPE_B1(Rest_collision,Item);
 
 void
-Rest_collision::add (Note_column *nc_l)
+Rest_collision::add_column (Note_column *nc_l)
 {
   add_dependency (nc_l);
   if (nc_l->rest_b ())
@@ -54,14 +53,16 @@ Rest_collision::do_post_processing()
 
   int dir_i = rest_l_arr_[0]->dir_;
   int midpos = 4;
-#if 1
   // ugh
   int stem_length_i = 7 - 2;
   // ugh, Stem::stem_start vs Stem::stem_end
   int pos = (int)(stem_l->stem_end_f() - midpos) - dir_i * stem_length_i;
-#else // nogo: stem_start not set for rests?
-  int pos = (stem_l->stem_start_f() - midpos) + dir_i * 2;
-#endif
+  /*
+    nogo: stem_start not set for rests?
+  int pos = (stem_l->stem_begin_f() - midpos) + dir_i * 2;
+
+  WHY IS THIS STILL HERE? --hwn
+  */
   rest_l_arr_[0]->translate_rests (pos);       
 }
 
@@ -95,15 +96,10 @@ Rest_collision::do_pre_processing()
   // meisjes met jongetjes
   else 
     {
-#if 0 // breendet: rests go always under
-      // geen gemug, trug op je rug
-      int dir_i = -1;
-      rest_l_arr_[0]->translate_rests (dir_i * 3);     
-#else
       // int dir_i = - ncol_l_arr_[0]->dir_;
       int dir_i = rest_l_arr_[0]->dir_;
       // hope it's 4: if it works->doco
-      int midpos = 4;
+      int midpos = 0;
        
       // minimum move
       int minpos = 4;
@@ -122,7 +118,6 @@ Rest_collision::do_pre_processing()
              (ncol_l_arr_[i]->head_l_arr_[j]->position_i_ -midpos) + sep_i;
        }
       rest_l_arr_[0]->translate_rests (dir_i * minpos);        
-#endif
     }
 }
 
@@ -136,21 +131,18 @@ Rest_collision::do_print() const
 }
 
 void
-Rest_collision::do_substitute_dependency (Score_elem*o,Score_elem*n)
+Rest_collision::do_substitute_dependency (Score_element*o,Score_element*n)
 {
-  Item*o_l = o->item();
-  
-
-  if (o_l&&o_l->is_type_b (Note_column::static_name ()))
+  if (Note_column *onl = dynamic_cast<Note_column *> (o))
     {
-      Note_column *n_l = n?(Note_column*)n->item():0;
-      rest_l_arr_.substitute ((Note_column*)o_l, n_l);
-      ncol_l_arr_.substitute ((Note_column*)o_l, n_l);
+      Note_column *n_l = n?dynamic_cast<Note_column *> (n):0;
+      rest_l_arr_.substitute (onl, n_l);
+      ncol_l_arr_.substitute (onl, n_l);
     }
 }
 
 Rest_collision::Rest_collision()
 {
   transparent_b_ = true;
-  empty_b_ = true;
+  set_empty (true);
 }