]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/hara-kiri-group-spanner.cc
patch::: 1.3.95.tca2
[lilypond.git] / lily / hara-kiri-group-spanner.cc
index 0094a018ed9083f2c223d96921d04ccd03bb39c4..66bd0389ad0fcf0d9f7fe342c88713566b301d43 100644 (file)
@@ -8,52 +8,41 @@
 */
 
 #include "axis-group-interface.hh"
+#include "spanner.hh"
 #include "hara-kiri-group-spanner.hh"
 #include "debug.hh"
 #include "item.hh"
 
-/*
- */
-Hara_kiri_group_spanner::Hara_kiri_group_spanner(SCM s)
-  : Spanner (s)
-{
-  set_elt_pointer ("items-worth-living", SCM_EOL);
-}
 
-void 
-Hara_kiri_group_spanner::add_interesting_item (Item* n)
+MAKE_SCHEME_CALLBACK(Hara_kiri_group_spanner,y_extent,2);
+SCM
+Hara_kiri_group_spanner::y_extent (SCM element_smob, SCM scm_axis)
 {
-  add_dependency (n);
-  Pointer_group_interface (this, "items-worth-living").add_element (n);
+  Score_element *me = unsmob_element (element_smob);
+  Axis a = (Axis) gh_scm2int (scm_axis);
 
+  assert (a == Y_AXIS);
+  consider_suicide (me);
+  return  Axis_group_interface::group_extent_callback (me->self_scm (), scm_axis);
 }
 
-GLUE_SCORE_ELEMENT(Hara_kiri_group_spanner,after_line_breaking);
-SCM 
-Hara_kiri_group_spanner::member_after_line_breaking ()
+
+void
+Hara_kiri_group_spanner::consider_suicide(Score_element*me)
 {
-  SCM worth = get_elt_pointer ("items-worth-living");
-  /*
-    worth == self_scm  is a stupid way to signal that we're done.
-   */
+  SCM worth = me->get_elt_property ("items-worth-living");
   if (gh_pair_p (worth))
-    return SCM_UNDEFINED;
+    return ;
 
-  Link_array<Score_element> childs = Axis_group_interface (this).get_children ();
+  Link_array<Score_element> childs = Axis_group_interface::get_children (me);
   for (int i = 0; i < childs.size (); i++)
-    {
-      Score_element* s = childs[i];
+    childs[i]->suicide ();
 
-      if ( line_l () != s->line_l ())
-       programming_error ("Killing other children too");
-      s->suicide ();
-    }
 
   /*
     very appropriate name here :-)
    */
-  suicide ();
-  return SCM_UNDEFINED;
+  me->suicide ();
 }
 
 
@@ -62,19 +51,53 @@ Hara_kiri_group_spanner::member_after_line_breaking ()
   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)
+MAKE_SCHEME_CALLBACK(Hara_kiri_group_spanner,force_hara_kiri_callback,2);
+SCM
+Hara_kiri_group_spanner::force_hara_kiri_callback (SCM element_smob, SCM axis)
 {
-  while (elt && !dynamic_cast<Hara_kiri_group_spanner const*> (elt))
-    elt = elt->parent_l(a);
+  Score_element *me = unsmob_element (element_smob);
+  Axis a = (Axis) gh_scm2int (axis);
+  assert (a == Y_AXIS);
+  consider_suicide (me);
+  return gh_double2scm (0.0);
+}
 
-  if (elt)
-    {
-      Hara_kiri_group_spanner const  * seppuku = dynamic_cast<Hara_kiri_group_spanner const*> (elt);
 
-      ((Hara_kiri_group_spanner*)seppuku)->member_after_line_breaking ();
-    }
-  
+MAKE_SCHEME_CALLBACK(Hara_kiri_group_spanner,force_hara_kiri_in_parent_callback,2);
+SCM
+Hara_kiri_group_spanner::force_hara_kiri_in_parent_callback (SCM element_smob, SCM axis)
+{
+  Score_element *daughter = unsmob_element (element_smob);
+  Axis a = (Axis) gh_scm2int (axis);
+  assert (a == Y_AXIS);
+  force_hara_kiri_callback (daughter->parent_l (a)->self_scm (), axis);
+  return gh_double2scm ( 0.0);
+}
 
-  return 0.0;
+void
+Hara_kiri_group_spanner::add_element (Score_element * me, Score_element *e)
+{
+  //  e->add_offset_callback (force_hara_kiri_in_parent_callback, Y_AXIS);
+  Axis_group_interface::add_element (me, e);
+}
+
+
+void
+Hara_kiri_group_spanner::set_interface (Score_element*me)
+{
+  me->set_interface (ly_symbol2scm ("hara-kiri-group-interface"));
+}
+
+
+bool
+Hara_kiri_group_spanner::has_interface (Score_element*me)
+{
+  return me->has_interface (ly_symbol2scm ("hara-kiri-group-interface"));
+}
+
+void 
+Hara_kiri_group_spanner::add_interesting_item (Score_element* me,Score_element* n)
+{
+  me->add_dependency (n);
+  Pointer_group_interface (me, "items-worth-living").add_element (n);
 }