X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fpaper-column.cc;h=bcb480451507ccbbde9553d113e90bd1bb772df2;hb=97a0169312a260933246ab224e4f8b0969871dd5;hp=d907acdf24f914e9b435aca0c92b44a46c149d96;hpb=fe4893be240c78a35deff5e86af3d7d1200a478b;p=lilypond.git diff --git a/lily/paper-column.cc b/lily/paper-column.cc index d907acdf24..bcb4804515 100644 --- a/lily/paper-column.cc +++ b/lily/paper-column.cc @@ -203,13 +203,14 @@ Paper_column::break_align_width (Grob *me, SCM align_syms) (me, ly_symbol2scm ("elements"), (scm_is_eq (align_sym, ly_symbol2scm ("staff-bar")) ? Bar_line::non_empty_barline - : Break_alignment_interface::has_interface)); + : has_interface)); else { extract_grob_set (me, "elements", elts); for (vsize i = 0; i < elts.size (); i++) { - if (elts[i]->get_property ("break-align-symbol") == align_sym + if (scm_is_eq (align_sym, elts[i]->get_property ("break-align-symbol")) + // TODO SCM: there must be a simpler way to put this. && !elts[i]->extent (elts[i], X_AXIS).is_empty ()) { align = elts[i]; @@ -225,6 +226,22 @@ Paper_column::break_align_width (Grob *me, SCM align_syms) return align->extent (p, X_AXIS); } +LY_DEFINE (ly_paper_column__break_align_width, "ly:paper-column::break-align-width", + 2, 0, 0, (SCM col, SCM align_syms), + "Determine the extent along the X-axis of a grob used for" + " break-alignment organized by column @var{col}. The grob is" + " specified by @var{align-syms}, which contains either a" + " single @code{break-align-symbol} or a list of such" + " symbols.") +{ + LY_ASSERT_SMOB (Grob, col, 1); + SCM_ASSERT_TYPE (scm_is_symbol (align_syms) || ly_is_list (align_syms), + align_syms, SCM_ARG2, __FUNCTION__, "symbol or list"); + + Interval ext = Paper_column::break_align_width (unsmob (col), align_syms); + return ly_interval2scm (ext); +} + /* Loop through elements of a PaperColumn, find all grobs implementing specified interface and return their combined extent. @@ -390,6 +407,11 @@ Paper_column::print (SCM p) return t.smobbed_copy (); } +static bool grob_is_live (const Grob *g) +{ + return g && g->is_live (); +} + /* This is all too hairy. We use bounded-by-me to make sure that some columns are kept "alive". Unfortunately, when spanners are suicided, @@ -404,21 +426,8 @@ Paper_column::before_line_breaking (SCM grob) { Grob *me = unsmob (grob); - SCM bbm = me->get_object ("bounded-by-me"); - Grob_array *ga = unsmob (bbm); - if (!ga) - return SCM_UNSPECIFIED; - - vector &array (ga->array_reference ()); - - for (vsize i = array.size (); i--;) - { - Grob *g = array[i]; - - if (!g || !g->is_live ()) - /* UGH . potentially quadratic. */ - array.erase (array.begin () + i); - } + if (Grob_array *ga = unsmob (me->get_object ("bounded-by-me"))) + ga->filter (grob_is_live); return SCM_UNSPECIFIED; } @@ -440,7 +449,7 @@ Paper_column::is_extraneous_column_from_ligature (Grob *me) bool has_notehead = false; for (vsize i = 0; i < elts.size (); i++) { - if (Rhythmic_head::has_interface (elts[i])) + if (has_interface (elts[i])) { has_notehead = true; if (dynamic_cast (elts[i])->get_column () == me)