Fixes Issue 1504, allowing feather beam line breaking.
[lilypond/patrick.git] / lily / grid-line-span-engraver.cc
blobad80c9ea7ee51134e3f54c72a559b212caec4dc3
1 /*
2 This file is part of LilyPond, the GNU music typesetter.
4 Copyright (C) 2005--2011 Han-Wen Nienhuys <hanwen@xs4all.nl>
6 LilyPond is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
11 LilyPond is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with LilyPond. If not, see <http://www.gnu.org/licenses/>.
20 #include "engraver.hh"
21 #include "item.hh"
22 #include "grid-line-interface.hh"
24 class Grid_line_span_engraver : public Engraver
26 Item *spanline_;
27 vector<Item*> lines_;
29 public:
30 TRANSLATOR_DECLARATIONS (Grid_line_span_engraver);
31 protected:
32 DECLARE_ACKNOWLEDGER (grid_point);
33 void stop_translation_timestep ();
36 Grid_line_span_engraver::Grid_line_span_engraver ()
38 spanline_ = 0;
41 void
42 Grid_line_span_engraver::acknowledge_grid_point (Grob_info i)
44 int depth = i.origin_contexts (this).size ();
45 if (depth)
47 Item *it = dynamic_cast<Item *> (i.grob ());
48 lines_.push_back (it);
50 if (lines_.size () >= 2 && !spanline_)
52 spanline_ = make_item ("GridLine", SCM_EOL);
53 spanline_->set_parent (lines_[0], X_AXIS);
58 void
59 Grid_line_span_engraver::stop_translation_timestep ()
61 if (spanline_)
63 for (vsize i = 0; i < lines_.size (); i++)
64 Grid_line_interface::add_grid_point (spanline_, lines_[i]);
66 spanline_ = 0;
68 lines_.resize (0);
71 #include "translator.icc"
72 ADD_ACKNOWLEDGER (Grid_line_span_engraver, grid_point);
73 ADD_TRANSLATOR (Grid_line_span_engraver,
74 /* doc */
75 "This engraver makes cross-staff lines: It catches all normal"
76 " lines and draws a single span line across them.",
78 /* create */
79 "GridLine ",
81 /* read */
82 "",
84 /* write */