X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fnote-column.cc;h=5fac5ffc5ad7477fe2772bb30a44ce5fe7ebbaa1;hb=refs%2Ftags%2Frelease%2F1.1.29;hp=8d7d7f7e2b8dcf5cc48a56b7b24837e0354b0211;hpb=6ce61146edb1c36647b514778c29cdc9beedab6a;p=lilypond.git diff --git a/lily/note-column.cc b/lily/note-column.cc index 8d7d7f7e2b..5fac5ffc5a 100644 --- a/lily/note-column.cc +++ b/lily/note-column.cc @@ -3,52 +3,146 @@ source file of the GNU LilyPond music typesetter - (c) 1997 Han-Wen Nienhuys + (c) 1997--1999 Han-Wen Nienhuys */ - +#include "dot-column.hh" #include "note-column.hh" #include "script.hh" #include "note-head.hh" #include "stem.hh" +#include "rest.hh" +#include "debug.hh" -IMPLEMENT_STATIC_NAME(Note_column); -IMPLEMENT_IS_TYPE_B1(Note_column,Head_column); - -void -Note_column::set(Stem*s) +bool +Note_column::rest_b () const { - stem_l_ = s; - add_support(s); + return rest_l_arr_.size (); } Note_column::Note_column() { - h_shift_b_ =false; + stem_l_ = 0; + h_shift_b_ = false; + dir_ =CENTER; } void Note_column::sort() { - head_l_arr_.sort( Note_head::compare); + head_l_arr_.sort (Note_head::compare); } - + Interval_t -Note_column::head_positions_interval()const +Note_column::head_positions_interval() const { - ((Note_column*)this)->sort(); - return Interval_t ( head_l_arr_[0]->position_i_, - head_l_arr_.top()->position_i_); + ((Note_column*)this)->sort(); + Interval_t iv; -} + iv.set_empty (); + if (head_l_arr_.size ()) + iv = Interval_t(head_l_arr_[0]->position_i_, + head_l_arr_.top()->position_i_); + + return iv; +} void Note_column::do_pre_processing() { - if (!dir_i_&& !stem_l_){ - dir_i_ = (head_positions_interval().center() >= 5) ? -1 : 1; + if (!dir_) + { + if (stem_l_) + dir_ = stem_l_->dir_; + else if (head_l_arr_.size ()) + { + // assert (false); // looks obsolete? + dir_ = sign (head_positions_interval().center ()); + } + } + Script_column::do_pre_processing(); +} + + + +void +Note_column::set_stem (Stem * stem_l) +{ + add_support (stem_l); + stem_l_ = stem_l; + /* + don't add stem to support; mostly invisible for rest-columns (and possibly taken . .) + */ + Score_element::add_dependency (stem_l); + for (int i=0; i < script_l_arr_.size(); i++) + script_l_arr_[i]->set_stem (stem_l); +} + +void +Note_column::add_script (Script *script_l) +{ + Script_column::add_script (script_l) ; + if (stem_l_) + script_l->set_stem (stem_l_); +} + +void +Note_column::do_substitute_dependency (Score_element*o, Score_element*n) +{ + if (stem_l_ == o) + { + stem_l_ = n ? dynamic_cast (n):0; + } + if (dynamic_cast (o)) + { + head_l_arr_.substitute (dynamic_cast (o), + (n)? dynamic_cast (n) : 0); + } + Script_column::do_substitute_dependency (o,n); + if (dynamic_cast (o)) + { + rest_l_arr_.substitute (dynamic_cast (o), + (n)? dynamic_cast (n) : 0); + } +} + +void +Note_column::add_head (Rhythmic_head *h) +{ + if (Rest*r=dynamic_cast (h)) + { + rest_l_arr_.push (r); + add_support (r); + } + if (Note_head *nh=dynamic_cast (h)) + { + head_l_arr_.push (nh); + add_support (nh); } - Head_column::do_pre_processing(); } - +/** + translate the rest symbols + */ +void +Note_column::translate_rests (int dy_i) +{ + invalidate_cache (Y_AXIS); + for (int i=0; i < rest_l_arr_.size(); i++) + rest_l_arr_[i]->position_i_ += dy_i; +} + +void +Note_column::do_print() const +{ +#ifndef NPRINT + DOUT << "rests: " << rest_l_arr_.size() << ", "; + DOUT << "heads: " << head_l_arr_.size(); +#endif +} + +void +Note_column::set_dotcol (Dot_column *d) +{ + add_element (d); +}