lilypond-1.3.69
[lilypond.git] / lily / note-column-grav.cc
bloba77557793e876a84f513688874ab8582c451cb4f
1 /*
2 note-column-reg.cc -- implement Note_column_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
7 */
9 #include "note-column-grav.hh"
10 #include "note-head.hh"
11 #include "stem.hh"
12 #include "note-column.hh"
13 #include "script.hh"
14 #include "rest-column.hh"
16 bool
17 Note_column_engraver::acceptable_elem_b (Score_elem const*elem_C) const
19 char const*nC = elem_C->name();
20 return (nC == Script::static_name() || nC == Note_head::static_name ()
21 || nC == Stem::static_name());
23 Note_column*
24 Note_column_engraver::note_col_l()
26 if (!ncol_p_)
28 ncol_p_ = new Note_column;
29 announce_element (Score_elem_info (ncol_p_, 0));
31 return ncol_p_;
34 Rest_column *
35 Note_column_engraver::rest_col_l()
37 if (!restcol_p_)
39 restcol_p_ = new Rest_column;
40 announce_element (Score_elem_info (restcol_p_,0));
42 return restcol_p_;
45 void
46 Note_column_engraver::acknowledge_element (Score_elem_info i)
48 if (!acceptable_elem_b (i.elem_l_))
49 return;
52 char const*nC = i.elem_l_->name();
54 if (nC == Script::static_name() && i.req_l_ && i.req_l_->musical ())
56 script_l_arr_.push ((Script*)i.elem_l_->item());
58 else if (nC == Note_head::static_name())
60 Note_head * h_l = (Note_head*)i.elem_l_->item();
61 if (h_l->rest_b_)
62 rest_col_l()->add (h_l);
63 else
64 note_col_l()->add (h_l);
67 else if (nC == Stem::static_name())
69 stem_l_ = (Stem*)i.elem_l_->item();
72 if (ncol_p_ || restcol_p_)
74 if (stem_l_)
76 if (restcol_p_&& !restcol_p_->stem_l_)
77 restcol_p_->set (stem_l_);
78 if (ncol_p_ && !ncol_p_->stem_l_)
79 ncol_p_->set (stem_l_);
83 for (int i=0; i < script_l_arr_.size(); i++)
85 if (restcol_p_)
86 restcol_p_->add (script_l_arr_[i]);
87 if (ncol_p_)
88 ncol_p_->add (script_l_arr_[i]);
91 script_l_arr_.clear();
96 void
97 Note_column_engraver::do_pre_move_processing()
99 if (ncol_p_)
101 if (! ncol_p_->h_shift_b_)
102 ncol_p_->h_shift_b_ = h_shift_b_;
103 if (! ncol_p_->dir_)
104 ncol_p_->dir_ = dir_;
106 typeset_element (ncol_p_);
107 ncol_p_ =0;
109 if (restcol_p_)
111 if (! restcol_p_->dir_)
112 restcol_p_->dir_ = dir_;
114 typeset_element (restcol_p_);
115 restcol_p_ =0;
119 void
120 Note_column_engraver::do_post_move_processing()
122 script_l_arr_.clear();
123 stem_l_ =0;
126 void
127 Note_column_engraver::set_feature (Feature i)
129 if (i.type_ == "vdir")
130 dir_ = (Direction) int(i.value_);
131 if (i.type_ == "hshift")
132 h_shift_b_ = (bool)(int)i.value_;
135 Note_column_engraver::Note_column_engraver()
137 dir_ =CENTER;
138 h_shift_b_ = false;
140 ncol_p_=0;
141 restcol_p_ =0;
142 do_post_move_processing();
146 IMPLEMENT_IS_TYPE_B1(Note_column_engraver,Engraver);
147 ADD_THIS_ENGRAVER(Note_column_engraver);