lilypond-1.3.7
[lilypond.git] / lily / note-column-reg.cc
blob44142ac9a703dd88d88f20894193267e802f39d3
1 /*
2 note-column-reg.cc -- implement Note_column_register
4 source file of the GNU LilyPond music typesetter
6 (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
7 */
9 #include "note-column-reg.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_register::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_register::note_col_l()
26 if (!ncol_p_){
27 ncol_p_ = new Note_column;
28 announce_element(Score_elem_info(ncol_p_, 0));
30 return ncol_p_;
33 Rest_column *
34 Note_column_register::rest_col_l()
36 if (!restcol_p_) {
37 restcol_p_ = new Rest_column;
38 announce_element(Score_elem_info(restcol_p_,0));
40 return restcol_p_;
43 void
44 Note_column_register::acknowledge_element(Score_elem_info i)
46 if (!acceptable_elem_b(i.elem_l_))
47 return;
50 char const*nC = i.elem_l_->name();
52 if (nC == Script::static_name()) {
53 script_l_arr_.push((Script*)i.elem_l_->item());
54 } else if (nC == Note_head::static_name()) {
55 Note_head * h_l = (Note_head*)i.elem_l_->item();
56 if (h_l->rest_b_)
57 rest_col_l()->add(h_l);
58 else
59 note_col_l()->add(h_l);
61 else if (nC == Stem::static_name()){
62 stem_l_ = (Stem*)i.elem_l_->item();
66 void
67 Note_column_register::do_pre_move_processing()
69 Script_column *col_l = ( ncol_p_ ) ? ncol_p_ : restcol_p_;
70 if (!col_l)
71 return;
73 for (int i=0; i < script_l_arr_.size(); i++)
74 col_l->add(script_l_arr_[i]);
76 if (stem_l_) {
77 if (ncol_p_)
78 ncol_p_->add(stem_l_);
79 if (restcol_p_)
80 restcol_p_->add(stem_l_);
82 if (restcol_p_) {
83 if (! restcol_p_ -> dir_i_)
84 restcol_p_->dir_i_ = dir_i_;
85 typeset_element(restcol_p_);
86 restcol_p_ =0;
88 if (ncol_p_) {
89 if (! ncol_p_->dir_i_ )
90 ncol_p_->dir_i_ = dir_i_;
91 if (! ncol_p_->h_shift_b_)
92 ncol_p_->h_shift_b_ = h_shift_b_;
93 typeset_element(ncol_p_);
94 ncol_p_ =0;
98 void
99 Note_column_register::do_post_move_processing()
101 script_l_arr_.set_size(0);
102 stem_l_ =0;
105 void
106 Note_column_register::set_feature(Feature i)
108 if (i.type_ == "vdir")
109 dir_i_ = i.value_;
110 if (i.type_ == "hshift")
111 h_shift_b_ = (bool)(int)i.value_;
114 Note_column_register::Note_column_register()
116 dir_i_ =0;
117 h_shift_b_ = false;
119 ncol_p_=0;
120 restcol_p_ =0;
121 do_post_move_processing();
123 IMPLEMENT_STATIC_NAME(Note_column_register);
124 IMPLEMENT_IS_TYPE_B1(Note_column_register,Request_register);
125 ADD_THIS_REGISTER(Note_column_register);