Change short-indent behaviour.
[lilypond.git] / lily / part-combine-engraver.cc
blobbadc17c2f6f3cce94f46f1117598b18df297ea30
1 /*
2 part-combine-engraver.cc -- implement PC-engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 2000--2007 Jan Nieuwenhuizen <janneke@gnu.org>
8 Han-Wen Nienhuys <hanwen@xs4all.nl>
9 */
11 #include "engraver.hh"
12 #include "multi-measure-rest.hh"
13 #include "note-head.hh"
14 #include "side-position-interface.hh"
15 #include "stem.hh"
16 #include "stream-event.hh"
17 #include "text-interface.hh"
18 #include "item.hh"
20 #include "translator.icc"
22 class Part_combine_engraver : public Engraver
24 TRANSLATOR_DECLARATIONS (Part_combine_engraver);
26 protected:
27 DECLARE_ACKNOWLEDGER (note_head);
28 DECLARE_ACKNOWLEDGER (stem);
30 DECLARE_TRANSLATOR_LISTENER (part_combine);
31 void process_music ();
32 void stop_translation_timestep ();
33 private:
34 Item *text_;
35 Stream_event *event_;
38 IMPLEMENT_TRANSLATOR_LISTENER (Part_combine_engraver, part_combine);
39 void
40 Part_combine_engraver::listen_part_combine (Stream_event *ev)
42 ASSIGN_EVENT_ONCE (event_, ev);
45 Part_combine_engraver::Part_combine_engraver ()
47 text_ = 0;
48 event_ = 0;
51 void
52 Part_combine_engraver::process_music ()
54 if (event_
55 && to_boolean (get_property ("printPartCombineTexts")))
57 SCM what = event_->get_property ("class");
58 SCM text = SCM_EOL;
59 if (what == ly_symbol2scm ("solo-one-event"))
60 text = get_property ("soloText");
61 else if (what == ly_symbol2scm ("solo-two-event"))
62 text = get_property ("soloIIText");
63 else if (what == ly_symbol2scm ("unisono-event"))
64 text = get_property ("aDueText");
66 if (Text_interface::is_markup (text))
68 text_ = make_item ("CombineTextScript", event_->self_scm ());
69 text_->set_property ("text", text);
74 void
75 Part_combine_engraver::acknowledge_note_head (Grob_info i)
77 if (text_)
79 Grob *t = text_;
80 Side_position_interface::add_support (t, i.grob ());
81 if (Side_position_interface::get_axis (t) == X_AXIS
82 && !t->get_parent (Y_AXIS))
83 t->set_parent (i.grob (), Y_AXIS);
87 void
88 Part_combine_engraver::acknowledge_stem (Grob_info i)
90 if (text_)
91 Side_position_interface::add_support (text_, i.grob ());
94 void
95 Part_combine_engraver::stop_translation_timestep ()
97 text_ = 0;
98 event_ = 0;
101 ADD_ACKNOWLEDGER (Part_combine_engraver, note_head);
102 ADD_ACKNOWLEDGER (Part_combine_engraver, stem);
103 ADD_TRANSLATOR (Part_combine_engraver,
104 /* doc */
105 "Part combine engraver for orchestral scores: Print markings"
106 " @q{a2}, @q{Solo}, @q{Solo II}, and @q{unisono}.",
108 /* create */
109 "CombineTextScript ",
111 /* read */
112 "printPartCombineTexts "
113 "soloText "
114 "soloIIText "
115 "aDueText ",
117 /* write */