From 06c4a2745f6425c4ea34dbca6348cd33b8cfa481 Mon Sep 17 00:00:00 2001 From: Han-Wen Nienhuys Date: Tue, 5 Dec 2006 16:15:11 +0100 Subject: [PATCH] Take measure length from left command column. Fixes #168 Put Spacing_options in separate header. (cherry picked from 7a46734071cd46d2395ed59fae0178b5f9400993 commit) --- input/regression/spacing-measure-length.ly | 26 +++++++++++++++++ lily/include/lily-proto.hh | 1 + lily/include/spacing-options.hh | 30 +++++++++++++++++++ lily/include/spacing-spanner.hh | 15 ---------- lily/spacing-basic.cc | 34 +++++++++++++++++++++- lily/spacing-determine-loose-columns.cc | 1 + lily/spacing-loose-columns.cc | 1 + lily/spacing-options.cc | 2 +- lily/spacing-spanner.cc | 2 ++ lily/system.cc | 1 + 10 files changed, 96 insertions(+), 17 deletions(-) create mode 100644 input/regression/spacing-measure-length.ly create mode 100644 lily/include/spacing-options.hh diff --git a/input/regression/spacing-measure-length.ly b/input/regression/spacing-measure-length.ly new file mode 100644 index 0000000000..848f27870d --- /dev/null +++ b/input/regression/spacing-measure-length.ly @@ -0,0 +1,26 @@ +\header { + + texidoc = "Horizontal spacing is bounded by of the current measure length. +This means that the 3/8 setting does not affect the whole rest spacing." + +} + + +\version "2.11.1" + +\layout { + ragged-right = ##t +} + +\score { + \new Staff \with { + \remove Separating_line_group_engraver + } { + \relative c' { + \override Score.SpacingSpanner #'uniform-stretching = ##t + \set Score.proportionalNotationDuration = #(ly:make-moment 4 25) + r1 + \time 3/8 r4. + } + } +} diff --git a/lily/include/lily-proto.hh b/lily/include/lily-proto.hh index 58e7cb4c84..c3082aaddd 100644 --- a/lily/include/lily-proto.hh +++ b/lily/include/lily-proto.hh @@ -150,6 +150,7 @@ class Simultaneous_music_iterator; class Skyline_entry; class Slur_configuration; class Slur_score_state; +class Spacing_options; class Span_score_bar_engraver; class Spanner; class Staff_group_bar_engraver; diff --git a/lily/include/spacing-options.hh b/lily/include/spacing-options.hh new file mode 100644 index 0000000000..faebb55489 --- /dev/null +++ b/lily/include/spacing-options.hh @@ -0,0 +1,30 @@ +/* + spacing-options.hh -- declare Spacing_options + + source file of the GNU LilyPond music typesetter + + (c) 2006 Han-Wen Nienhuys + +*/ + +#ifndef SPACING_OPTIONS_HH +#define SPACING_OPTIONS_HH + +#include "lily-proto.hh" +#include "rational.hh" + +struct Spacing_options +{ + bool packed_; + bool stretch_uniformly_; + bool float_nonmusical_columns_; + bool float_grace_columns_; + Rational global_shortest_; + Real increment_; + Real shortest_duration_space_; + + Spacing_options(); + void init_from_grob (Grob *me); + Real get_duration_space (Rational d, bool *) const; +}; +#endif /* SPACING_OPTIONS_HH */ diff --git a/lily/include/spacing-spanner.hh b/lily/include/spacing-spanner.hh index f39ea98bc3..b1467225b7 100644 --- a/lily/include/spacing-spanner.hh +++ b/lily/include/spacing-spanner.hh @@ -14,21 +14,6 @@ #include "rational.hh" #include "std-vector.hh" -struct Spacing_options -{ - bool packed_; - bool stretch_uniformly_; - bool float_nonmusical_columns_; - bool float_grace_columns_; - Rational global_shortest_; - Real increment_; - Real shortest_duration_space_; - - Spacing_options(); - void init_from_grob (Grob *me); - Real get_duration_space (Rational d, bool *) const; -}; - /* TODO: prune to public interface. */ diff --git a/lily/spacing-basic.cc b/lily/spacing-basic.cc index fcae3dfcc2..2e81fdf416 100644 --- a/lily/spacing-basic.cc +++ b/lily/spacing-basic.cc @@ -7,9 +7,13 @@ */ #include "spacing-spanner.hh" + +#include "spacing-options.hh" #include "moment.hh" #include "paper-column.hh" #include "warn.hh" +#include "pointer-group-interface.hh" +#include "system.hh" /* LilyPond spaces by taking a simple-minded spacing algorithm, and @@ -75,6 +79,34 @@ Spacing_spanner::standard_breakable_column_spacing (Grob *me, Item *l, Item *r, } } +Moment * +get_measure_length (Grob *column) +{ + Grob * sys = column->get_parent (X_AXIS); + + extract_grob_set (sys, "columns", cols); + + vsize col_idx = binary_search (cols, column, + Paper_column::less_than); + + if (col_idx == VPOS) + { + programming_error ( __FUNCTION__ + string (": Unknown column")); + return 0; + } + + do + { + if (Moment *len = unsmob_moment (cols[col_idx]->get_property ("measure-length"))) + { + return len; + } + } + while (col_idx-- != 0); + + return 0; +} + Real Spacing_spanner::note_spacing (Grob *me, Grob *lc, Grob *rc, Spacing_options const *options, @@ -106,7 +138,7 @@ Spacing_spanner::note_spacing (Grob *me, Grob *lc, Grob *rc, several measures. */ - Moment *dt = unsmob_moment (rc->get_property ("measure-length")); + Moment *dt = get_measure_length (lc); if (dt) { delta_t = min (delta_t, *dt); diff --git a/lily/spacing-determine-loose-columns.cc b/lily/spacing-determine-loose-columns.cc index 8cd0b9b6a0..ccb37a29d5 100644 --- a/lily/spacing-determine-loose-columns.cc +++ b/lily/spacing-determine-loose-columns.cc @@ -9,6 +9,7 @@ #include "staff-spacing.hh" +#include "spacing-options.hh" #include "system.hh" #include "paper-column.hh" #include "column-x-positions.hh" diff --git a/lily/spacing-loose-columns.cc b/lily/spacing-loose-columns.cc index 13a37071c0..94bc552e6f 100644 --- a/lily/spacing-loose-columns.cc +++ b/lily/spacing-loose-columns.cc @@ -15,6 +15,7 @@ #include "spacing-spanner.hh" #include "warn.hh" #include "moment.hh" +#include "spacing-options.hh" /* Find the loose columns in POSNS, and drape them around the columns specified in BETWEEN-COLS. */ diff --git a/lily/spacing-options.cc b/lily/spacing-options.cc index 916408aa73..c0e11fa62c 100644 --- a/lily/spacing-options.cc +++ b/lily/spacing-options.cc @@ -7,7 +7,7 @@ */ -#include "spacing-spanner.hh" +#include "spacing-options.hh" #include "grob.hh" #include "misc.hh" #include "moment.hh" diff --git a/lily/spacing-spanner.cc b/lily/spacing-spanner.cc index 2f6e90326c..e6024b3439 100644 --- a/lily/spacing-spanner.cc +++ b/lily/spacing-spanner.cc @@ -10,8 +10,10 @@ #include #include + using namespace std; +#include "spacing-options.hh" #include "international.hh" #include "main.hh" #include "moment.hh" diff --git a/lily/system.cc b/lily/system.cc index 0649849b21..ae1abd60c9 100644 --- a/lily/system.cc +++ b/lily/system.cc @@ -451,6 +451,7 @@ System::broken_col_range (Item const *left, Item const *right) const return ret; } + /** Return all columns, but filter out any unused columns , since they might disrupt the spacing problem. */ vector -- 2.39.5