From: Joe Neeman Date: Mon, 24 Sep 2007 21:32:43 +0000 (+1000) Subject: Fix 464. X-Git-Tag: release/2.11.34-1~8 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=b51d7ad0977e9f43915fff9e2313a150c8a44c77;p=lilypond.git Fix 464. Center a multimeasure rest between BreakAlignments, not according to the extent of the columns. --- diff --git a/input/regression/multi-measure-rest-center2.ly b/input/regression/multi-measure-rest-center2.ly new file mode 100644 index 0000000000..71fb64b696 --- /dev/null +++ b/input/regression/multi-measure-rest-center2.ly @@ -0,0 +1,13 @@ +\version "2.11.32" + +\header +{ + texidoc = "The existence of a text mark does not affect the placement of a multimeasure rest." +} + +\paper{ ragged-right=##t } + +\relative g' { + \mark \markup{ "foo foo foo foo foo foo"} + R1 | g4 g g g | +} diff --git a/lily/include/multi-measure-rest.hh b/lily/include/multi-measure-rest.hh index 554a328b6e..966741aaef 100644 --- a/lily/include/multi-measure-rest.hh +++ b/lily/include/multi-measure-rest.hh @@ -28,6 +28,7 @@ public: static Stencil big_rest (Grob *, Real); static Stencil symbol_stencil (Grob *, Real); static Stencil church_rest (Grob *, Font_metric *, int, Real); + static Interval bar_width (Spanner *me); }; #endif /* MULTI_MEASURE_REST_HH */ diff --git a/lily/include/paper-column.hh b/lily/include/paper-column.hh index 9109e4e697..350ed4e635 100644 --- a/lily/include/paper-column.hh +++ b/lily/include/paper-column.hh @@ -49,6 +49,7 @@ public: static bool is_used (Grob *); static bool is_breakable (Grob *); static Real minimum_distance (Grob *l, Grob *r); + static Interval break_align_width (Grob *me); }; #endif // PAPER_COLUMN_HH diff --git a/lily/multi-measure-rest.cc b/lily/multi-measure-rest.cc index 279f2d011f..8afc641439 100644 --- a/lily/multi-measure-rest.cc +++ b/lily/multi-measure-rest.cc @@ -16,11 +16,30 @@ #include "misc.hh" #include "spanner.hh" #include "staff-symbol-referencer.hh" +#include "system.hh" #include "text-interface.hh" #include "percent-repeat-item.hh" #include "lookup.hh" #include "separation-item.hh" +Interval +Multi_measure_rest::bar_width (Spanner *me) +{ + Interval iv; + Direction d = LEFT; + do + { + Item *col = me->get_bound (d)->get_column (); + + Interval coldim = Paper_column::break_align_width (col); + + iv[d] = coldim[-d]; + } + while ((flip (&d)) != LEFT); + + return iv; +} + MAKE_SCHEME_CALLBACK (Multi_measure_rest, percent, 1); SCM Multi_measure_rest::percent (SCM smob) @@ -34,17 +53,7 @@ Multi_measure_rest::percent (SCM smob) Grob *common_x = sp->get_bound (LEFT)->common_refpoint (sp->get_bound (RIGHT), X_AXIS); - Interval sp_iv; - Direction d = LEFT; - do - { - Item *col = sp->get_bound (d)->get_column (); - - Interval coldim = robust_relative_extent (col, common_x, X_AXIS); - - sp_iv[d] = coldim[-d]; - } - while ((flip (&d)) != LEFT); + Interval sp_iv = bar_width (sp); Real x_off = 0.0; Real rx = sp->get_bound (LEFT)->relative_coordinate (common_x, X_AXIS); @@ -71,20 +80,7 @@ Multi_measure_rest::print (SCM smob) Grob *me = unsmob_grob (smob); Spanner *sp = dynamic_cast (me); - Interval sp_iv; - Direction d = LEFT; - - Grob *common = sp->get_bound (LEFT)->common_refpoint (sp->get_bound (RIGHT), X_AXIS); - do - { - Item *b = sp->get_bound (d); - - Interval coldim = b->extent (common, X_AXIS); - - sp_iv[d] = coldim.is_empty () ? b->relative_coordinate (common, X_AXIS) : coldim[-d]; - } - while ((flip (&d)) != LEFT); - + Interval sp_iv = bar_width (sp); Real space = sp_iv.length (); Real rx = sp->get_bound (LEFT)->relative_coordinate (0, X_AXIS); diff --git a/lily/paper-column.cc b/lily/paper-column.cc index 53dfd4a906..0cd8eda9d9 100644 --- a/lily/paper-column.cc +++ b/lily/paper-column.cc @@ -8,6 +8,7 @@ #include "paper-column.hh" +#include "break-align-interface.hh" #include "moment.hh" #include "paper-score.hh" #include "warn.hh" @@ -157,6 +158,23 @@ Paper_column::minimum_distance (Grob *left, Grob *right) return max (0.0, skys[LEFT].distance (skys[RIGHT])); } +Interval +Paper_column::break_align_width (Grob *me) +{ + if (is_musical (me)) + { + me->programming_error ("tried to get break-align-width of a non-musical column"); + return Interval (0, 0); + } + + Grob *align = Pointer_group_interface::find_grob (me, ly_symbol2scm ("elements"), + Break_alignment_interface::has_interface); + if (!align) + return Interval (0, 0); + + return align->extent (me->get_parent (X_AXIS), X_AXIS); +} + /* Print a vertical line and the rank number, to aid debugging. */