]> git.donarmstrong.com Git - lilypond.git/blob - lily/part-combine-engraver.cc
284f7616c7226befc52faa368370c0bb515c7cd0
[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--2006 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
19 #include "translator.icc"
20
21 class Part_combine_engraver : public Engraver
22 {
23   TRANSLATOR_DECLARATIONS (Part_combine_engraver);
24
25 protected:
26   DECLARE_ACKNOWLEDGER (note_head);
27   DECLARE_ACKNOWLEDGER (stem);
28
29   DECLARE_TRANSLATOR_LISTENER (part_combine);
30   void process_music ();
31   void stop_translation_timestep ();
32 private:
33   Item *text_;
34   Stream_event *event_;
35 };
36
37 IMPLEMENT_TRANSLATOR_LISTENER (Part_combine_engraver, part_combine);
38 void
39 Part_combine_engraver::listen_part_combine (Stream_event *ev)
40 {
41   ASSIGN_EVENT_ONCE (event_, ev);
42 }
43
44 Part_combine_engraver::Part_combine_engraver ()
45 {
46   text_ = 0;
47   event_ = 0;
48 }
49
50 void
51 Part_combine_engraver::process_music ()
52 {
53   if (event_
54       && to_boolean (get_property ("printPartCombineTexts")))
55     {
56       SCM what = event_->get_property ("class");
57       SCM text = SCM_EOL;
58       if (what == ly_symbol2scm ("solo-one-event"))
59         text = get_property ("soloText");
60       else if (what == ly_symbol2scm ("solo-two-event"))
61         text = get_property ("soloIIText");
62       else if (what == ly_symbol2scm ("unisono-event"))
63         text = get_property ("aDueText");
64
65       if (Text_interface::is_markup (text))
66         {
67           text_ = make_item ("CombineTextScript", event_->self_scm ());
68           text_->set_property ("text", text);
69         }
70     }
71 }
72
73 void
74 Part_combine_engraver::acknowledge_note_head (Grob_info i)
75 {
76   if (text_)
77     {
78       Grob *t = text_;
79       Side_position_interface::add_support (t, i.grob ());
80       if (Side_position_interface::get_axis (t) == X_AXIS
81           && !t->get_parent (Y_AXIS))
82         t->set_parent (i.grob (), Y_AXIS);
83     }
84 }
85
86 void
87 Part_combine_engraver::acknowledge_stem (Grob_info i)
88 {
89   if (text_)
90     Side_position_interface::add_support (text_, i.grob ());
91 }
92
93 void
94 Part_combine_engraver::stop_translation_timestep ()
95 {
96   text_ = 0;
97   event_ = 0;
98 }
99
100 ADD_ACKNOWLEDGER (Part_combine_engraver, note_head);
101 ADD_ACKNOWLEDGER (Part_combine_engraver, stem);
102 ADD_TRANSLATOR (Part_combine_engraver,
103                 /* doc */ "Part combine engraver for orchestral scores:         "
104                 "Print markings a2, Solo, Solo II, and unisono ",
105                 /* create */ "CombineTextScript",
106                 /* accept */ "part-combine-event",
107                 /* read */ "printPartCombineTexts soloText soloIIText "
108                 "aDueText",
109                 /* write */ "");