X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fnote-spacing-engraver.cc;h=7a7ca7275fc832a0ee978e30400eb0a4ba754d48;hb=47db9a3883d726ca53e2133a3b2298f78dd6a32e;hp=3131f17777abea5867aaf294cfe56671c57a79c6;hpb=cdd820b9ea739e97c662f530808b6c807d4de13d;p=lilypond.git diff --git a/lily/note-spacing-engraver.cc b/lily/note-spacing-engraver.cc index 3131f17777..7a7ca7275f 100644 --- a/lily/note-spacing-engraver.cc +++ b/lily/note-spacing-engraver.cc @@ -1,10 +1,20 @@ -/* - note-spacing-engraver.cc -- implement Note_spacing_engraver - - source file of the GNU LilyPond music typesetter - - (c) 2006--2007 Han-Wen Nienhuys - +/* + This file is part of LilyPond, the GNU music typesetter. + + Copyright (C) 2006--2015 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" @@ -20,9 +30,10 @@ class Note_spacing_engraver : public Engraver { - typedef map Last_spacing_map; + typedef map Last_spacing_map; Last_spacing_map last_spacings_; - + Grob *last_spacing_; + Grob *spacing_; void add_spacing_item (Grob *); @@ -47,6 +58,7 @@ Note_spacing_engraver::derived_mark () const Note_spacing_engraver::Note_spacing_engraver () { spacing_ = 0; + last_spacing_ = 0; } void @@ -56,22 +68,20 @@ Note_spacing_engraver::add_spacing_item (Grob *g) { spacing_ = make_item ("NoteSpacing", g->self_scm ()); } - + if (spacing_) { Pointer_group_interface::add_grob (spacing_, - ly_symbol2scm ("left-items"), - g); - - Grob *last_spacing = last_spacings_[context ()->get_parent_context ()]; - if (last_spacing) - Pointer_group_interface::add_grob (last_spacing, - ly_symbol2scm ("right-items"), - g); + ly_symbol2scm ("left-items"), + g); + + if (last_spacing_) + Pointer_group_interface::add_grob (last_spacing_, + ly_symbol2scm ("right-items"), + g); } } - void Note_spacing_engraver::acknowledge_note_column (Grob_info gi) { @@ -91,13 +101,13 @@ Note_spacing_engraver::finalize () Grob *last_spacing = last_spacings_[parent]; if (last_spacing - && !unsmob_grob_array (last_spacing->get_object ("right-items"))) + && !Grob_array::is_smob (last_spacing->get_object ("right-items"))) { - Grob *col = unsmob_grob (get_property ("currentCommandColumn")); - + Grob *col = Grob::unsmob (get_property ("currentCommandColumn")); + Pointer_group_interface::add_grob (last_spacing, - ly_symbol2scm ("right-items"), - col); + ly_symbol2scm ("right-items"), + col); } } @@ -110,15 +120,16 @@ Note_spacing_engraver::stop_translation_timestep () if (last_spacing && to_boolean (get_property ("hasStaffSpacing"))) { - Grob *col = unsmob_grob (get_property ("currentCommandColumn")); + Grob *col = Grob::unsmob (get_property ("currentCommandColumn")); Pointer_group_interface::add_grob (last_spacing, - ly_symbol2scm ("right-items"), - col); + ly_symbol2scm ("right-items"), + col); } - + if (spacing_) { last_spacings_[parent] = spacing_; + last_spacing_ = spacing_; spacing_ = 0; } @@ -128,7 +139,16 @@ ADD_ACKNOWLEDGER (Note_spacing_engraver, note_column); ADD_ACKNOWLEDGER (Note_spacing_engraver, rhythmic_grob); ADD_TRANSLATOR (Note_spacing_engraver, - /* doc */ "Generates NoteSpacing, an object linking horizontal lines for use in spacing.", - /* create */ "NoteSpacing", - /* read */ "", - /* write */ ""); + /* doc */ + "Generate @code{NoteSpacing}, an object linking horizontal" + " lines for use in spacing.", + + /* create */ + "NoteSpacing ", + + /* read */ + "", + + /* write */ + "" + );