* lexer-gcc-3.1.sh: Remove.
[lilypond/patrick.git] / lily / grid-line-span-engraver.cc
blobe4cccb3c80a941cd377f2156d8fb68424e293c42
1 /*
2 grid-line-span-engraver.cc -- implement Grid_line_span_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 2005--2006 Han-Wen Nienhuys <hanwen@xs4all.nl>
7 */
9 #include "engraver.hh"
10 #include "item.hh"
11 #include "grid-line-interface.hh"
13 class Grid_line_span_engraver : public Engraver
15 Item *spanline_;
16 vector<Item*> lines_;
18 public:
19 TRANSLATOR_DECLARATIONS (Grid_line_span_engraver);
20 protected:
21 DECLARE_ACKNOWLEDGER (grid_point);
22 void stop_translation_timestep ();
25 Grid_line_span_engraver::Grid_line_span_engraver ()
27 spanline_ = 0;
30 void
31 Grid_line_span_engraver::acknowledge_grid_point (Grob_info i)
33 int depth = i.origin_contexts (this).size ();
34 if (depth)
36 Item *it = dynamic_cast<Item *> (i.grob ());
37 lines_.push_back (it);
39 if (lines_.size () >= 2 && !spanline_)
41 spanline_ = make_item ("GridLine", SCM_EOL);
42 spanline_->set_parent (lines_[0], X_AXIS);
47 void
48 Grid_line_span_engraver::stop_translation_timestep ()
50 if (spanline_)
52 for (vsize i = 0; i < lines_.size (); i++)
53 Grid_line_interface::add_grid_point (spanline_, lines_[i]);
55 spanline_ = 0;
57 lines_.resize (0);
60 #include "translator.icc"
61 ADD_ACKNOWLEDGER (Grid_line_span_engraver, grid_point);
62 ADD_TRANSLATOR (Grid_line_span_engraver,
63 /* doc */ "This engraver makes cross-staff linelines: It catches all normal "
64 "line lines, and draws a single span-line across them.",
65 /* create */ "GridLine",
66 /* accept */ "",
67 /* read */ "",
68 /* write */ "");