lilypond-1.4.4
[lilypond.git] / lily / rhythmic-column-engraver.cc
blobf5287f998c96dbe382ababbe3988559e3e99b544
1 /*
2 rhythmic-column-grav.cc -- implement Rhythmic_column_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--2001 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7 */
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 #include "item.hh"
19 class Rhythmic_column_engraver :public Engraver
21 Link_array<Grob> rhead_l_arr_;
22 Link_array<Grob> grace_slur_endings_;
23 Grob * stem_l_;
24 Grob *ncol_p_;
25 Grob *dotcol_l_;
27 protected:
28 VIRTUAL_COPY_CONS (Translator);
29 virtual void acknowledge_grob (Grob_info);
30 virtual void create_grobs ();
31 virtual void stop_translation_timestep ();
32 virtual void start_translation_timestep ();
33 public:
34 Rhythmic_column_engraver ();
40 Rhythmic_column_engraver::Rhythmic_column_engraver ()
42 stem_l_ =0;
43 ncol_p_=0;
44 dotcol_l_ =0;
48 void
49 Rhythmic_column_engraver::create_grobs ()
51 if (rhead_l_arr_.size ())
53 if (!ncol_p_)
55 ncol_p_ = new Item (get_property ("NoteColumn"));
56 Note_column::set_interface (ncol_p_);
57 announce_grob (ncol_p_, 0);
60 for (int i=0; i < rhead_l_arr_.size (); i++)
62 if (!rhead_l_arr_[i]->parent_l (X_AXIS))
63 Note_column::add_head (ncol_p_, rhead_l_arr_[i]);
65 rhead_l_arr_.set_size (0);
69 if (ncol_p_)
71 if (dotcol_l_
72 && !dotcol_l_->parent_l (X_AXIS))
74 Note_column::set_dotcol (ncol_p_, dotcol_l_);
77 if (stem_l_
78 && !stem_l_->parent_l (X_AXIS))
80 Note_column::set_stem (ncol_p_, stem_l_);
81 stem_l_ = 0;
84 SCM wg = get_property ("weAreGraceContext");
85 bool wegrace = to_boolean (wg);
87 if (!wegrace)
88 for (int i=0; i < grace_slur_endings_.size (); i++)
89 Slur::add_column (grace_slur_endings_[i], ncol_p_);
90 grace_slur_endings_.clear ();
94 void
95 Rhythmic_column_engraver::acknowledge_grob (Grob_info i)
97 SCM wg = get_property ("weAreGraceContext");
98 bool wegrace = to_boolean (wg);
99 if (wegrace != to_boolean (i.elem_l_->get_grob_property ("grace"))
100 && !Slur::has_interface (i.elem_l_))
101 return ;
103 Item * item = dynamic_cast <Item *> (i.elem_l_);
104 if (item && Stem::has_interface (item))
106 stem_l_ = item;
108 else if (item && Rhythmic_head::has_interface (item))
110 rhead_l_arr_.push (item);
112 else if (item && Dot_column::has_interface (item))
114 dotcol_l_ = item;
116 else if (Slur::has_interface (i.elem_l_))
119 end slurs starting on grace notes
122 if (to_boolean (i.elem_l_->get_grob_property ("grace")))
123 grace_slur_endings_.push (i.elem_l_);
127 void
128 Rhythmic_column_engraver::stop_translation_timestep ()
130 if (ncol_p_)
132 typeset_grob (ncol_p_);
133 ncol_p_ =0;
137 void
138 Rhythmic_column_engraver::start_translation_timestep ()
140 grace_slur_endings_.clear ();
141 dotcol_l_ =0;
142 stem_l_ =0;
145 ADD_THIS_TRANSLATOR (Rhythmic_column_engraver);