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