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