X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fseparating-line-group-engraver.cc;h=234008d9830bcac736edd19ad69459a3a7931b67;hb=b5de1ca579bc679f69b5df30803fda31a74075d5;hp=954c5834d4ed22413a17205ac8653807777abacb;hpb=2eb63c6977706ba261e4ee0674c734a34b3ee904;p=lilypond.git diff --git a/lily/separating-line-group-engraver.cc b/lily/separating-line-group-engraver.cc index 954c5834d4..234008d983 100644 --- a/lily/separating-line-group-engraver.cc +++ b/lily/separating-line-group-engraver.cc @@ -1,9 +1,20 @@ /* - separating-line-group-engraver.cc -- implement Separating_line_group_engraver + This file is part of LilyPond, the GNU music typesetter. - source file of the GNU LilyPond music typesetter + Copyright (C) 1998--2015 Han-Wen Nienhuys - (c) 1998--2007 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" @@ -24,7 +35,7 @@ struct Spacings { Item *staff_spacing_; - vector note_spacings_; + vector note_spacings_; Spacings () { @@ -48,17 +59,18 @@ protected: Spacings current_spacings_; Spacings last_spacings_; - DECLARE_ACKNOWLEDGER (item); - DECLARE_ACKNOWLEDGER (break_aligned); + void acknowledge_item (Grob_info); + void acknowledge_break_aligned (Grob_info); void stop_translation_timestep (); void start_translation_timestep (); - vector break_aligned_; + vector break_aligned_; public: TRANSLATOR_DECLARATIONS (Separating_line_group_engraver); }; -Separating_line_group_engraver::Separating_line_group_engraver () +Separating_line_group_engraver::Separating_line_group_engraver (Context *c) + : Engraver (c) { } @@ -67,7 +79,7 @@ Separating_line_group_engraver::acknowledge_item (Grob_info i) { Item *it = i.item (); - if (Note_spacing::has_interface (it)) + if (has_interface (it)) { current_spacings_.note_spacings_.push_back (it); return; @@ -77,30 +89,30 @@ Separating_line_group_engraver::acknowledge_item (Grob_info i) && !current_spacings_.staff_spacing_ && to_boolean (get_property ("createSpacing"))) { - Grob *col = unsmob_grob (get_property ("currentCommandColumn")); + Grob *col = unsmob (get_property ("currentCommandColumn")); current_spacings_.staff_spacing_ = make_item ("StaffSpacing", SCM_EOL); context ()->set_property ("hasStaffSpacing", SCM_BOOL_T); Pointer_group_interface::add_grob (current_spacings_.staff_spacing_, - ly_symbol2scm ("left-items"), - col); - + ly_symbol2scm ("left-items"), + col); + if (!last_spacings_.note_spacings_.size () - && last_spacings_.staff_spacing_) - { - SCM ri = last_spacings_.staff_spacing_->get_object ("right-items"); - Grob_array *ga = unsmob_grob_array (ri); - if (!ga) - { - SCM ga_scm = Grob_array::make_array (); - last_spacings_.staff_spacing_->set_object ("right-items", ga_scm); - ga = unsmob_grob_array (ga_scm); - } - - ga->clear (); - ga->add (col); - } + && last_spacings_.staff_spacing_) + { + SCM ri = last_spacings_.staff_spacing_->get_object ("right-items"); + Grob_array *ga = unsmob (ri); + if (!ga) + { + SCM ga_scm = Grob_array::make_array (); + last_spacings_.staff_spacing_->set_object ("right-items", ga_scm); + ga = unsmob (ga_scm); + } + + ga->clear (); + ga->add (col); + } } } @@ -124,37 +136,42 @@ Separating_line_group_engraver::stop_translation_timestep () SCM smob = break_aligned_[i]->self_scm (); if (Item *sp = current_spacings_.staff_spacing_) - Pointer_group_interface::add_grob (sp, ly_symbol2scm ("left-break-aligned"), smob); + Pointer_group_interface::add_grob (sp, ly_symbol2scm ("left-break-aligned"), smob); for (vsize j = 0; j < last_spacings_.note_spacings_.size (); j++) - Pointer_group_interface::add_grob (last_spacings_.note_spacings_[j], - ly_symbol2scm ("right-break-aligned"), smob); + Pointer_group_interface::add_grob (last_spacings_.note_spacings_[j], + ly_symbol2scm ("right-break-aligned"), smob); } if (!current_spacings_.is_empty ()) last_spacings_ = current_spacings_; if (Item *sp = current_spacings_.staff_spacing_) - if (Grob *col = unsmob_grob (get_property ("currentMusicalColumn"))) + if (Grob *col = unsmob (get_property ("currentMusicalColumn"))) Pointer_group_interface::add_grob (sp, ly_symbol2scm ("right-items"), col); current_spacings_.clear (); break_aligned_.clear (); } -ADD_ACKNOWLEDGER (Separating_line_group_engraver, item); -ADD_ACKNOWLEDGER (Separating_line_group_engraver, break_aligned); + +void +Separating_line_group_engraver::boot () +{ + ADD_ACKNOWLEDGER (Separating_line_group_engraver, item); + ADD_ACKNOWLEDGER (Separating_line_group_engraver, break_aligned); +} ADD_TRANSLATOR (Separating_line_group_engraver, - /* doc */ - "Generate objects for computing spacing parameters.", + /* doc */ + "Generate objects for computing spacing parameters.", - /* create */ - "StaffSpacing ", + /* create */ + "StaffSpacing ", - /* read */ - "createSpacing ", + /* read */ + "createSpacing ", - /* write */ - "hasStaffSpacing " - ); + /* write */ + "hasStaffSpacing " + );