]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/keep-alive-together-engraver.cc
Issue 5167/6: Changes: show \markup xxx = ... \etc assignments
[lilypond.git] / lily / keep-alive-together-engraver.cc
index c65ff455313f382a74a1f3c28504da924fbdc5f4..6875cd022fa68cf9e57eb4328c6d5af9f81952ed 100644 (file)
@@ -1,7 +1,7 @@
 /*
   This file is part of LilyPond, the GNU music typesetter.
 
-  Copyright (C) 2010--2014 Joe Neeman <joeneeman@gmail.com>
+  Copyright (C) 2010--2015 Joe Neeman <joeneeman@gmail.com>
 
   LilyPond is free software: you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
@@ -22,6 +22,7 @@
 #include "engraver.hh"
 #include "grob.hh"
 #include "grob-array.hh"
+#include "international.hh"
 
 #include "translator.icc"
 
@@ -31,12 +32,13 @@ class Keep_alive_together_engraver: public Engraver
 
 public:
   TRANSLATOR_DECLARATIONS (Keep_alive_together_engraver);
-  DECLARE_ACKNOWLEDGER (hara_kiri_group_spanner);
+  void acknowledge_hara_kiri_group_spanner (Grob_info);
 
   virtual void finalize ();
 };
 
-Keep_alive_together_engraver::Keep_alive_together_engraver ()
+Keep_alive_together_engraver::Keep_alive_together_engraver (Context *c)
+  : Engraver (c)
 {
 }
 
@@ -56,20 +58,52 @@ Keep_alive_together_engraver::finalize ()
         continue;
 
       SCM live_scm = Grob_array::make_array ();
-      Grob_array *live = Grob_array::unsmob (live_scm);
+      Grob_array *live = unsmob<Grob_array> (live_scm);
       SCM dead_scm = Grob_array::make_array ();
-      Grob_array *dead = Grob_array::unsmob (dead_scm);
+      Grob_array *dead = unsmob<Grob_array> (dead_scm);
 
       for (vsize j = 0; j < group_spanners_.size (); ++j)
         {
           if (i == j)
             continue;
+
+          if (scm_is_symbol (this_layer))
+            {
+              if (scm_is_eq (this_layer, ly_symbol2scm ("any")))
+                {
+                  // layer is kept alive by any other layer
+                  live->add (group_spanners_[j]);
+                  continue;
+                }
+              else if (scm_is_eq (this_layer, ly_symbol2scm ("above")))
+                {
+                  // layer is kept alive by the layer preceding it
+                  if (i == j + 1)
+                    live->add (group_spanners_[j]);
+                  continue;
+                }
+              else if (scm_is_eq (this_layer, ly_symbol2scm ("below")))
+                {
+                  // layer is kept alive by the layer following it
+                  if (i == j - 1)
+                    live->add (group_spanners_[j]);
+                  continue;
+                }
+              else
+                {
+                  group_spanners_[i]->warning (_f ("unknown remove-layer value `%s'",
+                                                   ly_symbol2string (this_layer).c_str ()));
+                  continue;
+                }
+            }
+
           SCM that_layer = group_spanners_[j]->get_property ("remove-layer");
+
           if (scm_is_false (that_layer))
             continue;
           if (!scm_is_integer (this_layer))
             {
-              // Unspecified layers are kept alive by anything else
+              // unset layers are kept alive by all but ignored layers
               live->add (group_spanners_[j]);
               continue;
             }
@@ -88,7 +122,12 @@ Keep_alive_together_engraver::finalize ()
     }
 }
 
-ADD_ACKNOWLEDGER (Keep_alive_together_engraver, hara_kiri_group_spanner);
+
+void
+Keep_alive_together_engraver::boot ()
+{
+  ADD_ACKNOWLEDGER (Keep_alive_together_engraver, hara_kiri_group_spanner);
+}
 
 ADD_TRANSLATOR (Keep_alive_together_engraver,
                 /* doc */