]> git.donarmstrong.com Git - lilypond.git/blob - lily/part-combine-engraver.cc
badc17c2f6f3cce94f46f1117598b18df297ea30
[lilypond.git] / lily / part-combine-engraver.cc
1 /*
2   part-combine-engraver.cc -- implement PC-engraver
3
4   source file of the GNU LilyPond music typesetter
5
6   (c) 2000--2007 Jan Nieuwenhuizen <janneke@gnu.org>
7
8   Han-Wen Nienhuys <hanwen@xs4all.nl>
9 */
10
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"
19
20 #include "translator.icc"
21
22 class Part_combine_engraver : public Engraver
23 {
24   TRANSLATOR_DECLARATIONS (Part_combine_engraver);
25
26 protected:
27   DECLARE_ACKNOWLEDGER (note_head);
28   DECLARE_ACKNOWLEDGER (stem);
29
30   DECLARE_TRANSLATOR_LISTENER (part_combine);
31   void process_music ();
32   void stop_translation_timestep ();
33 private:
34   Item *text_;
35   Stream_event *event_;
36 };
37
38 IMPLEMENT_TRANSLATOR_LISTENER (Part_combine_engraver, part_combine);
39 void
40 Part_combine_engraver::listen_part_combine (Stream_event *ev)
41 {
42   ASSIGN_EVENT_ONCE (event_, ev);
43 }
44
45 Part_combine_engraver::Part_combine_engraver ()
46 {
47   text_ = 0;
48   event_ = 0;
49 }
50
51 void
52 Part_combine_engraver::process_music ()
53 {
54   if (event_
55       && to_boolean (get_property ("printPartCombineTexts")))
56     {
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");
65
66       if (Text_interface::is_markup (text))
67         {
68           text_ = make_item ("CombineTextScript", event_->self_scm ());
69           text_->set_property ("text", text);
70         }
71     }
72 }
73
74 void
75 Part_combine_engraver::acknowledge_note_head (Grob_info i)
76 {
77   if (text_)
78     {
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);
84     }
85 }
86
87 void
88 Part_combine_engraver::acknowledge_stem (Grob_info i)
89 {
90   if (text_)
91     Side_position_interface::add_support (text_, i.grob ());
92 }
93
94 void
95 Part_combine_engraver::stop_translation_timestep ()
96 {
97   text_ = 0;
98   event_ = 0;
99 }
100
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}.",
107
108                 /* create */
109                 "CombineTextScript ",
110
111                 /* read */
112                 "printPartCombineTexts "
113                 "soloText "
114                 "soloIIText "
115                 "aDueText ",
116
117                 /* write */
118                 ""
119                 );