From: David Kastrup Date: Thu, 31 Oct 2013 22:34:12 +0000 (+0100) Subject: Issue 3641: Keep only one Axis_group_engraver active X-Git-Tag: release/2.17.95-1~4^2~8 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=23cb0d1943f6e6ad95b47619ceb295b53dad735f;p=lilypond.git Issue 3641: Keep only one Axis_group_engraver active The internal context property axisEngraver is used for tracking the currently active Axis_group_engraver. This supercedes the solution attempted in issue 2990. --- diff --git a/lily/axis-group-engraver.cc b/lily/axis-group-engraver.cc index c5dbb94e63..295ba8b403 100644 --- a/lily/axis-group-engraver.cc +++ b/lily/axis-group-engraver.cc @@ -36,10 +36,12 @@ class Axis_group_engraver : public Engraver { protected: + bool active_; Spanner *staffline_; SCM interesting_; vector elts_; void process_music (); + virtual void initialize (); virtual void finalize (); DECLARE_ACKNOWLEDGER (grob); void process_acknowledged (); @@ -57,6 +59,15 @@ Axis_group_engraver::Axis_group_engraver () { staffline_ = 0; interesting_ = SCM_EOL; + active_ = false; +} + +void +Axis_group_engraver::initialize () +{ + active_ = !to_boolean (get_property ("hasAxisGroup")); + if (active_) + context ()->set_property ("hasAxisGroup", SCM_BOOL_T); } void @@ -75,7 +86,7 @@ Axis_group_engraver::must_be_last () const void Axis_group_engraver::process_music () { - if (!staffline_) + if (!staffline_ && active_) { staffline_ = get_spanner (); Grob *it = unsmob_grob (get_property ("currentCommandColumn")); @@ -105,7 +116,8 @@ Axis_group_engraver::finalize () void Axis_group_engraver::acknowledge_grob (Grob_info i) { - elts_.push_back (i.grob ()); + if (staffline_) + elts_.push_back (i.grob ()); if (staffline_ && to_boolean(staffline_->get_property("remove-empty"))) { @@ -165,8 +177,9 @@ ADD_TRANSLATOR (Axis_group_engraver, /* read */ "currentCommandColumn " - "keepAliveInterfaces ", - + "keepAliveInterfaces " + "hasAxisGroup ", + /* write */ - "" + "hasAxisGroup " ); diff --git a/lily/vertical-align-engraver.cc b/lily/vertical-align-engraver.cc index 97f14fdce0..65cf6e7f77 100644 --- a/lily/vertical-align-engraver.cc +++ b/lily/vertical-align-engraver.cc @@ -22,6 +22,7 @@ #include "align-interface.hh" #include "axis-group-interface.hh" #include "engraver.hh" +#include "international.hh" #include "spanner.hh" #include "pointer-group-interface.hh" #include "grob-array.hh" @@ -58,7 +59,8 @@ ADD_TRANSLATOR (Vertical_align_engraver, /* read */ "alignAboveContext " - "alignBelowContext ", + "alignBelowContext " + "hasAxisGroup ", /* write */ "" @@ -86,8 +88,15 @@ Vertical_align_engraver::initialize () void Vertical_align_engraver::process_music () { - if (!valign_) + if (!valign_ && !scm_is_null (id_to_group_hashtab_)) { + if (to_boolean (get_property ("hasAxisGroup"))) + { + warning (_ ("Ignoring Vertical_align_engraver in VerticalAxisGroup")); + id_to_group_hashtab_ = SCM_EOL; + return; + } + top_level_ = to_boolean (get_property ("topLevelAlignment")); valign_ = make_spanner (top_level_ ? "VerticalAlignment" : "StaffGrouper", SCM_EOL); @@ -120,6 +129,9 @@ Vertical_align_engraver::qualifies (Grob_info i) const void Vertical_align_engraver::acknowledge_axis_group (Grob_info i) { + if (scm_is_null (id_to_group_hashtab_)) + return; + if (top_level_ && qualifies (i)) { string id = i.context ()->id_string (); diff --git a/scm/define-context-properties.scm b/scm/define-context-properties.scm index a0d3b98f7e..20d77ea72f 100644 --- a/scm/define-context-properties.scm +++ b/scm/define-context-properties.scm @@ -690,6 +690,9 @@ proceeding to next time step. This is an internal variable.") (graceSettings ,list? "Overrides for grace notes. This property should be manipulated through the @code{add-grace-property} function.") + + (hasAxisGroup ,boolean? "True if the current context is contained +in an axis group.") (hasStaffSpacing ,boolean? "True if the current @code{CommandColumn} contains items that will affect spacing.")