]> git.donarmstrong.com Git - lilypond.git/blob - lily/span-brace-engraver.cc
Revert "Fixes figuredBassCenterContinuations."
[lilypond.git] / lily / span-brace-engraver.cc
1 /*
2   This file is part of LilyPond, the GNU music typesetter.
3
4   Copyright (C) 2011 Bertrand Bordage
5                      Mike Solomon
6
7   LilyPond is free software: you can redistribute it and/or modify
8   it under the terms of the GNU General Public License as published by
9   the Free Software Foundation, either version 3 of the License, or
10   (at your option) any later version.
11
12   LilyPond is distributed in the hope that it will be useful,
13   but WITHOUT ANY WARRANTY; without even the implied warranty of
14   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15   GNU General Public License for more details.
16
17   You should have received a copy of the GNU General Public License
18   along with LilyPond.  If not, see <http://www.gnu.org/licenses/>.
19 */
20
21 #include "engraver.hh"
22 #include "arpeggio.hh"
23 #include "pointer-group-interface.hh"
24 #include "side-position-interface.hh"
25 #include "staff-symbol-referencer.hh"
26 #include "item.hh"
27
28 /**
29    Make braces that span multiple staves.  Catch braces, and span a
30    Span_brace over them if we find more than two braces.
31 */
32 class Span_brace_engraver : public Engraver
33 {
34 public:
35   TRANSLATOR_DECLARATIONS (Span_brace_engraver);
36   DECLARE_ACKNOWLEDGER (brace);
37
38 protected:
39   void process_acknowledged ();
40   void stop_translation_timestep ();
41
42 private:
43   Item *span_brace_;
44   vector<Grob*> braces_;
45 };
46
47 Span_brace_engraver::Span_brace_engraver ()
48 {
49   span_brace_ = 0;
50 }
51
52 void
53 Span_brace_engraver::acknowledge_brace (Grob_info info)
54 {
55   if (info.origin_contexts (this).size ()) // huh? what's this test for?
56     braces_.push_back (info.grob ());
57 }
58
59 void
60 Span_brace_engraver::process_acknowledged ()
61 {
62   /*
63     connectBraces is slightly brusque; we should really read a grob
64     property of the caught non-span braces. That way, we can have
65
66     both non-connected and connected braces in one pianostaff.
67
68   */
69   if (!span_brace_ && braces_.size () > 1
70       && to_boolean (get_property ("connectBraces")))
71     {
72       span_brace_ = make_item ("Brace", SCM_EOL);
73       span_brace_->set_property ("cross-staff", SCM_BOOL_T);
74     }
75 }
76
77 void
78 Span_brace_engraver::stop_translation_timestep ()
79 {
80   if (span_brace_)
81     {
82       /*
83         we do this very late, to make sure we also catch `extra'
84         side-pos support like accidentals.
85       */
86       for (vsize j = 0; j < braces_.size (); j++)
87         {
88           extract_grob_set (braces_[j], "stems", stems);
89           for (vsize i = 0; i < stems.size (); i++)
90             Pointer_group_interface::add_grob (span_brace_, ly_symbol2scm ("stems"),
91                                                stems[i]);
92
93           extract_grob_set (braces_[j], "side-support-elements", sses);
94           for (vsize i = 0; i < sses.size (); i++)
95             Pointer_group_interface::add_grob (span_brace_, ly_symbol2scm ("side-support-elements"),
96                                                sses[i]);
97
98           /*
99             we can't kill the children, since we don't want to the
100             previous note to bump into the span brace; so we make
101             it transparent.  */
102           braces_[j]->set_property ("transparent", SCM_BOOL_T);
103         }
104
105
106       span_brace_->set_parent (braces_[0]->get_parent (Y_AXIS), Y_AXIS);
107       span_brace_ = 0;
108     }
109   braces_.clear ();
110 }
111
112 #include "translator.icc"
113
114 ADD_ACKNOWLEDGER (Span_brace_engraver, brace);
115 ADD_TRANSLATOR (Span_brace_engraver,
116                 /* doc */
117                 "Make braces that span multiple staves.",
118
119                 /* create */
120                 "Brace ",
121
122                 /* read */
123                 "connectBraces ",
124
125                 /* write */
126                 ""
127                 );