]> git.donarmstrong.com Git - lilypond.git/blob - lily/part-combine-engraver.cc
(parse_symbol_list): Bugfix.
[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--2005 Jan Nieuwenhuizen <janneke@gnu.org>
7
8   Han-Wen Nienhuys <hanwen@xs4all.nl>
9 */
10
11 #include "engraver.hh"
12 #include "text-interface.hh"
13 #include "note-head.hh"
14 #include "stem.hh"
15 #include "side-position-interface.hh"
16 #include "multi-measure-rest.hh"
17
18 class Part_combine_engraver : public Engraver
19 {
20   TRANSLATOR_DECLARATIONS (Part_combine_engraver);
21
22 protected:
23   DECLARE_ACKNOWLEDGER (note_head);
24   DECLARE_ACKNOWLEDGER (stem);
25
26   void process_music ();
27   void stop_translation_timestep ();
28   virtual bool try_music (Music *);
29 private:
30   Item *text_;
31   Music *event_;
32 };
33
34 bool
35 Part_combine_engraver::try_music (Music *m)
36 {
37   event_ = m;
38   return true;
39 }
40
41 Part_combine_engraver::Part_combine_engraver ()
42 {
43   text_ = 0;
44   event_ = 0;
45 }
46
47 void
48 Part_combine_engraver::process_music ()
49 {
50   if (event_
51       && to_boolean (get_property ("printPartCombineTexts")))
52     {
53       SCM what = event_->get_property ("part-combine-status");
54       SCM text = SCM_EOL;
55       if (what == ly_symbol2scm ("solo1"))
56         text = get_property ("soloText");
57       else if (what == ly_symbol2scm ("solo2"))
58         text = get_property ("soloIIText");
59       else if (what == ly_symbol2scm ("unisono"))
60         text = get_property ("aDueText");
61
62       if (Text_interface::is_markup (text))
63         {
64           text_ = make_item ("CombineTextScript", event_->self_scm ());
65           text_->set_property ("text", text);
66         }
67     }
68 }
69
70 void
71 Part_combine_engraver::acknowledge_note_head (Grob_info i)
72 {
73   if (text_)
74     {
75       Grob *t = text_;
76       Side_position_interface::add_support (t, i.grob ());
77       if (Side_position_interface::get_axis (t) == X_AXIS
78           && !t->get_parent (Y_AXIS))
79         t->set_parent (i.grob (), Y_AXIS);
80     }
81 }
82
83 void
84 Part_combine_engraver::acknowledge_stem (Grob_info i)
85 {
86   if (text_)
87     Side_position_interface::add_support (text_, i.grob ());
88 }
89
90 void
91 Part_combine_engraver::stop_translation_timestep ()
92 {
93   text_ = 0;
94   event_ = 0;
95 }
96
97 #include "translator.icc"
98 ADD_ACKNOWLEDGER (Part_combine_engraver, note_head);
99 ADD_ACKNOWLEDGER (Part_combine_engraver, stem);
100 ADD_TRANSLATOR (Part_combine_engraver,
101                 /* doc */ "Part combine engraver for orchestral scores:         "
102                 "Print markings a2, Solo, Solo II, and unisono ",
103                 /* create */ "CombineTextScript",
104                 /* accept */ "part-combine-event",
105                 /* read */ "printPartCombineTexts soloText soloIIText "
106                 "aDueText",
107                 /* write */ "");