]> git.donarmstrong.com Git - lilypond.git/commitdiff
Issue 3641: Keep only one Axis_group_engraver active
authorDavid Kastrup <dak@gnu.org>
Thu, 31 Oct 2013 22:34:12 +0000 (23:34 +0100)
committerDavid Kastrup <dak@gnu.org>
Sat, 2 Nov 2013 13:41:12 +0000 (14:41 +0100)
The internal context property axisEngraver is used for tracking the
currently active Axis_group_engraver.  This supercedes the solution
attempted in issue 2990.

lily/axis-group-engraver.cc
lily/vertical-align-engraver.cc
scm/define-context-properties.scm

index c5dbb94e63eb1d912fe4b09c0b6d8977ee631dd0..295ba8b403284ec2d270dfc0435f27c0b855b01d 100644 (file)
 class Axis_group_engraver : public Engraver
 {
 protected:
+  bool active_;
   Spanner *staffline_;
   SCM interesting_;
   vector<Grob *> 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 "
                );
index 97f14fdce03b0e6f88aecac0be7ccc4491e0938f..65cf6e7f772d7af5086ccbe6bfab11a94664a1d7 100644 (file)
@@ -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 ();
index a0d3b98f7e82f1b070c92de64c36e3cfce1f036c..20d77ea72f5d100dbc5705f64b27a5023e74e057 100644 (file)
@@ -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.")