]> git.donarmstrong.com Git - lilypond.git/blob - lily/part-combine-engraver.cc
* flower
[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-item.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   virtual void acknowledge_grob (Grob_info);
24   virtual void process_music ();
25   virtual void stop_translation_timestep ();
26   virtual bool try_music (Music *);
27 private:
28   Item *text_;
29   Music *event_;
30 };
31
32 bool
33 Part_combine_engraver::try_music (Music *m)
34 {
35   event_ = m;
36   return true;
37 }
38
39 Part_combine_engraver::Part_combine_engraver ()
40 {
41   text_ = 0;
42   event_ = 0;
43 }
44
45 void
46 Part_combine_engraver::process_music ()
47 {
48   if (event_
49       && to_boolean (get_property ("printPartCombineTexts")))
50     {
51       SCM what = event_->get_property ("part-combine-status");
52       SCM text = SCM_EOL;
53       if (what == ly_symbol2scm ("solo1"))
54         text = get_property ("soloText");
55       else if (what == ly_symbol2scm ("solo2"))
56         text = get_property ("soloIIText");
57       else if (what == ly_symbol2scm ("unisono"))
58         text = get_property ("aDueText");
59
60       if (Text_interface::markup_p (text))
61         {
62           text_ = make_item ("CombineTextScript", event_->self_scm ());
63           text_->set_property ("text", text);
64         }
65     }
66 }
67
68 void
69 Part_combine_engraver::acknowledge_grob (Grob_info i)
70 {
71   if (text_)
72     {
73       if (Note_head::has_interface (i.grob_))
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       if (Stem::has_interface (i.grob_))
82         {
83           Side_position_interface::add_support (text_, i.grob_);
84         }
85     }
86 }
87
88 void
89 Part_combine_engraver::stop_translation_timestep ()
90 {
91   text_ = 0;
92   event_ = 0;
93 }
94
95 ADD_TRANSLATOR (Part_combine_engraver,
96                 /* descr */ "Part combine engraver for orchestral scores:               "
97                 "Print markings a2, Solo, Solo II, and unisono ",
98                 /* creats*/ "CombineTextScript",
99                 /* accepts */ "part-combine-event",
100                 /* acks  */ "multi-measure-rest-interface "
101                 "slur-interface stem-interface note-head-interface",
102                 /* reads */ "printPartCombineTexts",
103                 /* write */ "");