From 190a067275167c6dc9dd0afef683d14d392b7033 Mon Sep 17 00:00:00 2001 From: Neil Puttock Date: Tue, 20 Jul 2010 00:41:29 +0100 Subject: [PATCH] Fix #915. * lily/bar-line.cc: non_empty_barline () moved from lily/note-spacing.cc * lily/multi-measure-rest.cc (bar_width): read 'spacing-pair to determine spacing to left and right columns instead of fixed spacing to BreakAlignment for both directions * lily/note-spacing.cc (get_spacing): non_empty_barline -> Bar_line::non_empty_barline * lily/paper-column.cc (break_align_width): add alignment symbol arg and use it to find correct grob * scm/define-grob-properties.scm (all-user-grob-properties): doc 'spacing-pair * scm/define-grobs.scm (all-grob-descriptions): add 'spacing-pair defaults for MultiMeasureRest and PercentRepeat --- lily/bar-line.cc | 115 ++++++++++++++++----------------- lily/include/bar-line.hh | 9 +-- lily/include/paper-column.hh | 3 +- lily/multi-measure-rest.cc | 36 ++++++----- lily/note-spacing.cc | 97 +++++++++++++-------------- lily/paper-column.cc | 81 ++++++++++++++--------- scm/define-grob-properties.scm | 10 +++ scm/define-grobs.scm | 2 + 8 files changed, 188 insertions(+), 165 deletions(-) diff --git a/lily/bar-line.cc b/lily/bar-line.cc index a7f9024783..34e2e16622 100644 --- a/lily/bar-line.cc +++ b/lily/bar-line.cc @@ -21,11 +21,11 @@ #include "all-font-metrics.hh" #include "font-interface.hh" +#include "line-interface.hh" #include "lookup.hh" #include "output-def.hh" #include "paper-column.hh" #include "staff-symbol-referencer.hh" -#include "line-interface.hh" MAKE_SCHEME_CALLBACK (Bar_line, calc_bar_extent, 1) SCM @@ -40,7 +40,7 @@ Bar_line::calc_bar_extent (SCM smob) return ly_interval2scm (Interval ()); Real h = scm_to_double (size); - return ly_interval2scm (Interval (-h/2, h/2)); + return ly_interval2scm (Interval (-h / 2, h / 2)); } Interval @@ -52,6 +52,12 @@ Bar_line::bar_y_extent (Grob *me, Grob *refpoint) return iv; } +bool +Bar_line::non_empty_barline (Grob *me) +{ + return has_interface (me) && !me->extent (me, X_AXIS).is_empty (); +} + MAKE_SCHEME_CALLBACK (Bar_line, print, 1); SCM Bar_line::print (SCM smob) @@ -121,7 +127,7 @@ Bar_line::compound_barline (Grob *me, string str, Real h, if (str == "") { - Stencil empty = Lookup::blank (Box (Interval (0, 0), Interval (-h / 2, h / 2))); + Stencil empty = Lookup::blank (Box (Interval (0, 0), Interval (-h / 2, h / 2))); empty.translate_axis (center, Y_AXIS); return empty; } @@ -171,7 +177,6 @@ Bar_line::compound_barline (Grob *me, string str, Real h, m.add_at_edge (X_AXIS, LEFT, colon, kern); m.add_at_edge (X_AXIS, RIGHT, thin, kern); m.add_at_edge (X_AXIS, RIGHT, colon, kern); - } else if (str == ":|.:") { @@ -196,8 +201,8 @@ Bar_line::compound_barline (Grob *me, string str, Real h, /* should align to other side? this never appears on the system-start? - m.add_at_edge (X_AXIS, RIGHT, thin, 0); - m.add_at_edge (X_AXIS, RIGHT, thin, thinkern); + m.add_at_edge (X_AXIS, RIGHT, thin, 0); + m.add_at_edge (X_AXIS, RIGHT, thin, thinkern); */ m.add_at_edge (X_AXIS, LEFT, thin, thinkern); m.add_at_edge (X_AXIS, RIGHT, thin, thinkern); @@ -211,42 +216,40 @@ Bar_line::compound_barline (Grob *me, string str, Real h, segno.add_stencil (Font_interface::get_default_font (me)->find_by_name ("scripts.varsegno")); if (str == "S") - { - m.add_stencil (segno); - } + m.add_stencil (segno); else if (str == "S|:" || str == ".S|:") - { - m.add_at_edge (X_AXIS, RIGHT, thick, 0); - m.add_at_edge (X_AXIS, RIGHT, thin, kern); - m.add_at_edge (X_AXIS, RIGHT, colon, kern); - m.add_at_edge (X_AXIS, LEFT, segno, thinkern); - } + { + m.add_at_edge (X_AXIS, RIGHT, thick, 0); + m.add_at_edge (X_AXIS, RIGHT, thin, kern); + m.add_at_edge (X_AXIS, RIGHT, colon, kern); + m.add_at_edge (X_AXIS, LEFT, segno, thinkern); + } else if (str == ":|S" || str == ":|S.") - { - m.add_at_edge (X_AXIS, LEFT, thick, 0); - m.add_at_edge (X_AXIS, LEFT, thin, kern); - m.add_at_edge (X_AXIS, LEFT, colon, kern); - m.add_at_edge (X_AXIS, RIGHT, segno, thinkern); - } + { + m.add_at_edge (X_AXIS, LEFT, thick, 0); + m.add_at_edge (X_AXIS, LEFT, thin, kern); + m.add_at_edge (X_AXIS, LEFT, colon, kern); + m.add_at_edge (X_AXIS, RIGHT, segno, thinkern); + } else if (str == ":|S|:" || str == ":|S.|:") - { - m.add_at_edge (X_AXIS, LEFT, thick, 0); - m.add_at_edge (X_AXIS, LEFT, thin, kern); - m.add_at_edge (X_AXIS, LEFT, colon, kern); - m.add_at_edge (X_AXIS, RIGHT, segno, thinkern); - m.add_at_edge (X_AXIS, RIGHT, thick, thinkern); - m.add_at_edge (X_AXIS, RIGHT, thin, kern); - m.add_at_edge (X_AXIS, RIGHT, colon, kern); - } + { + m.add_at_edge (X_AXIS, LEFT, thick, 0); + m.add_at_edge (X_AXIS, LEFT, thin, kern); + m.add_at_edge (X_AXIS, LEFT, colon, kern); + m.add_at_edge (X_AXIS, RIGHT, segno, thinkern); + m.add_at_edge (X_AXIS, RIGHT, thick, thinkern); + m.add_at_edge (X_AXIS, RIGHT, thin, kern); + m.add_at_edge (X_AXIS, RIGHT, colon, kern); + } else if (str == "|._.|") // :|S|: or :|S.|: without segno and colon - { - // get the width of the segno sign - Real segno_width = segno.extent (X_AXIS).length (); - m.add_at_edge (X_AXIS, LEFT, thick, 0); - m.add_at_edge (X_AXIS, LEFT, thin, kern); - m.add_at_edge (X_AXIS, RIGHT, thick, segno_width + 2 * thinkern); - m.add_at_edge (X_AXIS, RIGHT, thin, kern); - } + { + // get the width of the segno sign + Real segno_width = segno.extent (X_AXIS).length (); + m.add_at_edge (X_AXIS, LEFT, thick, 0); + m.add_at_edge (X_AXIS, LEFT, thin, kern); + m.add_at_edge (X_AXIS, RIGHT, thick, segno_width + 2 * thinkern); + m.add_at_edge (X_AXIS, RIGHT, thin, kern); + } // end varsegno block } else if (str == ":") @@ -263,13 +266,9 @@ Bar_line::compound_barline (Grob *me, string str, Real h, } } else if (str == "dashed") - { - m = dashed_bar_line (me, h, hair); - } + m = dashed_bar_line (me, h, hair); else if (str == "'") - { - m = tick_bar_line (me, h, rounded); - } + m = tick_bar_line (me, h, rounded); m.translate_axis (center, Y_AXIS); return m; @@ -302,10 +301,9 @@ Bar_line::tick_bar_line (Grob *me, Real h, bool rounded) : 0.0; return Lookup::round_filled_box (Box (Interval (0, line_thick), - Interval (h / 2 - th, h / 2 + th)), blot); + Interval (h / 2 - th, h / 2 + th)), blot); } - MAKE_SCHEME_CALLBACK (Bar_line, calc_bar_size, 1); SCM Bar_line::calc_bar_size (SCM smob) @@ -319,7 +317,6 @@ Bar_line::calc_bar_size (SCM smob) return scm_from_int (0); } - Stencil Bar_line::dashed_bar_line (Grob *me, Real h, Real thick) { @@ -329,25 +326,25 @@ Bar_line::dashed_bar_line (Grob *me, Real h, Real thick) this is a tad complex for what we want to achieve, but with a simple line, the round blotting interferes with staff line connections. - */ + */ Real ss = Staff_symbol_referencer::staff_space (me); int count = Staff_symbol_referencer::line_count (me); - Real line_thick = Staff_symbol_referencer::line_thickness (me); + Real line_thick = Staff_symbol_referencer::line_thickness (me); - if (fabs (line_thick + (count -1) * ss - h) < 0.1) // ugh. + if (fabs (line_thick + (count -1) * ss - h) < 0.1) // ugh. { - Real blot = - me->layout ()->get_dimension (ly_symbol2scm ("blot-diameter")); + Real blot + = me->layout ()->get_dimension (ly_symbol2scm ("blot-diameter")); - Real half_space = ss/2; + Real half_space = ss / 2; Stencil bar; - for (int i = (count-1); i >= -(count-1); i -= 2) + for (int i = (count - 1); i >= -(count - 1); i -= 2) { Real top_y = min ((i + dash_size) * half_space, - (count-1) * half_space + line_thick / 2); + (count - 1) * half_space + line_thick / 2); Real bot_y = max ((i - dash_size) * half_space, - -(count-1) * half_space - line_thick/2); + -(count - 1) * half_space - line_thick / 2); bar.add_stencil (Lookup::round_filled_box (Box (Interval (0, thick), Interval (bot_y, top_y)), @@ -360,7 +357,7 @@ Bar_line::dashed_bar_line (Grob *me, Real h, Real thick) /* We have to scale the dashing so it starts and ends with half a dash exactly. - */ + */ int dashes = int (rint (h / ss)); Real total_dash_size = h / dashes; Real factor = (dash_size - thick) / ss; @@ -368,7 +365,7 @@ Bar_line::dashed_bar_line (Grob *me, Real h, Real thick) SCM at = scm_list_n (ly_symbol2scm ("dashed-line"), scm_from_double (thick), scm_from_double (factor * total_dash_size), - scm_from_double ((1-factor) * total_dash_size), + scm_from_double ((1 - factor) * total_dash_size), scm_from_double (0), scm_from_double (h), scm_from_double (factor * total_dash_size * 0.5), @@ -379,7 +376,7 @@ Bar_line::dashed_bar_line (Grob *me, Real h, Real thick) box.add_point (Offset (0, h)); Stencil s (box, at); - s.translate (Offset (thick/2, -h/2)); + s.translate (Offset (thick / 2, -h / 2)); return s; } return Stencil (); diff --git a/lily/include/bar-line.hh b/lily/include/bar-line.hh index a9b3ed90da..aeea3565a0 100644 --- a/lily/include/bar-line.hh +++ b/lily/include/bar-line.hh @@ -17,8 +17,8 @@ along with LilyPond. If not, see . */ -#ifndef BAR_HH -#define BAR_HH +#ifndef BAR_LINE_HH +#define BAR_LINE_HH #include "lily-proto.hh" #include "grob-interface.hh" @@ -33,10 +33,11 @@ public: static Stencil compound_barline (Grob *, string, Real height, bool rounded); static Stencil simple_barline (Grob *, Real wid, Real height, bool rounded); static Interval bar_y_extent (Grob *, Grob *); + static bool non_empty_barline (Grob *me); + DECLARE_SCHEME_CALLBACK (calc_bar_extent, (SCM)); DECLARE_SCHEME_CALLBACK (calc_bar_size, (SCM)); DECLARE_SCHEME_CALLBACK (print, (SCM)); DECLARE_SCHEME_CALLBACK (calc_anchor, (SCM)); }; -#endif // BAR_HH - +#endif // BAR_LINE_HH diff --git a/lily/include/paper-column.hh b/lily/include/paper-column.hh index e58ece9f22..e97533ed1d 100644 --- a/lily/include/paper-column.hh +++ b/lily/include/paper-column.hh @@ -58,8 +58,7 @@ public: static bool is_breakable (Grob *); static bool is_extraneous_column_from_ligature (Grob *); static Real minimum_distance (Grob *l, Grob *r); - static Interval break_align_width (Grob *me); + static Interval break_align_width (Grob *me, SCM align_sym); }; #endif // PAPER_COLUMN_HH - diff --git a/lily/multi-measure-rest.cc b/lily/multi-measure-rest.cc index a36d7c01ed..c1268f8572 100644 --- a/lily/multi-measure-rest.cc +++ b/lily/multi-measure-rest.cc @@ -19,34 +19,38 @@ #include "multi-measure-rest.hh" -#include "warn.hh" +#include "font-interface.hh" +#include "lookup.hh" +#include "misc.hh" #include "output-def.hh" #include "paper-column.hh" // urg -#include "font-interface.hh" +#include "percent-repeat-item.hh" #include "rest.hh" -#include "misc.hh" +#include "separation-item.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" +#include "warn.hh" Interval Multi_measure_rest::bar_width (Spanner *me) { + SCM spacing_pair = me->get_property ("spacing-pair"); Interval iv; Direction d = LEFT; do { Item *col = me->get_bound (d)->get_column (); - - Interval coldim = Paper_column::break_align_width (col); + SCM align_sym + = (scm_is_pair (spacing_pair) + ? index_get_cell (spacing_pair, d) + : ly_symbol2scm ("staff-bar")); + Interval coldim = Paper_column::break_align_width (col, align_sym); iv[d] = coldim[-d]; } - while ((flip (&d)) != LEFT); + while (flip (&d) != LEFT); return iv; } @@ -291,7 +295,7 @@ Multi_measure_rest::calculate_spacing_rods (Grob *me, Real length) if (! (sp->get_bound (LEFT) && sp->get_bound (RIGHT))) { programming_error ("Multi_measure_rest::get_rods (): I am not spanned!"); - return ; + return; } Item *li = sp->get_bound (LEFT)->get_column (); @@ -334,9 +338,9 @@ Multi_measure_rest::set_spacing_rods (SCM smob) Real sym_width = symbol_stencil (me, 0.0).extent (X_AXIS).length (); calculate_spacing_rods (me, sym_width); - return SCM_UNSPECIFIED; + return SCM_UNSPECIFIED; } - + MAKE_SCHEME_CALLBACK (Multi_measure_rest, set_text_rods, 1); SCM Multi_measure_rest::set_text_rods (SCM smob) @@ -357,12 +361,12 @@ ADD_INTERFACE (Multi_measure_rest, "A rest that spans a whole number of measures.", /* properties */ + "bound-padding " "expand-limit " - "measure-count " "hair-thickness " + "measure-count " + "minimum-length " + "spacing-pair " "thick-thickness " "use-breve-rest " - "bound-padding " - "minimum-length " ); - diff --git a/lily/note-spacing.cc b/lily/note-spacing.cc index e12c1cd91e..076d34648d 100644 --- a/lily/note-spacing.cc +++ b/lily/note-spacing.cc @@ -19,26 +19,20 @@ #include "note-spacing.hh" +#include "accidental-placement.hh" #include "bar-line.hh" #include "directional-element-interface.hh" #include "grob-array.hh" -#include "paper-column.hh" #include "moment.hh" #include "note-column.hh" -#include "warn.hh" -#include "stem.hh" +#include "output-def.hh" +#include "paper-column.hh" +#include "pointer-group-interface.hh" #include "separation-item.hh" #include "spacing-interface.hh" #include "staff-spacing.hh" -#include "accidental-placement.hh" -#include "output-def.hh" -#include "pointer-group-interface.hh" - -static bool -non_empty_barline (Grob *me) -{ - return Bar_line::has_interface (me) && !me->extent (me, X_AXIS).is_empty (); -} +#include "stem.hh" +#include "warn.hh" /* TODO: detect hshifts due to collisions, and account for them in @@ -49,29 +43,29 @@ Spring Note_spacing::get_spacing (Grob *me, Item *right_col, Real base_space, Real increment) { - vector note_columns = Spacing_interface::left_note_columns (me); + vector note_columns = Spacing_interface::left_note_columns (me); Real left_head_end = 0; for (vsize i = 0; i < note_columns.size (); i++) { - SCM r = note_columns[i]->get_object ("rest"); - Grob *g = unsmob_grob (r); - Grob *col = note_columns[i]->get_column (); - - if (!g) - g = Note_column::first_head (note_columns[i]); - - /* - Ugh. If Stem is switched off, we don't know what the - first note head will be. - */ - if (g) - { - if (g->common_refpoint (col, X_AXIS) != col) - programming_error ("Note_spacing::get_spacing (): Common refpoint incorrect"); - else - left_head_end = g->extent (col, X_AXIS)[RIGHT]; - } + SCM r = note_columns[i]->get_object ("rest"); + Grob *g = unsmob_grob (r); + Grob *col = note_columns[i]->get_column (); + + if (!g) + g = Note_column::first_head (note_columns[i]); + + /* + Ugh. If Stem is switched off, we don't know what the + first note head will be. + */ + if (g) + { + if (g->common_refpoint (col, X_AXIS) != col) + programming_error ("Note_spacing::get_spacing (): Common refpoint incorrect"); + else + left_head_end = g->extent (col, X_AXIS)[RIGHT]; + } } /* @@ -97,7 +91,7 @@ Note_spacing::get_spacing (Grob *me, Item *right_col, { Grob *bar = Pointer_group_interface::find_grob (right_col, ly_symbol2scm ("elements"), - non_empty_barline); + Bar_line::non_empty_barline); if (bar) { @@ -125,7 +119,7 @@ knee_correction (Grob *note_spacing, Grob *right_stem, Real increment) { Real note_head_width = increment; Grob *head = right_stem ? Stem::support_head (right_stem) : 0; - Grob *rcolumn = dynamic_cast (head)->get_column (); + Grob *rcolumn = dynamic_cast (head)->get_column (); Interval head_extent; if (head) @@ -170,44 +164,43 @@ same_direction_correction (Grob *note_spacing, Drul_array head_posns) { /* Correct for the following situation: - + X X | | | | | X | | | | ======== - + ^ move the center one to the left. - - + + this effect seems to be much more subtle than the stem-direction stuff (why?), and also does not scale with the difference in stem length. - + */ Interval hp = head_posns[LEFT]; hp.intersect (head_posns[RIGHT]); if (!hp.is_empty ()) return 0; - + Direction lowest = (head_posns[LEFT][DOWN] > head_posns[RIGHT][UP]) ? RIGHT : LEFT; - + Real delta = head_posns[-lowest][DOWN] - head_posns[lowest][UP]; Real corr = robust_scm2double (note_spacing->get_property ("same-direction-correction"), 0); - + return (delta > 1) ? -lowest * corr : 0; } - /* - Correct for optical illusions. See [Wanske] p. 138. The combination - up-stem + down-stem should get extra space, the combination - down-stem + up-stem less. + Correct for optical illusions. See [Wanske] p. 138. The combination + up-stem + down-stem should get extra space, the combination + down-stem + up-stem less. - TODO: have to check whether the stems are in the same staff. + TODO: have to check whether the stems are in the same staff. */ void Note_spacing::stem_dir_correction (Grob *me, Item *rcolumn, @@ -235,12 +228,12 @@ Note_spacing::stem_dir_correction (Grob *me, Item *rcolumn, Grob *bar = Spacing_interface::extremal_break_aligned_grob (me, RIGHT, rcolumn->break_status_dir (), &bar_xextent); - if (bar && dynamic_cast (bar)->get_column () == rcolumn) + if (bar && dynamic_cast (bar)->get_column () == rcolumn) bar_yextent = Staff_spacing::bar_y_positions (bar); do { - vector const &items (ly_scm2link_array (props [d])); + vector const &items (ly_scm2link_array (props [d])); for (vsize i = 0; i < items.size (); i++) { Item *it = dynamic_cast (items[i]); @@ -252,8 +245,8 @@ Note_spacing::stem_dir_correction (Grob *me, Item *rcolumn, /* Find accidentals which are sticking out of the right side. */ - if (d == RIGHT) - acc_right = acc_right || Note_column::accidentals (it); + if (d == RIGHT) + acc_right = acc_right || Note_column::accidentals (it); Grob *stem = Note_column::get_stem (it); @@ -286,8 +279,8 @@ Note_spacing::stem_dir_correction (Grob *me, Item *rcolumn, can't look at stem-end-position, since that triggers beam slope computations. */ - Real stem_end = hp[stem_dir] + - stem_dir * robust_scm2double (stem->get_property ("length"), 7); + Real stem_end = hp[stem_dir] + + stem_dir * robust_scm2double (stem->get_property ("length"), 7); stem_posns[d] = Interval (min (chord_start, stem_end), max (chord_start, stem_end)); diff --git a/lily/paper-column.cc b/lily/paper-column.cc index 24d76a163a..ac0e1fbde6 100644 --- a/lily/paper-column.cc +++ b/lily/paper-column.cc @@ -20,6 +20,7 @@ #include "paper-column.hh" #include "axis-group-interface.hh" +#include "bar-line.hh" #include "break-align-interface.hh" #include "font-interface.hh" #include "grob-array.hh" @@ -96,20 +97,20 @@ Paper_column::Paper_column (Paper_column const &src) } int -Paper_column::compare (Grob * const &a, - Grob * const &b) +Paper_column::compare (Grob *const &a, + Grob *const &b) { - return sign (dynamic_cast (a)->rank_ - - dynamic_cast (b)->rank_); + return sign (dynamic_cast (a)->rank_ + - dynamic_cast (b)->rank_); } bool Paper_column::less_than (Grob *const &a, Grob *const &b) { - Paper_column *pa = dynamic_cast (a); - Paper_column *pb = dynamic_cast (b); - + Paper_column *pa = dynamic_cast (a); + Paper_column *pb = dynamic_cast (b); + return pa->rank_ < pb->rank_; } @@ -142,7 +143,7 @@ Paper_column::is_used (Grob *me) extract_grob_set (me, "bounded-by-me", bbm); if (bbm.size ()) return true; - + if (Paper_column::is_breakable (me)) return true; @@ -160,7 +161,7 @@ Paper_column::is_breakable (Grob *me) Real Paper_column::minimum_distance (Grob *left, Grob *right) { - Drul_array cols (left, right); + Drul_array cols (left, right); Drul_array skys = Drul_array (Skyline (RIGHT), Skyline (LEFT)); Direction d = LEFT; @@ -178,18 +179,37 @@ Paper_column::minimum_distance (Grob *left, Grob *right) } Interval -Paper_column::break_align_width (Grob *me) +Paper_column::break_align_width (Grob *me, SCM align_sym) { Grob *p = me->get_parent (X_AXIS); if (is_musical (me)) { - me->programming_error ("tried to get break-align-width of a non-musical column"); + me->programming_error ("tried to get break-align-width of a musical column"); return Interval (0, 0) + me->relative_coordinate (p, X_AXIS); } - Grob *align = Pointer_group_interface::find_grob (me, ly_symbol2scm ("elements"), - Break_alignment_interface::has_interface); + Grob *align = 0; + if (align_sym == ly_symbol2scm ("staff-bar") + || align_sym == ly_symbol2scm ("break-alignment")) + align + = Pointer_group_interface::find_grob (me, ly_symbol2scm ("elements"), + (align_sym == ly_symbol2scm ("staff-bar") + ? Bar_line::non_empty_barline + : Break_alignment_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) + { + align = elts[i]; + break; + } + } + } + if (!align) return Interval (0, 0) + me->relative_coordinate (p, X_AXIS); @@ -203,7 +223,7 @@ MAKE_SCHEME_CALLBACK (Paper_column, print, 1); SCM Paper_column::print (SCM p) { - Paper_column *me = dynamic_cast (unsmob_grob (p)); + Paper_column *me = dynamic_cast (unsmob_grob (p)); string r = to_string (Paper_column::get_rank (me)); @@ -226,11 +246,11 @@ Paper_column::print (SCM p) Stencil l = Lookup::filled_box (Box (Interval (-0.01, 0.01), Interval (-2, -1))); - + SCM small_letters = scm_cons (scm_acons (ly_symbol2scm ("font-size"), scm_from_int (-6), SCM_EOL), properties); - + int j = 0; for (SCM s = me->get_object ("ideal-distances"); scm_is_pair (s); s = scm_cdr (s)) @@ -239,7 +259,7 @@ Paper_column::print (SCM p) if (!unsmob_grob (scm_cdar (s)) || !unsmob_grob (scm_cdar (s))->get_system ()) continue; - + j++; Real y = -j * 1 -3; vector pts; @@ -247,30 +267,30 @@ Paper_column::print (SCM p) Offset p2 (sp->distance (), y); pts.push_back (p2); - + Stencil id_stencil = Lookup::points_to_line_stencil (0.1, pts); Stencil head (musfont->find_by_name ("arrowheads.open.01")); SCM distance_stc = Text_interface::interpret_markup (me->layout ()->self_scm (), small_letters, ly_string2scm (String_convert::form_string ("%5.2lf", sp->distance ()))); - - id_stencil.add_stencil (unsmob_stencil (distance_stc)->translated (Offset (sp->distance ()/3, y+1))); + + id_stencil.add_stencil (unsmob_stencil (distance_stc)->translated (Offset (sp->distance () / 3, y + 1))); id_stencil.add_stencil (head.translated (p2)); id_stencil = id_stencil.in_color (0,0,1); l.add_stencil (id_stencil); } - + for (SCM s = me->get_object ("minimum-distances"); scm_is_pair (s); s = scm_cdr (s)) { Real dist = scm_to_double (scm_cdar (s)); - Grob *other = unsmob_grob (scm_caar (s)); + Grob *other = unsmob_grob (scm_caar (s)); if (!other || other->get_system () != me->get_system ()) continue; j++; - + Real y = -j * 1.0 -3.5; vector pts; pts.push_back (Offset (0, y)); @@ -287,10 +307,9 @@ Paper_column::print (SCM p) small_letters, ly_string2scm (String_convert::form_string ("%5.2lf", dist))); - - id_stencil.add_stencil (unsmob_stencil (distance_stc)->translated (Offset (dist/3, y-1))); - - + + id_stencil.add_stencil (unsmob_stencil (distance_stc)->translated (Offset (dist / 3, y - 1))); + id_stencil = id_stencil.in_color (1,0,0); l.add_stencil (id_stencil); } @@ -317,7 +336,7 @@ Paper_column::before_line_breaking (SCM grob) if (!ga) return SCM_UNSPECIFIED; - vector &array (ga->array_reference ()); + vector &array (ga->array_reference ()); for (vsize i = array.size (); i--;) { @@ -351,14 +370,13 @@ Paper_column::is_extraneous_column_from_ligature (Grob *me) if (Rhythmic_head::has_interface (elts[i])) { has_notehead = true; - if (dynamic_cast (elts[i])->get_column () == me) + if (dynamic_cast (elts[i])->get_column () == me) return false; } } return has_notehead; } - ADD_INTERFACE (Paper_column, "@code{Paper_column} objects form the top-most X@tie{}parents" " for items. There are two types of columns: musical and" @@ -392,6 +410,5 @@ ADD_INTERFACE (Paper_column, "shortest-starter-duration " "spacing " "used " - "when " - ); + "when "); diff --git a/scm/define-grob-properties.scm b/scm/define-grob-properties.scm index a7262de34b..b3401d2261 100644 --- a/scm/define-grob-properties.scm +++ b/scm/define-grob-properties.scm @@ -755,6 +755,16 @@ there.") (spacing-increment ,number? "Add this much space for a doubled duration. Typically, the width of a note head. See also @rinternals{spacing-spanner-interface}.") + (spacing-pair ,pair? "A pair of alignment symbols which set an object's +spacing relative to its left and right @code{BreakAlignment}s. + +For example, a @code{MultiMeasureRest} will ignore prefatory items at its +bounds (i.e., clefs, key signatures and time signatures) using the following +override: + +@example +\\override MultiMeasureRest #'spacing-pair = #'(staff-bar . staff-bar) +@end example") (springs-and-rods ,boolean? "Dummy variable for triggering spacing routines.") (stacking-dir ,ly:dir? "Stack objects in which direction?") diff --git a/scm/define-grobs.scm b/scm/define-grobs.scm index 92a62bfcef..15d0b0d908 100644 --- a/scm/define-grobs.scm +++ b/scm/define-grobs.scm @@ -1174,6 +1174,7 @@ (expand-limit . 10) (hair-thickness . 2.0) (padding . 1) + (spacing-pair . (break-alignment . staff-bar)) (springs-and-rods . ,ly:multi-measure-rest::set-spacing-rods) (staff-position . 0) (stencil . ,ly:multi-measure-rest::print) @@ -1414,6 +1415,7 @@ (dot-negative-kern . 0.75) (font-encoding . fetaMusic) (slope . 1.0) + (spacing-pair . (break-alignment . staff-bar)) (springs-and-rods . ,ly:multi-measure-rest::set-spacing-rods) (stencil . ,ly:multi-measure-rest::percent) (thickness . 0.48) -- 2.39.2