]> git.donarmstrong.com Git - lilypond.git/blob - lily/grid-line-span-engraver.cc
Issue 4550 (1/2) Avoid "using namespace std;" in included files
[lilypond.git] / lily / grid-line-span-engraver.cc
1 /*
2   This file is part of LilyPond, the GNU music typesetter.
3
4   Copyright (C) 2005--2015 Han-Wen Nienhuys <hanwen@xs4all.nl>
5
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.
10
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.
15
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/>.
18 */
19
20 #include "engraver.hh"
21 #include "item.hh"
22 #include "grid-line-interface.hh"
23
24 #include "translator.icc"
25
26 using std::vector;
27
28 class Grid_line_span_engraver : public Engraver
29 {
30   Item *spanline_;
31   vector<Item *> lines_;
32
33 public:
34   TRANSLATOR_DECLARATIONS (Grid_line_span_engraver);
35 protected:
36   DECLARE_ACKNOWLEDGER (grid_point);
37   void stop_translation_timestep ();
38 };
39
40 Grid_line_span_engraver::Grid_line_span_engraver ()
41 {
42   spanline_ = 0;
43 }
44
45 void
46 Grid_line_span_engraver::acknowledge_grid_point (Grob_info i)
47 {
48   int depth = i.origin_contexts (this).size ();
49   if (depth)
50     {
51       Item *it = dynamic_cast<Item *> (i.grob ());
52       lines_.push_back (it);
53
54       if (lines_.size () >= 2 && !spanline_)
55         {
56           spanline_ = make_item ("GridLine", SCM_EOL);
57           spanline_->set_parent (lines_[0], X_AXIS);
58         }
59     }
60 }
61
62 void
63 Grid_line_span_engraver::stop_translation_timestep ()
64 {
65   if (spanline_)
66     {
67       for (vsize i = 0; i < lines_.size (); i++)
68         Grid_line_interface::add_grid_point (spanline_, lines_[i]);
69
70       spanline_ = 0;
71     }
72   lines_.resize (0);
73 }
74
75 ADD_ACKNOWLEDGER (Grid_line_span_engraver, grid_point);
76 ADD_TRANSLATOR (Grid_line_span_engraver,
77                 /* doc */
78                 "This engraver makes cross-staff lines: It catches all normal"
79                 " lines and draws a single span line across them.",
80
81                 /* create */
82                 "GridLine ",
83
84                 /* read */
85                 "",
86
87                 /* write */
88                 ""
89                );