]> git.donarmstrong.com Git - lilypond.git/blob - lily/part-combine-engraver.cc
Metronome-mark: with multi measure rest: align at bar.
[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 "note-head.hh"
24 #include "side-position-interface.hh"
25 #include "stem.hh"
26 #include "stream-event.hh"
27 #include "text-interface.hh"
28 #include "item.hh"
29
30 #include "translator.icc"
31
32 class Part_combine_engraver : public Engraver
33 {
34   TRANSLATOR_DECLARATIONS (Part_combine_engraver);
35
36 protected:
37   DECLARE_ACKNOWLEDGER (note_head);
38   DECLARE_ACKNOWLEDGER (stem);
39
40   DECLARE_TRANSLATOR_LISTENER (part_combine);
41   void process_music ();
42   void stop_translation_timestep ();
43 private:
44   Item *text_;
45   Stream_event *event_;
46 };
47
48 IMPLEMENT_TRANSLATOR_LISTENER (Part_combine_engraver, part_combine);
49 void
50 Part_combine_engraver::listen_part_combine (Stream_event *ev)
51 {
52   ASSIGN_EVENT_ONCE (event_, ev);
53 }
54
55 Part_combine_engraver::Part_combine_engraver ()
56 {
57   text_ = 0;
58   event_ = 0;
59 }
60
61 void
62 Part_combine_engraver::process_music ()
63 {
64   if (event_
65       && to_boolean (get_property ("printPartCombineTexts")))
66     {
67       SCM what = event_->get_property ("class");
68       SCM text = SCM_EOL;
69       if (what == ly_symbol2scm ("solo-one-event"))
70         text = get_property ("soloText");
71       else if (what == ly_symbol2scm ("solo-two-event"))
72         text = get_property ("soloIIText");
73       else if (what == ly_symbol2scm ("unisono-event"))
74         text = get_property ("aDueText");
75
76       if (Text_interface::is_markup (text))
77         {
78           text_ = make_item ("CombineTextScript", event_->self_scm ());
79           text_->set_property ("text", text);
80         }
81     }
82 }
83
84 void
85 Part_combine_engraver::acknowledge_note_head (Grob_info i)
86 {
87   if (text_)
88     {
89       Grob *t = text_;
90       Side_position_interface::add_support (t, i.grob ());
91       if (Side_position_interface::get_axis (t) == X_AXIS
92           && !t->get_parent (Y_AXIS))
93         t->set_parent (i.grob (), Y_AXIS);
94     }
95 }
96
97 void
98 Part_combine_engraver::acknowledge_stem (Grob_info i)
99 {
100   if (text_)
101     Side_position_interface::add_support (text_, i.grob ());
102 }
103
104 void
105 Part_combine_engraver::stop_translation_timestep ()
106 {
107   text_ = 0;
108   event_ = 0;
109 }
110
111 ADD_ACKNOWLEDGER (Part_combine_engraver, note_head);
112 ADD_ACKNOWLEDGER (Part_combine_engraver, stem);
113 ADD_TRANSLATOR (Part_combine_engraver,
114                 /* doc */
115                 "Part combine engraver for orchestral scores: Print markings"
116                 " @q{a2}, @q{Solo}, @q{Solo II}, and @q{unisono}.",
117
118                 /* create */
119                 "CombineTextScript ",
120
121                 /* read */
122                 "printPartCombineTexts "
123                 "soloText "
124                 "soloIIText "
125                 "aDueText ",
126
127                 /* write */
128                 ""
129                 );