From: fred Date: Sun, 24 Mar 2002 19:56:06 +0000 (+0000) Subject: lilypond-0.1.11 X-Git-Tag: release/1.5.59~3983 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=870ea7dc2c02796420a7426f6976fae6b4e14044;p=lilypond.git lilypond-0.1.11 --- diff --git a/flower/include/list.tcc b/flower/include/list.tcc index 1233c4821d..06aa312bc3 100644 --- a/flower/include/list.tcc +++ b/flower/include/list.tcc @@ -10,7 +10,7 @@ // instantiate a template: explicit instantiation. -#define L_INSTANTIATE(a) class List; template class Cursor; \ +#define LIST_INSTANTIATE(a) class List; template class Cursor; \ template class Link #include "list.hh" diff --git a/flower/include/plist.icc b/flower/include/plist.icc index 7fda7abb2c..d81b322e48 100644 --- a/flower/include/plist.icc +++ b/flower/include/plist.icc @@ -8,7 +8,7 @@ #define PLIST_INL template -void +inline void PL_copy (Pointer_list &to, Pointer_list const&src) { for (PCursor pc (src); pc.ok(); pc++) @@ -19,4 +19,15 @@ PL_copy (Pointer_list &to, Pointer_list const&src) } } + +template +inline PCursor +Link_list::find (T what) const +{ + PCursor i (*this); + for (; i.ok(); i++) + if (i.ptr() == what) + break; + return i; +} #endif diff --git a/lily/include/stem.hh b/lily/include/stem.hh index 3ea7c35608..4cf67df0e2 100644 --- a/lily/include/stem.hh +++ b/lily/include/stem.hh @@ -28,75 +28,75 @@ */ class Stem : public Item { - Real stem_bottom_f_, stem_top_f_; + Real stem_bottom_f_, stem_top_f_; - /// needed for determining direction/length - int staff_size_i_; - - /**extent of the stem (positions). - fractional, since Beam has to adapt them. - */ - - - /** - geen gedonder, jij gaat onder. - -1 stem points down, +1: stem points up - */ - Real stem_xoffset_f_; - /** - store the wholes (for vapourware tremolo) - */ - Link_array whole_l_arr_; - Link_array head_l_arr_; - Link_array rest_l_arr_; + /// needed for determining direction/length + int staff_size_i_; + + /**extent of the stem (positions). + fractional, since Beam has to adapt them. + */ + + + /** + geen gedonder, jij gaat onder. + -1 stem points down, +1: stem points up + */ + Real stem_xoffset_f_; + /** + store the wholes (for vapourware tremolo) + */ + Link_array whole_l_arr_; + Link_array head_l_arr_; + Link_array rest_l_arr_; public: - /// flagtype? 4 none, 8 8th flag, 0 = beam. - int flag_i_; + /// flagtype? 4 none, 8 8th flag, 0 = beam. + int flag_i_; - int beams_left_i_; - int beams_right_i_; + int beams_left_i_; + int beams_right_i_; - /// false if in beam - bool print_flag_b_; + /// false if in beam + bool print_flag_b_; - int dir_i_; + Direction dir_; - /* *************** */ - Stem (int staff_size_i); + /* *************** */ + Stem (); - /// ensure that this Stem also encompasses the Notehead #n# - void add (Note_head*n); + /// ensure that this Stem also encompasses the Notehead #n# + void add (Note_head*n); - DECLARE_MY_RUNTIME_TYPEINFO; + DECLARE_MY_RUNTIME_TYPEINFO; - Real hpos_f()const; + Real hpos_f() const; - void do_print() const; - void set_stemend (Real); - int get_default_dir(); - int get_center_distance_from_top(); - int get_center_distance_from_bottom(); - void set_default_dir(); - void set_default_stemlen(); - void set_default_extents(); - void set_noteheads(); - - Real stem_length_f()const; - Real stem_end_f()const; - Real stem_start_f() const; - - bool invisible_b()const; + void do_print() const; + void set_stemend (Real); + Direction get_default_dir(); + int get_center_distance_from_top(); + int get_center_distance_from_bottom(); + void set_default_dir(); + void set_default_stemlen(); + void set_default_extents(); + void set_noteheads(); + + Real stem_length_f() const; + Real stem_end_f() const; + Real stem_start_f() const; + + bool invisible_b() const; - /// heads that the stem encompasses (positions) - int max_head_i() const; - int min_head_i() const; + /// heads that the stem encompasses (positions) + int max_head_i() const; + int min_head_i() const; protected: - virtual void do_substitute_dependency (Score_elem*,Score_elem*); - virtual void do_pre_processing(); - virtual Interval do_width() const; - Molecule* brew_molecule_p() const; + virtual void do_substitute_dependency (Score_elem*,Score_elem*); + virtual void do_pre_processing(); + virtual Interval do_width() const; + Molecule* brew_molecule_p() const; }; #endif diff --git a/lily/musical-request.cc b/lily/musical-request.cc index 4924a934be..9ffd4f494c 100644 --- a/lily/musical-request.cc +++ b/lily/musical-request.cc @@ -14,29 +14,12 @@ #include "music-list.hh" -IMPLEMENT_IS_TYPE_B1(Stem_req,Rhythmic_req); - -void -Stem_req::do_print() const -{ -#ifndef NPRINT - Rhythmic_req::do_print(); - DOUT << "dir : " << dir_i_; -#endif -} - -Stem_req::Stem_req() -{ - dir_i_ = 0; -} - -/* ************** */ IMPLEMENT_IS_TYPE_B1(Musical_req,Request); void -Musical_req::do_print()const{} +Musical_req::do_print() const{} void -Tie_req::do_print()const{} +Tie_req::do_print() const{} /* *************** */ @@ -64,7 +47,7 @@ Spacing_req::Spacing_req() IMPLEMENT_IS_TYPE_B1(Spacing_req,Request); void -Spacing_req::do_print()const +Spacing_req::do_print() const { #ifndef NPRINT DOUT << "next " << next << "dist " << distance << "strength\n"; @@ -75,7 +58,7 @@ Spacing_req::do_print()const IMPLEMENT_IS_TYPE_B2(Blank_req,Spacing_req,Rhythmic_req); void -Blank_req::do_print()const +Blank_req::do_print() const { Spacing_req::do_print(); } @@ -114,7 +97,7 @@ Melodic_req::transpose (Melodic_req const & delta) IMPLEMENT_IS_TYPE_B1(Melodic_req,Musical_req); bool -Melodic_req::do_equal_b (Request*r)const +Melodic_req::do_equal_b (Request*r) const { Melodic_req* m= r->musical()->melodic (); return !compare (*m, *this); @@ -129,7 +112,7 @@ Melodic_req::compare (Melodic_req const &m1 , Melodic_req const&m2) if (o) return o; - if ( n) + if (n) return n; if (a) return a; @@ -170,7 +153,7 @@ Rhythmic_req::compare (Rhythmic_req const &r1, Rhythmic_req const &r2) } bool -Rhythmic_req::do_equal_b (Request*r)const +Rhythmic_req::do_equal_b (Request*r) const { Rhythmic_req* rh = r->musical()->rhythmic (); @@ -209,7 +192,7 @@ Lyric_req::Lyric_req (Text_def* def_p) :Text_req (0, def_p) { def_p->align_i_ = 0; // centre - dir_i_ = -1; // lyrics below (invisible) staff + dir_ = DOWN; // lyrics below (invisible) staff } @@ -224,7 +207,7 @@ Lyric_req::do_print() const /* *************** */ bool -Note_req::do_equal_b (Request*r)const +Note_req::do_equal_b (Request*r) const { return Rhythmic_req::do_equal_b (r) && Melodic_req::do_equal_b (r); } @@ -267,17 +250,17 @@ Beam_req::Beam_req() IMPLEMENT_IS_TYPE_B1(Beam_req,Span_req); void -Beam_req::do_print()const{} +Beam_req::do_print() const{} /* *************** */ IMPLEMENT_IS_TYPE_B1(Slur_req,Span_req); void -Slur_req::do_print()const{} +Slur_req::do_print() const{} /* *************** */ bool -Span_req:: do_equal_b (Request*r)const +Span_req:: do_equal_b (Request*r) const { Span_req * s = r->span(); return spantype - s->spantype; @@ -291,17 +274,17 @@ Span_req::Span_req() /* *************** */ Script_req::Script_req (Script_req const&s) { - dir_i_ = s.dir_i_; + dir_ = s.dir_; scriptdef_p_ = s.scriptdef_p_ ? s.scriptdef_p_->clone() : 0; } /* don't check dirs? - (d1.dir_i_ == d2.dir_i_) + (d1.dir_ == d2.dir_) */ bool -Script_req::do_equal_b (Request*r)const +Script_req::do_equal_b (Request*r) const { Script_req * s = r->script(); @@ -310,7 +293,7 @@ Script_req::do_equal_b (Request*r)const Script_req::Script_req() { - dir_i_ = 0; + dir_ = CENTER; scriptdef_p_ = 0; } @@ -321,7 +304,7 @@ void Script_req::do_print() const { #ifndef NPRINT - DOUT << " dir " << dir_i_ ; + DOUT << " dir " << dir_ ; scriptdef_p_->print(); #endif } @@ -352,12 +335,12 @@ Text_req::~Text_req() Text_req::Text_req (Text_req const& src) { tdef_p_ = new Text_def (*src.tdef_p_); - dir_i_ = src.dir_i_; + dir_ = src.dir_; } Text_req::Text_req (int dir_i, Text_def* tdef_p) { - dir_i_ = dir_i; + dir_ = Direction(dir_i); tdef_p_ = tdef_p; } @@ -368,7 +351,7 @@ void Text_req::do_print() const { #ifndef NPRINT - DOUT << " dir " << dir_i_ ; + DOUT << " dir " << dir_ ; tdef_p_->print(); #endif } @@ -435,18 +418,18 @@ Absolute_dynamic_req::Absolute_dynamic_req() Span_dynamic_req::Span_dynamic_req() { - dynamic_dir_i_ = 0; + dynamic_dir_ = CENTER; } IMPLEMENT_IS_TYPE_B1(Span_dynamic_req,Musical_req); void -Span_dynamic_req::do_print()const +Span_dynamic_req::do_print() const { #ifndef NPRINT Span_req::do_print(); - DOUT << "louder/louder: " <symidx_str_ && - rel_stem_dir_i_ == c->rel_stem_dir_i_&& - staff_dir_i_ == c->staff_dir_i_&& - invertsym_b_ == c->invertsym_b_); + rel_stem_dir_ == c->rel_stem_dir_&& + staff_dir_ == c->staff_dir_&& + invertsym_b_ == c->invertsym_b_); } -int -Script_def::staff_dir_i() const +Direction +Script_def::staff_dir() const { - return staff_dir_i_; + return staff_dir_; } -int -Script_def::rel_stem_dir_i() const +Direction +Script_def::rel_stem_dir() const { - return rel_stem_dir_i_; + return rel_stem_dir_; } bool @@ -72,11 +72,11 @@ Script_def::inside_b() const } Atom -Script_def::get_atom (Paper_def *p , int d)const +Script_def::get_atom (Paper_def *p , Direction d) const { String preidx_str =""; if (invertsym_b_&& d < 0) - preidx_str = "-"; + preidx_str = "-"; return p->lookup_l()->script (preidx_str + symidx_str_); } @@ -85,7 +85,7 @@ Script_def::get_atom (Paper_def *p , int d)const IMPLEMENT_IS_TYPE_B1(Script_def,General_script_def); int -Script_def::priority_i()const +Script_def::priority_i() const { return priority_i_; } diff --git a/lily/staff-side.cc b/lily/staff-side.cc index 5d9bd748ab..a58d2f2828 100644 --- a/lily/staff-side.cc +++ b/lily/staff-side.cc @@ -25,16 +25,16 @@ Staff_side::Staff_side() pos_i_ =0; sym_int_ = Interval (0,0); staff_size_i_ = 0; - staff_sym_l_=0; - dir_i_ =0; - inside_staff_b_ =false; + staff_sym_l_ = 0; + dir_ = CENTER; + inside_staff_b_ = false; } void Staff_side::read_staff_sym() { if (! staff_sym_l_) - return ; + return ; staff_size_i_ = staff_sym_l_->steps_i(); } @@ -45,10 +45,10 @@ Staff_side::support_height() const Interval r; for (int i=0; i < support_l_arr_.size(); i++) - r.unite (support_l_arr_[i]->height()); + r.unite (support_l_arr_[i]->height()); if (r.empty_b()) { - r = Interval (0,0); + r = Interval (0,0); } return r; } @@ -61,13 +61,13 @@ Staff_side::add_support (Score_elem*i) } int -Staff_side::get_position_i()const +Staff_side::get_position_i() const { - if (!dir_i_) + if (!dir_) { - warning ("Staff_side::get_position_i(): " - "somebody forgot to set my vertical direction, returning -20"); - return -20; + warning ("Staff_side::get_position_i(): " + "somebody forgot to set my vertical direction, returning -20"); + return -20; } @@ -75,23 +75,23 @@ Staff_side::get_position_i()const Real inter_f = paper()-> internote_f (); if (!inside_staff_b_) { - y = (dir_i_ > 0 && staff_sym_l_) ? staff_sym_l_->steps_i() + 2: -2; - y *=inter_f; - Interval v= support_height(); - - if (dir_i_ > 0) - { - y = y >? (v.max() + 2*inter_f); - } - else if (dir_i_ < 0) - { - y = y 0 && staff_sym_l_) ? staff_sym_l_->steps_i() + 2: -2; + y *=inter_f; + Interval v= support_height(); + + if (dir_ > 0) + { + y = y >? (v.max() + 2*inter_f); + } + else if (dir_ < 0) + { + y = y internote_f ())); + if (dir_) + pos_i_ += int (rint (- sym_int_[-dir_] / paper()->internote_f ())); } void @@ -116,7 +116,7 @@ Staff_side::do_substitute_dependency (Score_elem*o, Score_elem*n) { support_l_arr_.unordered_substitute (o,n); if (staff_sym_l_ == o) - staff_sym_l_ = n ? (Staff_symbol*) n->spanner():0; + staff_sym_l_ = n ? (Staff_symbol*) n->spanner():0; } diff --git a/lily/stem.cc b/lily/stem.cc index 633a0e3252..62e1a87537 100644 --- a/lily/stem.cc +++ b/lily/stem.cc @@ -19,11 +19,11 @@ const int STEMLEN=7; int -Stem::min_head_i()const +Stem::min_head_i() const { int m = 1000; for (int i =0; i < head_l_arr_.size(); i++) - m = m position_i_; + m = m position_i_; return m; } @@ -32,20 +32,22 @@ Stem::max_head_i() const { int m = -1000; for (int i =0; i < head_l_arr_.size(); i++) - m = m >? head_l_arr_[i]->position_i_; + m = m >? head_l_arr_[i]->position_i_; return m; } - -Stem::Stem (int c) +/* + TODO: staff-size + */ +Stem::Stem () { beams_left_i_ = 0; beams_right_i_ = 0; stem_bottom_f_ = stem_top_f_ = 0; flag_i_ = 4; - dir_i_ =0; - staff_size_i_ = c; + dir_ =CENTER; + staff_size_i_ = 8; print_flag_b_=true; stem_xoffset_f_ =0; @@ -63,21 +65,21 @@ Stem::do_print() const } Real -Stem::stem_length_f()const +Stem::stem_length_f() const { return stem_top_f_-stem_bottom_f_ ; } Real -Stem::stem_start_f()const +Stem::stem_start_f() const { - return (dir_i_ < 0)? stem_top_f_ : stem_bottom_f_; + return (dir_ < 0)? stem_top_f_ : stem_bottom_f_; } Real Stem::stem_end_f() const { - return (dir_i_ < 0)? stem_bottom_f_ : stem_top_f_; + return (dir_ < 0)? stem_bottom_f_ : stem_top_f_; } @@ -85,12 +87,12 @@ void Stem::set_stemend (Real se) { // todo: margins - if (! ((dir_i_ > 0 && se >= max_head_i()) || - (se <= min_head_i() && dir_i_ <0)) ) - warning ("Weird stem size; check for narrow beams"); + if (! ((dir_ > 0 && se >= max_head_i()) || + (se <= min_head_i() && dir_ <0))) + warning ("Weird stem size; check for narrow beams"); - stem_top_f_ = (dir_i_ < 0) ? max_head_i() : se; - stem_bottom_f_ = (dir_i_ < 0) ? se : min_head_i(); + stem_top_f_ = (dir_ < 0) ? max_head_i() : se; + stem_bottom_f_ = (dir_ < 0) ? se : min_head_i(); } void @@ -99,83 +101,83 @@ Stem::add (Note_head *n) n->add_dependency (this); if (n->rest_b_) { - rest_l_arr_.push (n); + rest_l_arr_.push (n); } else if (n->balltype_i_ == 0) { - whole_l_arr_.push (n); - return; + whole_l_arr_.push (n); + return; } else { - head_l_arr_.push (n); + head_l_arr_.push (n); } } bool -Stem::invisible_b()const +Stem::invisible_b() const { return !head_l_arr_.size(); } -// if dir_i_ is set we return fake values. +// if dir_ is set we return fake values. int Stem::get_center_distance_from_top() { - if (dir_i_) - return (dir_i_ > 0) ? 0 : 1; + if (dir_) + return (dir_ > 0) ? 0 : 1; int staff_center = staff_size_i_ / 2; int max = max_head_i() - staff_center; return max >? 0; } -// if dir_i_ is set we return fake values. +// if dir_ is set we return fake values. int Stem::get_center_distance_from_bottom() { - if (dir_i_) - return (dir_i_ > 0) ? 1 : 0; + if (dir_) + return (dir_ > 0) ? 1 : 0; int staff_center = staff_size_i_ / 2; int min = staff_center - min_head_i(); return min >? 0; } -int +Direction Stem::get_default_dir() { - if (dir_i_) - return dir_i_; + if (dir_) + return dir_; return (get_center_distance_from_top() >= - get_center_distance_from_bottom()) ? -1 : 1; + get_center_distance_from_bottom()) ? -1 : 1; } void Stem::set_default_dir() { - dir_i_ = get_default_dir(); + dir_ = get_default_dir(); } void Stem::set_default_stemlen() { - if (!dir_i_) - set_default_dir(); + if (!dir_) + set_default_dir(); // ugh... how about non 5-line staffs? - if ((max_head_i() < -2 && dir_i_ == 1) - ||(min_head_i() > staff_size_i_ && dir_i_ == -1)) - { - set_stemend (staff_size_i_ /2 -1); + if ((max_head_i() < -2 && dir_ == 1) + ||(min_head_i() > staff_size_i_ && dir_ == -1)) + { + set_stemend (staff_size_i_ /2 -1); } else { - set_stemend ((dir_i_ > 0) ? max_head_i() + STEMLEN : - min_head_i() - STEMLEN); + set_stemend ((dir_ > 0) ? max_head_i() + STEMLEN : + min_head_i() - STEMLEN); } } @@ -185,15 +187,15 @@ void Stem::set_default_extents() { if (!stem_length_f()) - set_default_stemlen(); + set_default_stemlen(); - set_stemend ((dir_i_< 0) ? - max_head_i()-stem_length_f (): min_head_i () +stem_length_f ()); - if (dir_i_ > 0){ - stem_xoffset_f_ = paper()->note_width ()-paper ()->rule_thickness (); - } + set_stemend ((dir_< 0) ? + max_head_i()-stem_length_f (): min_head_i () +stem_length_f ()); + if (dir_ > 0){ + stem_xoffset_f_ = paper()->note_width ()-paper ()->rule_thickness (); + } else - stem_xoffset_f_ = 0; + stem_xoffset_f_ = 0; } /* @@ -206,10 +208,10 @@ void Stem::set_noteheads() { if (!head_l_arr_.size()) - return; + return; head_l_arr_.sort (Note_head::compare); - if (dir_i_ < 0) - head_l_arr_.reverse(); + if (dir_ < 0) + head_l_arr_.reverse(); head_l_arr_[0]->extremal_i_ = -1; head_l_arr_.top()->extremal_i_ = 1; @@ -217,17 +219,17 @@ Stem::set_noteheads() int lastpos = head_l_arr_[0]->position_i_; for (int i=1; i < head_l_arr_.size(); i ++) { - int dy =abs (lastpos- head_l_arr_[i]->position_i_); + int dy =abs (lastpos- head_l_arr_[i]->position_i_); - if (dy <= 1) - { - if (parity) - head_l_arr_[i]->x_dir_i_ = (stem_xoffset_f_>0) ? 1:-1; - parity = !parity; - } - else - parity = 0; - lastpos = head_l_arr_[i]->position_i_; + if (dy <= 1) + { + if (parity) + head_l_arr_[i]->x_dir_ = (stem_xoffset_f_>0) ? UP:DOWN; + parity = !parity; + } + else + parity = 0; + lastpos = head_l_arr_[i]->position_i_; } } @@ -235,19 +237,19 @@ void Stem::do_pre_processing() { if (stem_bottom_f_== stem_top_f_) - set_default_extents(); + set_default_extents(); set_noteheads(); - flag_i_ = dir_i_*abs (flag_i_); + flag_i_ = dir_*abs (flag_i_); transparent_b_ = invisible_b(); empty_b_ = invisible_b(); } Interval -Stem::do_width()const +Stem::do_width() const { if (!print_flag_b_ || abs (flag_i_) <= 4) - return Interval (0,0); // TODO! + return Interval (0,0); // TODO! Paper_def*p= paper(); Interval r (p->lookup_l()->flag (flag_i_).dim.x ()); r+= stem_xoffset_f_; @@ -255,7 +257,7 @@ Stem::do_width()const } Molecule* -Stem::brew_molecule_p()const +Stem::brew_molecule_p() const { Molecule *out =0; @@ -273,17 +275,17 @@ Stem::brew_molecule_p()const if (print_flag_b_&&abs (flag_i_) > 4) { - Symbol fl = p->lookup_l()->flag (flag_i_); - Molecule m (fl); - if (flag_i_ < -4){ - out->add_bottom (m); - } - else if (flag_i_ > 4) - { - out->add_top (m); - } - else - assert (false); + Symbol fl = p->lookup_l()->flag (flag_i_); + Molecule m (fl); + if (flag_i_ < -4){ + out->add_bottom (m); + } + else if (flag_i_ > 4) + { + out->add_top (m); + } + else + assert (false); } out->translate (stem_xoffset_f_, X_AXIS); @@ -291,7 +293,7 @@ Stem::brew_molecule_p()const } Real -Stem::hpos_f()const +Stem::hpos_f() const { return Item::hpos_f() + stem_xoffset_f_; }