]> git.donarmstrong.com Git - lilypond.git/blob - lily/part-combine-engraver.cc
2003 -> 2004
[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 "item.hh"
14 #include "text-item.hh"
15 #include "note-head.hh"
16 #include "stem.hh"
17 #include "side-position-interface.hh"
18 #include "multi-measure-rest.hh"
19
20 class Part_combine_engraver : public Engraver
21 {
22   TRANSLATOR_DECLARATIONS(Part_combine_engraver);
23
24 protected:
25   virtual void acknowledge_grob (Grob_info);
26   virtual void process_music ();
27   virtual 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 ("soloADue")))
52     {
53       SCM what = event_->get_mus_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_item::markup_p (text))
63         {
64           text_ =  make_item ("CombineTextScript");
65           text_->set_grob_property ("text", text);
66           announce_grob (text_, event_->self_scm ());
67         }
68     }
69 }
70
71 void
72 Part_combine_engraver::acknowledge_grob (Grob_info i)
73 {
74   if (text_)
75     {
76       if (Note_head::has_interface (i.grob_))
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       if (Stem::has_interface (i.grob_))
85         {
86           Side_position_interface::add_support (text_, i.grob_);
87         }
88     }
89 }
90
91 void 
92 Part_combine_engraver::stop_translation_timestep ()
93 {
94   if (text_)
95     {
96       typeset_grob (text_);
97       text_ = 0;
98     }
99   event_ = 0;
100 }
101
102 ENTER_DESCRIPTION(Part_combine_engraver,
103 /* descr */       "Part combine engraver for orchestral scores:         "
104                   "Print markings a2, Solo, Solo II, and unisono ",
105 /* creats*/       "CombineTextScript",
106 /* accepts */     "part-combine-event",
107 /* acks  */       "multi-measure-rest-interface "
108 "slur-interface stem-interface note-head-interface"
109 ,/* reads */       "soloADue",
110 /* write */       "");