X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fsystem-start-delimiter-engraver.cc;h=a0bc5039254db3688e3e8a07a271752c75bc436a;hb=eaa41b4e4dc1d3b893c5a75711f26db6a7f5fa18;hp=dd2151146d6d7cd724079d0f548126da61036f33;hpb=0c5bcc9f980e3dc40b53543a957bbf353d7c2308;p=lilypond.git diff --git a/lily/system-start-delimiter-engraver.cc b/lily/system-start-delimiter-engraver.cc index dd2151146d..a0bc503925 100644 --- a/lily/system-start-delimiter-engraver.cc +++ b/lily/system-start-delimiter-engraver.cc @@ -1,32 +1,40 @@ /* - System-start-delimiter-engraver.cc -- implement - System_start_delimiter_engraver + This file is part of LilyPond, the GNU music typesetter. - source file of the GNU LilyPond music typesetter + Copyright (C) 2005--2011 Han-Wen Nienhuys - (c) 2005--2006 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 "side-position-interface.hh" -#include "system-start-delimiter.hh" -#include "staff-symbol.hh" -#include "pointer-group-interface.hh" -#include "paper-column.hh" #include "output-def.hh" +#include "paper-column.hh" +#include "pointer-group-interface.hh" +#include "side-position-interface.hh" #include "spanner.hh" +#include "staff-symbol.hh" +#include "system-start-delimiter.hh" struct Bracket_nesting_node { public: - virtual ~Bracket_nesting_node(){} + virtual ~Bracket_nesting_node () {} virtual bool add_staff (Grob *) { return false; } - virtual void add_support (Grob *) { } - virtual void set_bound (Direction, Grob *){} - virtual void set_nesting_support (Grob*) {} - virtual void create_grobs (Engraver*, SCM) {} + virtual void add_support (Grob *) {} + virtual void set_bound (Direction, Grob *) {} + virtual void set_nesting_support (Grob *) {} + virtual void create_grobs (Engraver *, SCM) {} }; struct Bracket_nesting_group : public Bracket_nesting_node @@ -35,12 +43,12 @@ struct Bracket_nesting_group : public Bracket_nesting_node vector children_; SCM symbol_; - void from_list (SCM ); + void from_list (SCM); virtual void add_support (Grob *grob); virtual bool add_staff (Grob *grob); - virtual void set_nesting_support (Grob*); + virtual void set_nesting_support (Grob *); virtual void set_bound (Direction, Grob *grob); - virtual void create_grobs (Engraver*, SCM); + virtual void create_grobs (Engraver *, SCM); ~Bracket_nesting_group (); Bracket_nesting_group (); }; @@ -76,12 +84,11 @@ void Bracket_nesting_group::create_grobs (Engraver *engraver, SCM default_type) { SCM type = scm_is_symbol (symbol_) ? symbol_ : default_type; - delimiter_ = engraver->make_spanner (ly_symbol2string (type).c_str (), SCM_EOL); + delimiter_ = engraver->make_spanner (ly_symbol2string (type).c_str (), + SCM_EOL); for (vsize i = 0 ; i < children_.size (); i++) - { - children_[i]->create_grobs (engraver, default_type); - } + children_[i]->create_grobs (engraver, default_type); } void @@ -89,15 +96,12 @@ Bracket_nesting_group::add_support (Grob *g) { Side_position_interface::add_support (g, delimiter_); for (vsize i = 0 ; i < children_.size (); i++) - { - children_[i]->add_support (g); - } + children_[i]->add_support (g); } Bracket_nesting_group::~Bracket_nesting_group () { - for (vsize i = 0 ; i < children_.size (); i++) - delete children_[i]; + junk_pointers (children_); } void @@ -105,9 +109,7 @@ Bracket_nesting_group::set_bound (Direction d, Grob *g) { delimiter_->set_bound (d, g); for (vsize i = 0 ; i < children_.size (); i++) - { - children_[i]->set_bound (d, g); - } + children_[i]->set_bound (d, g); } void @@ -115,11 +117,9 @@ Bracket_nesting_group::set_nesting_support (Grob *parent) { if (parent) Side_position_interface::add_support (delimiter_, parent); - + for (vsize i = 0 ; i < children_.size (); i++) - { - children_[i]->set_nesting_support (delimiter_); - } + children_[i]->set_nesting_support (delimiter_); } @@ -138,13 +138,10 @@ Bracket_nesting_group::from_list (SCM x) else if (entry == ly_symbol2scm ("SystemStartBrace") || entry == ly_symbol2scm ("SystemStartBracket") || entry == ly_symbol2scm ("SystemStartBar") - || entry == ly_symbol2scm ("SystemStartSquare") - ) + || entry == ly_symbol2scm ("SystemStartSquare")) symbol_ = entry; else - { - children_.push_back (new Bracket_nesting_staff (0)); - } + children_.push_back (new Bracket_nesting_staff (0)); } } @@ -155,11 +152,11 @@ Bracket_nesting_group::add_staff (Grob *grob) { if (children_[i]->add_staff (grob)) { - Pointer_group_interface::add_grob (delimiter_, ly_symbol2scm ("elements"), grob); + Pointer_group_interface::add_grob (delimiter_, + ly_symbol2scm ("elements"), grob); return true; } } - return false; } @@ -175,9 +172,8 @@ public: protected: Bracket_nesting_group *nesting_; - + DECLARE_ACKNOWLEDGER (system_start_delimiter); - DECLARE_ACKNOWLEDGER (system_start_text); DECLARE_ACKNOWLEDGER (staff_symbol); void process_music (); @@ -200,7 +196,8 @@ System_start_delimiter_engraver::process_music () nesting_->from_list (hierarchy); nesting_->create_grobs (this, delimiter_name); - nesting_->set_bound (LEFT, unsmob_grob (get_property ("currentCommandColumn"))); + nesting_->set_bound (LEFT, + unsmob_grob (get_property ("currentCommandColumn"))); } } @@ -212,13 +209,15 @@ System_start_delimiter_engraver::finalize () nesting_->set_bound (RIGHT, unsmob_grob (get_property ("currentCommandColumn"))); nesting_->set_nesting_support (0); + + delete nesting_; } } void System_start_delimiter_engraver::acknowledge_staff_symbol (Grob_info inf) { - Grob *staff = inf.grob(); + Grob *staff = inf.grob (); bool succ = nesting_->add_staff (staff); if (!succ) @@ -228,14 +227,6 @@ System_start_delimiter_engraver::acknowledge_staff_symbol (Grob_info inf) } } - - -void -System_start_delimiter_engraver::acknowledge_system_start_text (Grob_info inf) -{ - nesting_->add_support (inf.grob ()); -} - void System_start_delimiter_engraver::acknowledge_system_start_delimiter (Grob_info inf) { @@ -246,18 +237,25 @@ System_start_delimiter_engraver::acknowledge_system_start_delimiter (Grob_info i ADD_ACKNOWLEDGER (System_start_delimiter_engraver, staff_symbol); ADD_ACKNOWLEDGER (System_start_delimiter_engraver, system_start_delimiter); -ADD_ACKNOWLEDGER (System_start_delimiter_engraver, system_start_text); ADD_TRANSLATOR (System_start_delimiter_engraver, - /* doc */ "Creates a system start delimiter (ie. SystemStart@{Bar, Brace, Bracket@} spanner", - /* create */ "SystemStartSquare " + /* doc */ + "Create a system start delimiter (i.e., a" + " @code{SystemStartBar}, @code{SystemStartBrace}," + " @code{SystemStartBracket} or @code{SystemStartSquare}" + " spanner).", + + /* create */ + "SystemStartSquare " "SystemStartBrace " "SystemStartBracket " - "SystemStartBar", - /* accept */ "", + "SystemStartBar ", + /* read */ "systemStartDelimiter " "systemStartDelimiterHierarchy " - "currentCommandColumn", + "currentCommandColumn ", - /* write */ ""); + /* write */ + "" + );