]> git.donarmstrong.com Git - lilypond.git/blob - lily/rhythmic-column-engraver.cc
release: 1.1.51
[lilypond.git] / lily / rhythmic-column-engraver.cc
1 /*
2   rhythmic-column-grav.cc -- implement Rhythmic_column_engraver
3
4   source file of the GNU LilyPond music typesetter
5
6   (c)  1997--1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7 */
8
9 #include "slur.hh"
10 #include "rhythmic-column-engraver.hh"
11 #include "note-head.hh"
12 #include "stem.hh"
13 #include "note-column.hh"
14 #include "dot-column.hh"
15 #include "musical-request.hh"
16
17 Rhythmic_column_engraver::Rhythmic_column_engraver()
18 {
19   stem_l_ =0;
20   ncol_p_=0;
21   dotcol_l_ =0;
22 }
23
24
25 void
26 Rhythmic_column_engraver::process_acknowledged ()
27 {
28   if (rhead_l_arr_.size ())
29     {
30       if (!ncol_p_)
31         {
32           ncol_p_ = new Note_column;
33           announce_element (Score_element_info (ncol_p_, 0));
34         }
35
36       for (int i=0; i < rhead_l_arr_.size (); i++)
37         {
38           if (!rhead_l_arr_[i]->dim_cache_[X_AXIS]->parent_l_)
39             ncol_p_->add_head (rhead_l_arr_[i]);
40         }
41       rhead_l_arr_.set_size (0);
42     }
43
44   
45   if (ncol_p_)
46     {
47       if (dotcol_l_
48           && !dotcol_l_->dim_cache_[X_AXIS]->parent_l_)
49         {
50           ncol_p_->set_dotcol (dotcol_l_);
51         }
52
53       if (stem_l_
54           && !stem_l_->dim_cache_[X_AXIS]->parent_l_)
55         {
56           ncol_p_->set_stem (stem_l_);
57           stem_l_ = 0;
58         }
59
60       /*
61         since ncol_p_ is announced, it already has its grace_scm_sym set, if we're
62         in a Grace context.
63        */
64       if (ncol_p_->get_elt_property (grace_scm_sym) == SCM_BOOL_F)
65         for (int i=0; i < grace_slur_endings_.size(); i++)
66           grace_slur_endings_[i]->add_column (ncol_p_);
67       grace_slur_endings_.clear ();
68     }
69 }
70
71 void
72 Rhythmic_column_engraver::acknowledge_element (Score_element_info i)
73 {
74   Item * item =  dynamic_cast <Item *> (i.elem_l_);
75   if (Stem*s=dynamic_cast<Stem *> (item))
76     {
77       stem_l_ = s;
78     }
79   else if (Rhythmic_head*r=dynamic_cast<Rhythmic_head *> (item))
80     {
81       rhead_l_arr_.push (r);
82     }
83   else if (Dot_column*d =dynamic_cast<Dot_column *> (item))
84     {
85       dotcol_l_ = d;
86     }
87   else if (Slur *s = dynamic_cast<Slur*> (i.elem_l_))
88     {
89       /*
90         end slurs starting on grace notes
91        */
92       
93       if (s->get_elt_property (grace_scm_sym) != SCM_BOOL_F)
94         grace_slur_endings_.push (s);
95    }
96 }
97
98 void
99 Rhythmic_column_engraver::do_pre_move_processing()
100 {
101   if (ncol_p_) 
102     {
103       Scalar sh = get_property ("horizontalNoteShift", 0);
104       // egcs
105       if (sh.to_bool () && sh.isnum_b ())
106         {
107           ncol_p_->set_elt_property (horizontal_shift_scm_sym,
108                                      gh_int2scm (int (sh)));
109         }
110
111       typeset_element (ncol_p_);
112       ncol_p_ =0;
113     }
114 }
115
116 void
117 Rhythmic_column_engraver::do_post_move_processing()
118 {
119   grace_slur_endings_.clear ();
120   dotcol_l_ =0;
121   stem_l_ =0;
122 }
123
124
125
126
127
128 ADD_THIS_TRANSLATOR(Rhythmic_column_engraver);