CVSROOT:        /cvsroot/lilypond
Module name:    lilypond
Branch:         lilypond_2_6
Changes by:     Han-Wen Nienhuys <[EMAIL PROTECTED]>    05/10/11 09:15:02

Modified files:
        .              : ChangeLog 
        lily           : hara-kiri-group-spanner.cc 

Log message:
        (consider_suicide): backport:
        only consider break_index for broken spanner.

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/lilypond/lilypond/ChangeLog.diff?only_with_tag=lilypond_2_6&tr1=1.3836.2.39&tr2=1.3836.2.40&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/lilypond/lilypond/lily/hara-kiri-group-spanner.cc.diff?only_with_tag=lilypond_2_6&tr1=1.35&tr2=1.35.2.1&r1=text&r2=text

Patches:
Index: lilypond/ChangeLog
diff -u lilypond/ChangeLog:1.3836.2.39 lilypond/ChangeLog:1.3836.2.40
--- lilypond/ChangeLog:1.3836.2.39      Sun Oct  9 23:03:06 2005
+++ lilypond/ChangeLog  Tue Oct 11 09:15:01 2005
@@ -1,3 +1,8 @@
+2005-10-11  Han-Wen Nienhuys  <[EMAIL PROTECTED]>
+
+       * lily/hara-kiri-group-spanner.cc (consider_suicide): backport:
+       only consider break_index for broken spanner.  
+
 2005-10-10  Han-Wen Nienhuys  <[EMAIL PROTECTED]>
 
        * stepmake/stepmake/python-module-rules.make
Index: lilypond/lily/hara-kiri-group-spanner.cc
diff -u /dev/null lilypond/lily/hara-kiri-group-spanner.cc:1.35.2.1
--- /dev/null   Tue Oct 11 09:15:03 2005
+++ lilypond/lily/hara-kiri-group-spanner.cc    Tue Oct 11 09:15:02 2005
@@ -0,0 +1,102 @@
+/*
+  hara-kiri-vertical-group-spanner.cc -- implement Hara_kiri_group_spanner
+
+  source file of the GNU LilyPond music typesetter
+
+  (c) 1998--2005 Jan Nieuwenhuizen <[EMAIL PROTECTED]>
+  Han-Wen Nienhuys <[EMAIL PROTECTED]>
+*/
+
+#include "hara-kiri-group-spanner.hh"
+
+#include "axis-group-interface.hh"
+#include "spanner.hh"
+#include "warn.hh"
+#include "item.hh"
+#include "paper-column.hh"
+
+MAKE_SCHEME_CALLBACK (Hara_kiri_group_spanner, y_extent, 2);
+SCM
+Hara_kiri_group_spanner::y_extent (SCM element_smob, SCM scm_axis)
+{
+  Grob *me = unsmob_grob (element_smob);
+  (void) scm_axis;
+
+  assert (scm_to_int (scm_axis) == Y_AXIS);
+  consider_suicide (me);
+  return Axis_group_interface::group_extent_callback (me->self_scm (), 
scm_axis);
+}
+
+void
+Hara_kiri_group_spanner::consider_suicide (Grob *me)
+{
+  Spanner *sp = dynamic_cast<Spanner *> (me);
+  SCM worth = me->get_property ("items-worth-living");
+  if (scm_is_pair (worth))
+    return;
+
+
+  bool remove_first = to_boolean (me->get_property ("remove-first"));
+  if (!remove_first
+       && ((sp->original_ && broken_spanner_index (sp) == 0)
+          || Paper_column::get_rank (sp->get_bound (LEFT)->get_column ())
+          == 0)) 
+    return;
+
+  Link_array<Grob> childs = Axis_group_interface::get_children (me);
+  for (int i = 0; i < childs.size (); i++)
+    childs[i]->suicide ();
+
+  /*
+    very appropriate name here :-)
+  */
+  me->suicide ();
+}
+
+/*
+  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.  */
+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)
+{
+  Grob *me = unsmob_grob (element_smob);
+  (void) axis;
+  
+  assert (scm_to_int (axis) == Y_AXIS);
+  consider_suicide (me);
+  return scm_make_real (0.0);
+}
+
+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)
+{
+  Grob *daughter = unsmob_grob (element_smob);
+  Axis a = (Axis) scm_to_int (axis);
+  assert (a == Y_AXIS);
+  force_hara_kiri_callback (daughter->get_parent (a)->self_scm (), axis);
+  return scm_make_real (0.0);
+}
+
+void
+Hara_kiri_group_spanner::add_element (Grob *me, Grob *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::add_interesting_item (Grob *me, Grob *n)
+{
+  me->add_dependency (n);
+  Pointer_group_interface::add_grob (me, ly_symbol2scm ("items-worth-living"), 
n);
+}
+
+ADD_INTERFACE (Hara_kiri_group_spanner, "hara-kiri-group-interface",
+              "A group spanner that  keeps track of interesting items.  If it "
+              "doesn't contain any after linebreaking, then it "
+              "will remove itself and all its children.",
+              "items-worth-living remove-first");
+


_______________________________________________
Lilypond-cvs mailing list
Lilypond-cvs@gnu.org
http://lists.gnu.org/mailman/listinfo/lilypond-cvs

Reply via email to