X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fhara-kiri-group-spanner.cc;h=f477cd22e4cad5be5db83b3c701f99125d874410;hb=34881554afeaf03a55a3a983caf9cfeaaf3ea060;hp=50dd0dbc2ea296d0cd6ab88f8c9c3488e810f8d5;hpb=38d60c0c4e8c29beccd4acfd07aadf1cdea74097;p=lilypond.git diff --git a/lily/hara-kiri-group-spanner.cc b/lily/hara-kiri-group-spanner.cc index 50dd0dbc2e..f477cd22e4 100644 --- a/lily/hara-kiri-group-spanner.cc +++ b/lily/hara-kiri-group-spanner.cc @@ -3,14 +3,14 @@ source file of the GNU LilyPond music typesetter - (c) 1998--2001 Jan Nieuwenhuizen + (c) 1998--2004 Jan Nieuwenhuizen Han-Wen Nienhuys */ #include "axis-group-interface.hh" #include "spanner.hh" #include "hara-kiri-group-spanner.hh" -#include "debug.hh" +#include "warn.hh" #include "item.hh" @@ -19,7 +19,7 @@ SCM Hara_kiri_group_spanner::y_extent (SCM element_smob, SCM scm_axis) { Grob *me = unsmob_grob (element_smob); - Axis a = (Axis) gh_scm2int (scm_axis); + Axis a = (Axis) scm_to_int (scm_axis); assert (a == Y_AXIS); consider_suicide (me); @@ -30,10 +30,17 @@ Hara_kiri_group_spanner::y_extent (SCM element_smob, SCM scm_axis) void Hara_kiri_group_spanner::consider_suicide (Grob*me) { - SCM worth = me->get_grob_property ("items-worth-living"); - if (gh_pair_p (worth)) + Spanner*sp = dynamic_cast (me); + SCM worth = me->get_property ("items-worth-living"); + if (scm_is_pair (worth)) return ; + if (!to_boolean (me->get_property ("remove-first")) + && broken_spanner_index (sp) == 0) + { + return ; + } + Link_array childs = Axis_group_interface::get_children (me); for (int i = 0; i < childs.size (); i++) childs[i]->suicide (); @@ -56,10 +63,10 @@ SCM Hara_kiri_group_spanner::force_hara_kiri_callback (SCM element_smob, SCM axis) { Grob *me = unsmob_grob (element_smob); - Axis a = (Axis) gh_scm2int (axis); + Axis a = (Axis) scm_to_int (axis); assert (a == Y_AXIS); consider_suicide (me); - return gh_double2scm (0.0); + return scm_make_real (0.0); } @@ -68,10 +75,10 @@ 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) gh_scm2int (axis); + Axis a = (Axis) scm_to_int (axis); assert (a == Y_AXIS); force_hara_kiri_callback (daughter->get_parent (a)->self_scm (), axis); - return gh_double2scm (0.0); + return scm_make_real (0.0); } void @@ -82,18 +89,8 @@ Hara_kiri_group_spanner::add_element (Grob * me, Grob *e) } -void -Hara_kiri_group_spanner::set_interface (Grob*me) -{ - me->set_interface (ly_symbol2scm ("hara-kiri-group-interface")); -} -bool -Hara_kiri_group_spanner::has_interface (Grob*me) -{ - return me->has_interface (ly_symbol2scm ("hara-kiri-group-interface")); -} void Hara_kiri_group_spanner::add_interesting_item (Grob* me,Grob* n) @@ -101,3 +98,12 @@ 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"); +