]> git.donarmstrong.com Git - lilypond.git/commitdiff
lilypond-0.0.56
authorfred <fred>
Sun, 24 Mar 2002 19:40:08 +0000 (19:40 +0000)
committerfred <fred>
Sun, 24 Mar 2002 19:40:08 +0000 (19:40 +0000)
lily/note-column-reg.cc

index e5e839fc28e197aab672cee6b0dc359a362d984b..cb8129d5bc14d8325290964be93b75e0a0f207aa 100644 (file)
@@ -11,6 +11,7 @@
 #include "stem.hh"
 #include "note-column.hh"
 #include "script.hh"
+#include "rest-column.hh"
 
 bool
 Note_column_register::acceptable_elem_b(Staff_elem const*elem_C)const
@@ -19,6 +20,25 @@ Note_column_register::acceptable_elem_b(Staff_elem const*elem_C)const
     return (nC == Script::static_name() || nC == Notehead::static_name() 
            || nC == Stem::static_name());
 }
+Note_column*
+Note_column_register::note_col_l()
+{
+    if (!ncol_p_){
+       ncol_p_ = new Note_column;
+       announce_element(Staff_elem_info(ncol_p_, 0));
+    }
+    return ncol_p_;
+}
+
+Rest_column *
+Note_column_register::rest_col_l()
+{
+    if (!restcol_p_) {
+       restcol_p_  = new Rest_column;
+       announce_element(Staff_elem_info(restcol_p_,0));
+    }
+    return restcol_p_;
+}
 
 void
 Note_column_register::acknowledge_element(Staff_elem_info i)
@@ -26,23 +46,41 @@ Note_column_register::acknowledge_element(Staff_elem_info i)
     if (!acceptable_elem_b(i.elem_l_))
        return;
 
-    if (!ncol_p_){
-       ncol_p_ = new Note_column;
-       announce_element(Staff_elem_info(ncol_p_, 0));
-    }
+
     char const*nC = i.elem_l_->name();
 
-    if (nC == Script::static_name())
-       ncol_p_->add((Script*)i.elem_l_);
-    else if (nC == Notehead::static_name())
-       ncol_p_->add((Notehead*)i.elem_l_);
-    else if (nC == Stem::static_name())
-       ncol_p_->add((Stem*)i.elem_l_);
+    if (nC == Script::static_name()) {
+       script_l_arr_.push((Script*)i.elem_l_);
+    } else if (nC == Notehead::static_name()) {
+       Notehead * h_l = (Notehead*)i.elem_l_;
+       if (h_l->rest_b_)
+           rest_col_l()->add(h_l);
+       else
+           note_col_l()->add(h_l);
+    }
+    else if (nC == Stem::static_name()){ 
+       stem_l_ = (Stem*)i.elem_l_;
+    }
 }
 
 void
 Note_column_register::pre_move_processing()
 {
+    Script_column *col_l = ( ncol_p_ ) ? ncol_p_ : restcol_p_;
+    if (!col_l)
+       return;
+    
+    for (int i=0; i < script_l_arr_.size(); i++)
+       col_l->add(script_l_arr_[i]);
+    
+    if (ncol_p_&&stem_l_)
+       ncol_p_->add(stem_l_);
+    if (restcol_p_) {
+       if (! restcol_p_ -> dir_i_)
+           restcol_p_->dir_i_ = dir_i_;
+       typeset_element(restcol_p_);
+       restcol_p_ =0;
+    }
     if (ncol_p_) {
        if (!   ncol_p_->dir_i_ )
            ncol_p_->dir_i_ = dir_i_;
@@ -53,6 +91,13 @@ Note_column_register::pre_move_processing()
     }
 }
 
+void
+Note_column_register::post_move_processing()
+{
+    script_l_arr_.set_size(0);
+    stem_l_ =0;
+}
+
 void
 Note_column_register::set_feature(Feature i)
 {
@@ -66,7 +111,10 @@ Note_column_register::Note_column_register()
 {
     dir_i_ =0;
     h_shift_b_ = false;
+    
     ncol_p_=0;
+    restcol_p_ =0;
+    post_move_processing();
 }
 IMPLEMENT_STATIC_NAME(Note_column_register);
 ADD_THIS_REGISTER(Note_column_register);