X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fbreak-align-engraver.cc;h=73f7db34ae973b2d7a7c8fd487be638715a40a34;hb=e3a15ec3c1951dd16f6ee71fbd79870d9e2fb3a0;hp=b3e74500d0c5ae102d14457ff3259c6a5335841c;hpb=a93cdac09beaeb940a1776a5177fb823d1fa8337;p=lilypond.git diff --git a/lily/break-align-engraver.cc b/lily/break-align-engraver.cc index b3e74500d0..73f7db34ae 100644 --- a/lily/break-align-engraver.cc +++ b/lily/break-align-engraver.cc @@ -1,9 +1,20 @@ /* - break-align-engraver.cc -- implement Break_align_engraver + This file is part of LilyPond, the GNU music typesetter. - source file of the GNU LilyPond music typesetter + Copyright (C) 1999--2011 Han-Wen Nienhuys - (c) 1999--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" #include "protected-scm.hh" @@ -23,12 +34,14 @@ class Break_align_engraver : public Engraver Item *left_edge_; void add_to_group (SCM, Item *); + void create_alignment (Grob_info); protected: void stop_translation_timestep (); virtual void derived_mark () const; public: TRANSLATOR_DECLARATIONS (Break_align_engraver); DECLARE_ACKNOWLEDGER (break_aligned); + DECLARE_ACKNOWLEDGER (break_alignable); }; void @@ -53,6 +66,18 @@ Break_align_engraver::derived_mark () const scm_gc_mark (column_alist_); } +void +Break_align_engraver::acknowledge_break_alignable (Grob_info inf) +{ + if (!align_) + create_alignment (inf); + + Grob *g = inf.grob (); + + if (!g->get_parent (X_AXIS)) + g->set_parent (align_, X_AXIS); +} + void Break_align_engraver::acknowledge_break_aligned (Grob_info inf) { @@ -72,26 +97,30 @@ Break_align_engraver::acknowledge_break_aligned (Grob_info inf) return; if (!align_) - { - align_ = make_item ("BreakAlignment", SCM_EOL); + create_alignment (inf); - Context *origin = inf.origin_contexts (this)[0]; + add_to_group (align_name, item); + } +} - Translator_group *tg = origin->implementation (); - Engraver *random_source = dynamic_cast (unsmob_translator (scm_car (tg->get_simple_trans_list ()))); - if (!random_source) - random_source = this; +void +Break_align_engraver::create_alignment (Grob_info inf) +{ + align_ = make_item ("BreakAlignment", SCM_EOL); - /* - Make left edge appear to come from same context as clef/bar-line etc. - */ - left_edge_ = random_source->make_item ("LeftEdge", SCM_EOL); - add_to_group (left_edge_->get_property ("break-align-symbol"), - left_edge_); - } + Context *origin = inf.origin_contexts (this)[0]; - add_to_group (align_name, item); - } + Translator_group *tg = origin->implementation (); + Engraver *random_source = dynamic_cast (unsmob_translator (scm_car (tg->get_simple_trans_list ()))); + if (!random_source) + random_source = this; + + /* + Make left edge appear to come from same context as clef/bar-line etc. + */ + left_edge_ = random_source->make_item ("LeftEdge", SCM_EOL); + add_to_group (left_edge_->get_property ("break-align-symbol"), + left_edge_); } void @@ -118,13 +147,24 @@ Break_align_engraver::add_to_group (SCM align_name, Item *item) } Axis_group_interface::add_element (group, item); } + ADD_ACKNOWLEDGER (Break_align_engraver, break_aligned); +ADD_ACKNOWLEDGER (Break_align_engraver, break_alignable); ADD_TRANSLATOR (Break_align_engraver, - "Align grobs with corresponding @code{break-align-symbols} into " - "groups, and order the groups according to @code{breakAlignOrder}. " - "The left edge of the alignment gets a separate group, with a symbol @code{left-edge}. ", - /* create */ "BreakAlignment " + /* doc */ + "Align grobs with corresponding @code{break-align-symbols}" + " into groups, and order the groups according to" + " @code{breakAlignOrder}. The left edge of the alignment gets" + " a separate group, with a symbol @code{left-edge}.", + + /* create */ + "BreakAlignment " "BreakAlignGroup " "LeftEdge ", - /* read */ "", - /* write */ ""); + + /* read */ + "", + + /* write */ + "" + );