]> git.donarmstrong.com Git - lilypond.git/blob - lily/rhythmic-column-engraver.cc
release: 1.3.68
[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--2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7 */
8
9 #include "dimension-cache.hh"
10 #include "slur.hh"
11 #include "engraver.hh"
12 #include "rhythmic-head.hh"
13 #include "stem.hh"
14 #include "note-column.hh"
15 #include "dot-column.hh"
16 #include "musical-request.hh"
17
18 class Rhythmic_column_engraver :public Engraver
19 {
20   Link_array<Rhythmic_head> rhead_l_arr_;
21   Link_array<Slur> grace_slur_endings_;
22   Stem * stem_l_;
23   Note_column *ncol_p_;
24   Score_element *dotcol_l_;
25
26 protected:
27   VIRTUAL_COPY_CONS(Translator);
28   virtual void acknowledge_element (Score_element_info);
29   virtual void process_acknowledged ();
30   virtual void do_pre_move_processing();
31   virtual void do_post_move_processing();
32 public:
33   Rhythmic_column_engraver();
34   
35 };
36
37
38
39 Rhythmic_column_engraver::Rhythmic_column_engraver()
40 {
41   stem_l_ =0;
42   ncol_p_=0;
43   dotcol_l_ =0;
44 }
45
46
47 void
48 Rhythmic_column_engraver::process_acknowledged ()
49 {
50   if (rhead_l_arr_.size ())
51     {
52       if (!ncol_p_)
53         {
54           ncol_p_ = new Note_column (SCM_EOL);
55           announce_element (Score_element_info (ncol_p_, 0));
56         }
57
58       for (int i=0; i < rhead_l_arr_.size (); i++)
59         {
60           if (!rhead_l_arr_[i]->parent_l(X_AXIS))
61             ncol_p_->add_head (rhead_l_arr_[i]);
62         }
63       rhead_l_arr_.set_size (0);
64     }
65
66   
67   if (ncol_p_)
68     {
69       if (dotcol_l_
70           && !dotcol_l_->parent_l (X_AXIS))
71         {
72           ncol_p_->set_dotcol (dotcol_l_);
73         }
74
75       if (stem_l_
76           && !stem_l_->parent_l(X_AXIS))
77         {
78           ncol_p_->set_stem (stem_l_);
79           stem_l_ = 0;
80         }
81
82       SCM wg = get_property ("weAreGraceContext");
83       bool wegrace = to_boolean (wg);
84
85       if (!wegrace)
86         for (int i=0; i < grace_slur_endings_.size(); i++)
87           grace_slur_endings_[i]->add_column (ncol_p_);
88       grace_slur_endings_.clear ();
89     }
90 }
91
92 void
93 Rhythmic_column_engraver::acknowledge_element (Score_element_info i)
94 {
95   SCM wg = get_property ("weAreGraceContext");
96   bool wegrace = to_boolean (wg);
97   if ((wegrace !=
98       (i.elem_l_->get_elt_property ("grace") != SCM_UNDEFINED))
99     && !dynamic_cast<Slur*> (i.elem_l_))
100     return ;
101   
102   Item * item =  dynamic_cast <Item *> (i.elem_l_);
103   if (Stem*s=dynamic_cast<Stem *> (item))
104     {
105       stem_l_ = s;
106     }
107   else if (Rhythmic_head*r=dynamic_cast<Rhythmic_head *> (item))
108     {
109       rhead_l_arr_.push (r);
110     }
111   else if (item
112            && to_boolean (item->get_elt_property ("dot-column-interface")))
113     {
114       dotcol_l_ = item;
115     }
116   else if (Slur *s = dynamic_cast<Slur*> (i.elem_l_))
117     {
118       /*
119         end slurs starting on grace notes
120        */
121       
122       if (to_boolean (s->get_elt_property ("grace")))
123         grace_slur_endings_.push (s);
124    }
125 }
126
127 void
128 Rhythmic_column_engraver::do_pre_move_processing()
129 {
130   if (ncol_p_) 
131     {
132       typeset_element (ncol_p_);
133       ncol_p_ =0;
134     }
135 }
136
137 void
138 Rhythmic_column_engraver::do_post_move_processing()
139 {
140   grace_slur_endings_.clear ();
141   dotcol_l_ =0;
142   stem_l_ =0;
143 }
144
145 ADD_THIS_TRANSLATOR(Rhythmic_column_engraver);
146