]> git.donarmstrong.com Git - lilypond.git/blob - lily/part-combine-engraver.cc
Merge branch 'lilypond/translation' of ssh://git.sv.gnu.org/srv/git/lilypond
[lilypond.git] / lily / part-combine-engraver.cc
1 /*
2   This file is part of LilyPond, the GNU music typesetter.
3
4   Copyright (C) 2000--2010 Jan Nieuwenhuizen <janneke@gnu.org>
5
6   Han-Wen Nienhuys <hanwen@xs4all.nl>
7
8   LilyPond is free software: you can redistribute it and/or modify
9   it under the terms of the GNU General Public License as published by
10   the Free Software Foundation, either version 3 of the License, or
11   (at your option) any later version.
12
13   LilyPond is distributed in the hope that it will be useful,
14   but WITHOUT ANY WARRANTY; without even the implied warranty of
15   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16   GNU General Public License for more details.
17
18   You should have received a copy of the GNU General Public License
19   along with LilyPond.  If not, see <http://www.gnu.org/licenses/>.
20 */
21
22 #include "engraver.hh"
23 #include "multi-measure-rest.hh"
24 #include "note-head.hh"
25 #include "side-position-interface.hh"
26 #include "stem.hh"
27 #include "stream-event.hh"
28 #include "text-interface.hh"
29 #include "item.hh"
30
31 #include "translator.icc"
32
33 class Part_combine_engraver : public Engraver
34 {
35   TRANSLATOR_DECLARATIONS (Part_combine_engraver);
36
37 protected:
38   DECLARE_ACKNOWLEDGER (note_head);
39   DECLARE_ACKNOWLEDGER (stem);
40
41   DECLARE_TRANSLATOR_LISTENER (part_combine);
42   void process_music ();
43   void stop_translation_timestep ();
44 private:
45   Item *text_;
46   Stream_event *event_;
47 };
48
49 IMPLEMENT_TRANSLATOR_LISTENER (Part_combine_engraver, part_combine);
50 void
51 Part_combine_engraver::listen_part_combine (Stream_event *ev)
52 {
53   ASSIGN_EVENT_ONCE (event_, ev);
54 }
55
56 Part_combine_engraver::Part_combine_engraver ()
57 {
58   text_ = 0;
59   event_ = 0;
60 }
61
62 void
63 Part_combine_engraver::process_music ()
64 {
65   if (event_
66       && to_boolean (get_property ("printPartCombineTexts")))
67     {
68       SCM what = event_->get_property ("class");
69       SCM text = SCM_EOL;
70       if (what == ly_symbol2scm ("solo-one-event"))
71         text = get_property ("soloText");
72       else if (what == ly_symbol2scm ("solo-two-event"))
73         text = get_property ("soloIIText");
74       else if (what == ly_symbol2scm ("unisono-event"))
75         text = get_property ("aDueText");
76
77       if (Text_interface::is_markup (text))
78         {
79           text_ = make_item ("CombineTextScript", event_->self_scm ());
80           text_->set_property ("text", text);
81         }
82     }
83 }
84
85 void
86 Part_combine_engraver::acknowledge_note_head (Grob_info i)
87 {
88   if (text_)
89     {
90       Grob *t = text_;
91       Side_position_interface::add_support (t, i.grob ());
92       if (Side_position_interface::get_axis (t) == X_AXIS
93           && !t->get_parent (Y_AXIS))
94         t->set_parent (i.grob (), Y_AXIS);
95     }
96 }
97
98 void
99 Part_combine_engraver::acknowledge_stem (Grob_info i)
100 {
101   if (text_)
102     Side_position_interface::add_support (text_, i.grob ());
103 }
104
105 void
106 Part_combine_engraver::stop_translation_timestep ()
107 {
108   text_ = 0;
109   event_ = 0;
110 }
111
112 ADD_ACKNOWLEDGER (Part_combine_engraver, note_head);
113 ADD_ACKNOWLEDGER (Part_combine_engraver, stem);
114 ADD_TRANSLATOR (Part_combine_engraver,
115                 /* doc */
116                 "Part combine engraver for orchestral scores: Print markings"
117                 " @q{a2}, @q{Solo}, @q{Solo II}, and @q{unisono}.",
118
119                 /* create */
120                 "CombineTextScript ",
121
122                 /* read */
123                 "printPartCombineTexts "
124                 "soloText "
125                 "soloIIText "
126                 "aDueText ",
127
128                 /* write */
129                 ""
130                 );