]> git.donarmstrong.com Git - lilypond.git/blob - lily/note-column-grav.cc
release: 0.0.73pre
[lilypond.git] / lily / note-column-grav.cc
1 /*
2   note-column-reg.cc -- implement Note_column_engraver
3
4   source file of the GNU LilyPond music typesetter
5
6   (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
7 */
8
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"
15
16 bool
17 Note_column_engraver::acceptable_elem_b(Score_elem const*elem_C)const
18 {
19     char const*nC = elem_C->name();
20     return (nC == Script::static_name() || nC == Note_head::static_name() 
21             || nC == Stem::static_name());
22 }
23 Note_column*
24 Note_column_engraver::note_col_l()
25 {
26     if (!ncol_p_){
27         ncol_p_ = new Note_column;
28         announce_element(Score_elem_info(ncol_p_, 0));
29     }
30     return ncol_p_;
31 }
32
33 Rest_column *
34 Note_column_engraver::rest_col_l()
35 {
36     if (!restcol_p_) {
37         restcol_p_  = new Rest_column;
38         announce_element(Score_elem_info(restcol_p_,0));
39     }
40     return restcol_p_;
41 }
42
43 void
44 Note_column_engraver::acknowledge_element(Score_elem_info i)
45 {
46     if (!acceptable_elem_b(i.elem_l_))
47         return;
48
49
50     char const*nC = i.elem_l_->name();
51
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);
60     }
61     else if (nC == Stem::static_name()){ 
62         stem_l_ = (Stem*)i.elem_l_->item();
63     }
64 }
65
66 void
67 Note_column_engraver::do_pre_move_processing()
68 {
69     Script_column *col_l = ( ncol_p_ ) ? ncol_p_ : restcol_p_;
70     if (!col_l)
71         return;
72     
73     for (int i=0; i < script_l_arr_.size(); i++)
74         col_l->add(script_l_arr_[i]);
75     
76     if (stem_l_) {
77         if (ncol_p_)
78             ncol_p_->add(stem_l_);
79         if (restcol_p_)
80             restcol_p_->add(stem_l_);
81     }
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;
87     }
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;
95     }
96 }
97
98 void
99 Note_column_engraver::do_post_move_processing()
100 {
101     script_l_arr_.set_size(0);
102     stem_l_ =0;
103 }
104
105 void
106 Note_column_engraver::set_feature(Feature i)
107 {
108      if (i.type_ == "vdir")     
109         dir_i_ = i.value_;
110      if (i.type_ == "hshift")
111          h_shift_b_ = (bool)(int)i.value_;
112 }
113
114 Note_column_engraver::Note_column_engraver()
115 {
116     dir_i_ =0;
117     h_shift_b_ = false;
118     
119     ncol_p_=0;
120     restcol_p_ =0;
121     do_post_move_processing();
122 }
123 IMPLEMENT_STATIC_NAME(Note_column_engraver);
124 IMPLEMENT_IS_TYPE_B1(Note_column_engraver,Engraver);
125 ADD_THIS_ENGRAVER(Note_column_engraver);