]> git.donarmstrong.com Git - lilypond.git/blob - lily/rhythmic-column-grav.cc
af3238c0f9510ec508d13e19ba66398c3ff51b09
[lilypond.git] / lily / rhythmic-column-grav.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 Han-Wen Nienhuys <hanwen@stack.nl>
7 */
8
9 #include "rhythmic-column-grav.hh"
10 #include "note-head.hh"
11 #include "stem.hh"
12 #include "note-column.hh"
13 #include "script.hh"
14 #include "dot-column.hh"
15
16 Rhythmic_column_engraver::Rhythmic_column_engraver()
17 {
18   stem_l_ =0;
19   ncol_p_=0;
20   dotcol_p_ =0;
21 }
22
23
24 void
25 Rhythmic_column_engraver::acknowledge_element (Score_elem_info i)
26 {
27   if (i.elem_l_->is_type_b (Script::static_name ())
28       && i.req_l_ && i.req_l_->musical ()) 
29     {
30       script_l_arr_.push ((Script*)i.elem_l_->item());
31     }
32   else if (i.elem_l_->is_type_b (Stem::static_name()))
33     {
34       stem_l_ = (Stem*) i.elem_l_->item();
35     }
36   else if (i.elem_l_->is_type_b (Rhythmic_head::static_name ()))
37     {
38       Rhythmic_head * r = (Rhythmic_head*)i.elem_l_->item ();
39       if (!ncol_p_)
40         {
41           ncol_p_ = new Note_column;
42           announce_element (Score_elem_info (ncol_p_, 0));
43         }
44       ncol_p_->add (r);
45
46       if (r->dots_l_)
47         {
48           if (!dotcol_p_)
49             {
50               dotcol_p_ = new Dot_column;
51               ncol_p_->set (dotcol_p_);
52               announce_element (Score_elem_info (dotcol_p_, 0));
53             }
54           dotcol_p_->add (r);
55         }
56     }
57   
58   if (ncol_p_)
59     {
60       if (stem_l_&& !ncol_p_->stem_l_) 
61         ncol_p_->set (stem_l_);
62   
63       for (int i=0; i < script_l_arr_.size(); i++) 
64         {
65           if (ncol_p_)
66             ncol_p_->add (script_l_arr_[i]);
67         }
68   
69       script_l_arr_.clear();
70     }
71 }
72
73 void
74 Rhythmic_column_engraver::do_pre_move_processing()
75 {
76   if (ncol_p_) 
77     {
78       if (! ncol_p_->h_shift_b_)
79         ncol_p_->h_shift_b_  = (bool) get_property ("hshift");
80       if (! ncol_p_->dir_)
81         ncol_p_->dir_ =(Direction) int(get_property ("ydirection"));
82
83       typeset_element (ncol_p_);
84       ncol_p_ =0;
85     }
86   if (dotcol_p_)
87     {
88       typeset_element (dotcol_p_);
89       dotcol_p_ =0;
90     }
91 }
92
93 void
94 Rhythmic_column_engraver::do_post_move_processing()
95 {
96   script_l_arr_.clear();
97   stem_l_ =0;
98 }
99
100
101
102
103 IMPLEMENT_IS_TYPE_B1(Rhythmic_column_engraver,Engraver);
104 ADD_THIS_TRANSLATOR(Rhythmic_column_engraver);