X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fgrid-line-span-engraver.cc;h=d5f0335a480f7cff62b0a2d9a6e3e3bb90d66331;hb=97a0169312a260933246ab224e4f8b0969871dd5;hp=5ad0bed8a0b2b8acba8aeddb13fb8dcc8925984e;hpb=02c656d3b0cb895cc81b428d699d960746800e45;p=lilypond.git diff --git a/lily/grid-line-span-engraver.cc b/lily/grid-line-span-engraver.cc index 5ad0bed8a0..d5f0335a48 100644 --- a/lily/grid-line-span-engraver.cc +++ b/lily/grid-line-span-engraver.cc @@ -1,47 +1,60 @@ /* - grid-line-span-engraver.cc -- implement Grid_line_span_engraver + This file is part of LilyPond, the GNU music typesetter. - source file of the GNU LilyPond music typesetter + Copyright (C) 2005--2015 Han-Wen Nienhuys - (c) 2005 Han-Wen Nienhuys + LilyPond is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + LilyPond is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with LilyPond. If not, see . */ #include "engraver.hh" #include "item.hh" #include "grid-line-interface.hh" +#include "translator.icc" + class Grid_line_span_engraver : public Engraver { Item *spanline_; - Link_array lines_; + vector lines_; public: TRANSLATOR_DECLARATIONS (Grid_line_span_engraver); protected: - virtual void acknowledge_grob (Grob_info); - virtual void stop_translation_timestep (); + void acknowledge_grid_point (Grob_info); + void stop_translation_timestep (); }; -Grid_line_span_engraver::Grid_line_span_engraver () +Grid_line_span_engraver::Grid_line_span_engraver (Context *c) + : Engraver (c) { spanline_ = 0; } void -Grid_line_span_engraver::acknowledge_grob (Grob_info i) +Grid_line_span_engraver::acknowledge_grid_point (Grob_info i) { int depth = i.origin_contexts (this).size (); - if (depth && i.grob ()->internal_has_interface (ly_symbol2scm ("grid-point-interface"))) + if (depth) { Item *it = dynamic_cast (i.grob ()); - lines_.push (it); + lines_.push_back (it); if (lines_.size () >= 2 && !spanline_) - { - spanline_ = make_item ("GridLine", SCM_EOL); - spanline_->set_parent (lines_[0], X_AXIS); - } + { + spanline_ = make_item ("GridLine", SCM_EOL); + spanline_->set_parent (lines_[0], X_AXIS); + } } } @@ -50,19 +63,31 @@ Grid_line_span_engraver::stop_translation_timestep () { if (spanline_) { - for (int i = 0; i < lines_.size (); i++) - Grid_line_interface::add_grid_point (spanline_, lines_[i]); + for (vsize i = 0; i < lines_.size (); i++) + Grid_line_interface::add_grid_point (spanline_, lines_[i]); spanline_ = 0; } - lines_.set_size (0); + lines_.resize (0); +} + +void +Grid_line_span_engraver::boot () +{ + ADD_ACKNOWLEDGER (Grid_line_span_engraver, grid_point); } ADD_TRANSLATOR (Grid_line_span_engraver, - /* descr */ "This engraver makes cross-staff linelines: It catches all normal " - "line lines, and draws a single span-line across them.", - /* creats*/ "GridLine", - /* accepts */ "", - /* acks */ "grid-point-interface", - /* reads */ "", - /* write */ ""); + /* doc */ + "This engraver makes cross-staff lines: It catches all normal" + " lines and draws a single span line across them.", + + /* create */ + "GridLine ", + + /* read */ + "", + + /* write */ + "" + );