X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fhara-kiri-group-spanner.cc;h=cb5aacecc551faf1055579bc47f5d5b50d146684;hb=706b1bf8f6eed212eb1314641148ecea950623e8;hp=395bcdb553931e0db85b9b0ca7266318e5d09b0a;hpb=bc95f4434f760d41191341ab4508b2064eb19025;p=lilypond.git diff --git a/lily/hara-kiri-group-spanner.cc b/lily/hara-kiri-group-spanner.cc index 395bcdb553..cb5aacecc5 100644 --- a/lily/hara-kiri-group-spanner.cc +++ b/lily/hara-kiri-group-spanner.cc @@ -1,7 +1,7 @@ /* This file is part of LilyPond, the GNU music typesetter. - Copyright (C) 1998--2010 Jan Nieuwenhuizen + Copyright (C) 1998--2012 Jan Nieuwenhuizen Han-Wen Nienhuys LilyPond is free software: you can redistribute it and/or modify @@ -70,12 +70,26 @@ bool find_in_range (SCM vector, int low, int hi, int min, int max) if (val >= min && val <= max) return true; else if (val < min) - return find_in_range (vector, mid+1, hi, min, max); + return find_in_range (vector, mid + 1, hi, min, max); return find_in_range (vector, low, mid, min, max); } bool Hara_kiri_group_spanner::request_suicide (Grob *me, int start, int end) +{ + if (!request_suicide_alone (me, start, end)) + return false; + + extract_grob_set (me, "keep-alive-with", friends); + for (vsize i = 0; i < friends.size (); ++i) + if (friends[i]->is_live () && !request_suicide_alone (friends[i], start, end)) + return false; + + return true; +} + +bool +Hara_kiri_group_spanner::request_suicide_alone (Grob *me, int start, int end) { if (!to_boolean (me->get_property ("remove-empty"))) return false; @@ -89,7 +103,7 @@ Hara_kiri_group_spanner::request_suicide (Grob *me, int start, int end) { int len = scm_c_vector_length (important); if (find_in_range (important, 0, len, start, end)) - return false; + return false; } else /* build the important-columns-cache */ { @@ -97,17 +111,17 @@ Hara_kiri_group_spanner::request_suicide (Grob *me, int start, int end) vector ranks; for (vsize i = 0; i < worth.size (); i++) - { - Interval_t iv = worth[i]->spanned_rank_interval (); - for (int j = iv[LEFT]; j <= iv[RIGHT]; j++) - ranks.push_back (j); - } + { + Interval_t iv = worth[i]->spanned_rank_interval (); + for (int j = iv[LEFT]; j <= iv[RIGHT]; j++) + ranks.push_back (j); + } vector_sort (ranks, less ()); uniq (ranks); SCM scm_vec = scm_c_make_vector (ranks.size (), SCM_EOL); for (vsize i = 0; i < ranks.size (); i++) - scm_vector_set_x (scm_vec, scm_from_int (i), scm_from_int (ranks[i])); + scm_vector_set_x (scm_vec, scm_from_int (i), scm_from_int (ranks[i])); me->set_property ("important-column-ranks", scm_vec); return request_suicide (me, start, end); @@ -119,13 +133,13 @@ Hara_kiri_group_spanner::request_suicide (Grob *me, int start, int end) void Hara_kiri_group_spanner::consider_suicide (Grob *me) { - Spanner *sp = dynamic_cast (me); + Spanner *sp = dynamic_cast (me); int left = sp->get_bound (LEFT)->get_column ()->get_rank (); int right = sp->get_bound (RIGHT)->get_column ()->get_rank (); if (!request_suicide (me, left, right)) return; - vector childs; + vector childs; Axis_group_interface::get_children (me, &childs); for (vsize i = 0; i < childs.size (); i++) childs[i]->suicide (); @@ -165,15 +179,15 @@ Hara_kiri_group_spanner::add_interesting_item (Grob *me, Grob *n) } ADD_INTERFACE (Hara_kiri_group_spanner, - "A group spanner that keeps track of interesting items. If it" - " doesn't contain any after line breaking, it removes itself" - " and all its children.", - - /* properties */ - "items-worth-living " - "important-column-ranks " - "remove-empty " - "remove-first " - ); - + "A group spanner that keeps track of interesting items. If it" + " doesn't contain any after line breaking, it removes itself" + " and all its children.", + + /* properties */ + "items-worth-living " + "important-column-ranks " + "keep-alive-with " + "remove-empty " + "remove-first " + );