]> git.donarmstrong.com Git - lilypond.git/blob - lily/rhythmic-column-engraver.cc
release: 1.3.0
[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 Rhythmic_column_engraver::Rhythmic_column_engraver()
19 {
20   stem_l_ =0;
21   ncol_p_=0;
22   dotcol_l_ =0;
23 }
24
25
26 void
27 Rhythmic_column_engraver::process_acknowledged ()
28 {
29   if (rhead_l_arr_.size ())
30     {
31       if (!ncol_p_)
32         {
33           ncol_p_ = new Note_column;
34           announce_element (Score_element_info (ncol_p_, 0));
35         }
36
37       for (int i=0; i < rhead_l_arr_.size (); i++)
38         {
39           if (!rhead_l_arr_[i]->parent_l(X_AXIS))
40             ncol_p_->add_head (rhead_l_arr_[i]);
41         }
42       rhead_l_arr_.set_size (0);
43     }
44
45   
46   if (ncol_p_)
47     {
48       if (dotcol_l_
49           && !dotcol_l_->parent_l(X_AXIS))
50         {
51           ncol_p_->set_dotcol (dotcol_l_);
52         }
53
54       if (stem_l_
55           && !stem_l_->parent_l(X_AXIS))
56         {
57           ncol_p_->set_stem (stem_l_);
58           stem_l_ = 0;
59         }
60
61       SCM wg = get_property ("weAreGraceContext",0);
62       bool wegrace = gh_boolean_p (wg) && gh_scm2bool (wg);
63
64       if (!wegrace)
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   SCM wg = get_property ("weAreGraceContext",0);
75   bool wegrace = gh_boolean_p (wg) && gh_scm2bool (wg);
76   if ((wegrace !=
77       (i.elem_l_->get_elt_property (grace_scm_sym) != SCM_BOOL_F))
78     && !dynamic_cast<Slur*> (i.elem_l_))
79     return ;
80   
81   Item * item =  dynamic_cast <Item *> (i.elem_l_);
82   if (Stem*s=dynamic_cast<Stem *> (item))
83     {
84       stem_l_ = s;
85     }
86   else if (Rhythmic_head*r=dynamic_cast<Rhythmic_head *> (item))
87     {
88       rhead_l_arr_.push (r);
89     }
90   else if (Dot_column*d =dynamic_cast<Dot_column *> (item))
91     {
92       dotcol_l_ = d;
93     }
94   else if (Slur *s = dynamic_cast<Slur*> (i.elem_l_))
95     {
96       /*
97         end slurs starting on grace notes
98        */
99       
100       if (s->get_elt_property (grace_scm_sym) != SCM_BOOL_F)
101         grace_slur_endings_.push (s);
102    }
103 }
104
105 void
106 Rhythmic_column_engraver::do_pre_move_processing()
107 {
108   if (ncol_p_) 
109     {
110       SCM sh = get_property ("horizontalNoteShift", 0);
111       if (SCM_NUMBERP(sh))
112         {
113           ncol_p_->set_elt_property (horizontal_shift_scm_sym, sh);
114         }
115
116       sh = get_property ("forceHorizontalShift" ,0);
117       if (SCM_NUMBERP(sh))
118         {
119           ncol_p_->set_elt_property (force_hshift_scm_sym, sh);
120         }
121
122       typeset_element (ncol_p_);
123       ncol_p_ =0;
124     }
125 }
126
127 void
128 Rhythmic_column_engraver::do_post_move_processing()
129 {
130   grace_slur_endings_.clear ();
131   dotcol_l_ =0;
132   stem_l_ =0;
133 }
134
135 ADD_THIS_TRANSLATOR(Rhythmic_column_engraver);