]> git.donarmstrong.com Git - lilypond.git/blob - lily/note-column-reg.cc
release: 0.0.63
[lilypond.git] / lily / note-column-reg.cc
1 /*
2   note-column-reg.cc -- implement Note_column_register
3
4   source file of the LilyPond music typesetter
5
6   (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
7 */
8
9 #include "note-column-reg.hh"
10 #include "notehead.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_register::acceptable_elem_b(Staff_elem const*elem_C)const
18 {
19     char const*nC = elem_C->name();
20     return (nC == Script::static_name() || nC == Notehead::static_name() 
21             || nC == Stem::static_name());
22 }
23 Note_column*
24 Note_column_register::note_col_l()
25 {
26     if (!ncol_p_){
27         ncol_p_ = new Note_column;
28         announce_element(Staff_elem_info(ncol_p_, 0));
29     }
30     return ncol_p_;
31 }
32
33 Rest_column *
34 Note_column_register::rest_col_l()
35 {
36     if (!restcol_p_) {
37         restcol_p_  = new Rest_column;
38         announce_element(Staff_elem_info(restcol_p_,0));
39     }
40     return restcol_p_;
41 }
42
43 void
44 Note_column_register::acknowledge_element(Staff_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_);
54     } else if (nC == Notehead::static_name()) {
55         Notehead * h_l = (Notehead*)i.elem_l_;
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_;
63     }
64 }
65
66 void
67 Note_column_register::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 (ncol_p_&&stem_l_)
77         ncol_p_->add(stem_l_);
78     if (restcol_p_) {
79         if (! restcol_p_ -> dir_i_)
80             restcol_p_->dir_i_ = dir_i_;
81         typeset_element(restcol_p_);
82         restcol_p_ =0;
83     }
84     if (ncol_p_) {
85         if (!   ncol_p_->dir_i_ )
86             ncol_p_->dir_i_ = dir_i_;
87         if (! ncol_p_->h_shift_b_)
88             ncol_p_->h_shift_b_ = h_shift_b_;
89         typeset_element(ncol_p_);
90         ncol_p_ =0;
91     }
92 }
93
94 void
95 Note_column_register::post_move_processing()
96 {
97     script_l_arr_.set_size(0);
98     stem_l_ =0;
99 }
100
101 void
102 Note_column_register::set_feature(Feature i)
103 {
104      if (i.type_ == "vdir")     
105         dir_i_ = i.value_;
106      if (i.type_ == "hshift")
107          h_shift_b_ = i.value_;
108 }
109
110 Note_column_register::Note_column_register()
111 {
112     dir_i_ =0;
113     h_shift_b_ = false;
114     
115     ncol_p_=0;
116     restcol_p_ =0;
117     post_move_processing();
118 }
119 IMPLEMENT_STATIC_NAME(Note_column_register);
120 ADD_THIS_REGISTER(Note_column_register);