]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/hara-kiri-vertical-group-spanner.cc
release: 1.3.61
[lilypond.git] / lily / hara-kiri-vertical-group-spanner.cc
index 9ea5c23de1d5366634f0af97581f3e69396b59bf..21746accfd4374d45c95b67baa2e345744f82821 100644 (file)
@@ -4,58 +4,75 @@
 
   source file of the GNU LilyPond music typesetter
 
-  (c)  1998,1999 Jan Nieuwenhuizen <janneke@gnu.org>
+  (c)  1998--2000 Jan Nieuwenhuizen <janneke@gnu.org>
   Han-Wen Nienhuys <hanwen@cs.uu.nl>
 */
 
+#include "axis-group-interface.hh"
 #include "hara-kiri-vertical-group-spanner.hh"
 #include "debug.hh"
 #include "item.hh"
 
-Hara_kiri_group_spanner::Hara_kiri_group_spanner()
+/*
+ */
+Hara_kiri_group_spanner::Hara_kiri_group_spanner(SCM s)
+  : Spanner (s)
 {
-  set_axes(Y_AXIS,Y_AXIS);
+  set_elt_pointer ("items-worth-living", SCM_EOL);
 }
 
 void 
 Hara_kiri_group_spanner::add_interesting_item (Item* n)
 {
   add_dependency (n);
-  interesting_items_.push (n);
+  Pointer_group_interface (this, "items-worth-living").add_element (n);
+
 }
 
 void 
-Hara_kiri_group_spanner::do_post_processing ()
+Hara_kiri_group_spanner::after_line_breaking ()
 {
-  if (!interesting_items_.empty ())
+  SCM worth = get_elt_pointer ("items-worth-living");
+  /*
+    worth == self_scm  is a stupid way to signal that we're done.
+   */
+  if (gh_pair_p (worth))
     return;
 
-  Link_array<Score_element> childs = get_children ();
+  Link_array<Score_element> childs = Axis_group_interface (this).get_children ();
   for (int i = 0; i < childs.size (); i++)
     {
       Score_element* s = childs[i];
 
       if ( line_l () != s->line_l ())
        programming_error ("Killing other children too");
-      s->set_elt_property ("transparent", SCM_BOOL_T);
-      s->set_empty (true, X_AXIS, Y_AXIS);
-
+      s->suicide ();
     }
-  set_empty (true);
-}
 
-void
-Hara_kiri_group_spanner::do_substitute_element_pointer (Score_element*o, Score_element*n)
-{
-  Axis_group_spanner::do_substitute_element_pointer (o,n);
-  if (Item *it = dynamic_cast<Item *> (o))
-    interesting_items_.substitute (it, dynamic_cast<Item *> (n));
+  /*
+    very appropriate name here :-)
+   */
+  suicide ();
 }
 
 
-void
-Hara_kiri_group_spanner::do_print () const
+
+/*
+  We can't rely on offsets and dimensions of elements in a hara-kiri
+  group. Use a callback to make sure that hara-kiri has been done
+  before asking for offsets.  */
+Real
+Hara_kiri_group_spanner::force_hara_kiri_callback (Score_element const  *elt, Axis a)
 {
-  Axis_group_spanner::do_print ();
-}
+  while (elt && !dynamic_cast<Hara_kiri_group_spanner const*> (elt))
+    elt = elt->parent_l(a);
+
+  if (elt)
+    {
+      Hara_kiri_group_spanner const  * seppuku = dynamic_cast<Hara_kiri_group_spanner const*> (elt);
 
+      ((Hara_kiri_group_spanner*)seppuku)->after_line_breaking ();
+    }
+
+  return 0.0;
+}