From: Han-Wen Nienhuys Date: Sun, 7 Jan 2007 17:03:15 +0000 (+0100) Subject: Notes or rests that fill an entire measure are preceded by some more space. X-Git-Tag: release/2.11.10-1~21 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=965f52a64e989bb9f3f03b08e5f43dff1156a9eb;p=lilypond.git Notes or rests that fill an entire measure are preceded by some more space. --- diff --git a/input/regression/spacing-bar-whole-measure.ly b/input/regression/spacing-bar-whole-measure.ly new file mode 100644 index 0000000000..e2cb1d9f1d --- /dev/null +++ b/input/regression/spacing-bar-whole-measure.ly @@ -0,0 +1,21 @@ +\header{ + texidoc = "Notes that fill a whole measure are preceded by extra space. " + + } + +\version "2.11.10" + +\layout{ + ragged-right=##t +} + +\new Staff \relative { + \override Score.NonMusicalPaperColumn #'stencil = #ly:paper-column::print + \override Score.NonMusicalPaperColumn #'layer = #1 + + \time 4/4 + s1 + c2. c4 + \time 3/4 + c2. +} diff --git a/lily/constrained-breaking.cc b/lily/constrained-breaking.cc index cbc22cfc05..1a03c6b324 100644 --- a/lily/constrained-breaking.cc +++ b/lily/constrained-breaking.cc @@ -329,7 +329,7 @@ Constrained_breaking::initialize () Interval other_lines = line_dimensions_int (pscore_->layout (), 1); /* do all the rod/spring problems */ breaks_ = pscore_->find_break_indices (); - all_ = pscore_->root_system ()->columns (); + all_ = pscore_->root_system ()->used_columns (); lines_.resize (breaks_.size (), breaks_.size (), Line_details ()); vector forces = get_line_forces (all_, other_lines.length (), diff --git a/lily/include/spacing-options.hh b/lily/include/spacing-options.hh index faebb55489..1b5ee32db0 100644 --- a/lily/include/spacing-options.hh +++ b/lily/include/spacing-options.hh @@ -12,6 +12,7 @@ #include "lily-proto.hh" #include "rational.hh" +#include "std-vector.hh" struct Spacing_options { @@ -22,7 +23,8 @@ struct Spacing_options Rational global_shortest_; Real increment_; Real shortest_duration_space_; - + vector columns_; + Spacing_options(); void init_from_grob (Grob *me); Real get_duration_space (Rational d, bool *) const; diff --git a/lily/include/spacing-spanner.hh b/lily/include/spacing-spanner.hh index 6a27eb158b..6723dfefbf 100644 --- a/lily/include/spacing-spanner.hh +++ b/lily/include/spacing-spanner.hh @@ -26,14 +26,14 @@ private: static Real get_duration_space (Moment dur, Spacing_options const *, bool *); static Rational effective_shortest_duration (Grob *me, vector const &all); static void breakable_column_spacing (Grob *, Item *l, Item *r, Spacing_options const *); - static void prune_loose_columns (Grob *, vector *cols, Spacing_options const *); + static void prune_loose_columns (Grob *, Spacing_options *); static void set_explicit_neighbor_columns (vector const &cols); static void set_implicit_neighbor_columns (vector const &cols); - static void generate_springs (Grob *me, vector const &cols, Spacing_options const *); + static void generate_springs (Grob *me, Spacing_options const *); static void musical_column_spacing (Grob *, Item *, Item *, Spacing_options const *); - static vector get_columns (Spanner *me); - + static bool fills_measure (Grob *, Item *, Item *); public: + static vector get_columns (Grob *me); static Real note_spacing (Grob *, Grob *, Grob *, Spacing_options const *, bool *); static void standard_breakable_column_spacing (Grob *me, Item *l, Item *r, Real *fixed, Real *space, diff --git a/lily/include/system.hh b/lily/include/system.hh index 44bb21d516..597b3204fc 100644 --- a/lily/include/system.hh +++ b/lily/include/system.hh @@ -44,8 +44,8 @@ public: DECLARE_GROB_INTERFACE(); vector broken_col_range (Item const *, Item const *) const; - vector columns () const; - Grob *column (int i) const; + vector used_columns () const; + Grob *column (vsize i) const; void add_column (Paper_column *); void typeset_grob (Grob *); diff --git a/lily/page-breaking.cc b/lily/page-breaking.cc index b43c302367..76cecc03c3 100644 --- a/lily/page-breaking.cc +++ b/lily/page-breaking.cc @@ -255,7 +255,7 @@ Page_breaking::find_chunks_and_breaks (Break_predicate is_break) { if (all_[i].pscore_) { - vector cols = all_[i].pscore_->root_system ()->columns (); + vector cols = all_[i].pscore_->root_system ()->used_columns (); vector line_breaker_columns; line_breaker_columns.push_back (0); diff --git a/lily/paper-column.cc b/lily/paper-column.cc index 7d5009b957..e42a3417e2 100644 --- a/lily/paper-column.cc +++ b/lily/paper-column.cc @@ -167,7 +167,6 @@ Paper_column::print (SCM p) Stencil l = Lookup::filled_box (Box (Interval (-0.01, 0.01), Interval (-2, -1))); - System * my_system = me->get_system (); SCM small_letters = scm_cons (scm_acons (ly_symbol2scm ("font-size"), scm_from_int (-6), SCM_EOL), properties); diff --git a/lily/paper-score.cc b/lily/paper-score.cc index 047e880f3c..f299e56e8e 100644 --- a/lily/paper-score.cc +++ b/lily/paper-score.cc @@ -62,7 +62,7 @@ Paper_score::typeset_system (System *system) vector Paper_score::find_break_indices () const { - vector all = root_system ()->columns (); + vector all = root_system ()->used_columns (); vector retval; for (vsize i = 0; i < all.size (); i++) @@ -125,7 +125,7 @@ Paper_score::process () down the road. doubly, also done in Score_engraver */ - vector pc (system_->columns ()); + vector pc (system_->used_columns ()); pc[0]->set_property ("line-break-permission", ly_symbol2scm ("allow")); pc.back ()->set_property ("line-break-permission", ly_symbol2scm ("allow")); diff --git a/lily/spacing-determine-loose-columns.cc b/lily/spacing-determine-loose-columns.cc index 052e0d766b..11e9caa18d 100644 --- a/lily/spacing-determine-loose-columns.cc +++ b/lily/spacing-determine-loose-columns.cc @@ -194,9 +194,9 @@ Spacing_spanner::set_distances_for_loose_col (Grob *me, Grob *c, between. */ void -Spacing_spanner::prune_loose_columns (Grob *me, vector *cols, - Spacing_options const *options) -{ +Spacing_spanner::prune_loose_columns (Grob *me, Spacing_options *options) + { + vector *cols = &options->columns_; vector newcols; for (vsize i = 0; i < cols->size (); i++) diff --git a/lily/spacing-options.cc b/lily/spacing-options.cc index c0e11fa62c..9a73ad6d7f 100644 --- a/lily/spacing-options.cc +++ b/lily/spacing-options.cc @@ -8,9 +8,11 @@ */ #include "spacing-options.hh" +#include "spacing-spanner.hh" #include "grob.hh" #include "misc.hh" #include "moment.hh" +#include "spanner.hh" void Spacing_options::init_from_grob (Grob *me) @@ -34,6 +36,7 @@ Spacing_options::init_from_grob (Grob *me) else global_shortest_ = shortest_dur.grace_part_; + columns_ = Spacing_spanner::get_columns (me); // ugh. } Spacing_options::Spacing_options () diff --git a/lily/spacing-spanner.cc b/lily/spacing-spanner.cc index 497474d7d1..fb91f0b010 100644 --- a/lily/spacing-spanner.cc +++ b/lily/spacing-spanner.cc @@ -29,14 +29,15 @@ using namespace std; #include "warn.hh" vector -Spacing_spanner::get_columns (Spanner *me) +Spacing_spanner::get_columns (Grob *me_grob) { - vector all (get_root_system (me)->columns ()); + Spanner *me = dynamic_cast (me_grob); + vector all (get_root_system (me)->used_columns ()); vsize start = binary_search (all, (Grob*)me->get_bound (LEFT), &Paper_column::less_than); vsize end = binary_search (all, (Grob*) me->get_bound (RIGHT), - &Paper_column::less_than); - + &Paper_column::less_than); + all = vector::vector (all.begin () + start, all.begin () + end + 1); return all; @@ -51,15 +52,14 @@ Spacing_spanner::set_springs (SCM smob) /* can't use get_system() ? --hwn. */ - vector all (get_columns (me)); - set_explicit_neighbor_columns (all); - Spacing_options options; options.init_from_grob (me); - prune_loose_columns (me, &all, &options); - set_implicit_neighbor_columns (all); - generate_springs (me, all, &options); + set_explicit_neighbor_columns (options.columns_); + + prune_loose_columns (me, &options); + set_implicit_neighbor_columns (options.columns_); + generate_springs (me, &options); return SCM_UNSPECIFIED; } @@ -216,14 +216,13 @@ Spacing_spanner::generate_pair_spacing (Grob *me, void Spacing_spanner::generate_springs (Grob *me, - vector const &cols, Spacing_options const *options) { Paper_column *prev = 0; - for (vsize i = 0; i < cols.size (); i++) + for (vsize i = 0; i < options->columns_.size (); i++) { - Paper_column *col = dynamic_cast (cols[i]); - Paper_column *next = (i < cols.size()-1) ? dynamic_cast (cols[i+1]) : 0; + Paper_column *col = dynamic_cast (options->columns_[i]); + Paper_column *next = (i < options->columns_.size()-1) ? dynamic_cast (options->columns_[i+1]) : 0; if (i > 0) generate_pair_spacing (me, prev, col, next, options); @@ -394,6 +393,27 @@ Spacing_spanner::musical_column_spacing (Grob *me, Spaceable_grob::add_spring (left_col, right_col, distance, inverse_strength); } +bool +Spacing_spanner::fills_measure (Grob *me, Item *l, Item *r) +{ + return false; + System *sys = get_root_system (me); + Grob *next = sys->column (r->get_column()->get_rank () + 1); + if (!next) + return false; + + Moment dt = + Paper_column::when_mom (next) - Paper_column::when_mom (r); + + Moment *len = unsmob_moment (l->get_property ("measure-length")); + if (!len) + return false; + + if (dt.main_part_ == len->main_part_) + return true; + + return false; +} /* Read hints from L and generate springs. */ @@ -427,7 +447,6 @@ Spacing_spanner::breakable_column_spacing (Grob *me, Item *l, Item *r, /* column for the left one settings should be ok due automatic pointer munging. - */ assert (spacing_grob->get_column () == l); @@ -474,6 +493,11 @@ Spacing_spanner::breakable_column_spacing (Grob *me, Item *l, Item *r, } + if (fills_measure (me, l, r)) + { + compound_space += 1.0; + } + if (options->stretch_uniformly_ && l->break_status_dir () != RIGHT) compound_fixed = 0.0; diff --git a/lily/system.cc b/lily/system.cc index 5070f9426c..12ceddd1f5 100644 --- a/lily/system.cc +++ b/lily/system.cc @@ -467,7 +467,7 @@ System::broken_col_range (Item const *left, Item const *right) const /** Return all columns, but filter out any unused columns , since they might disrupt the spacing problem. */ vector -System::columns () const +System::used_columns () const { extract_grob_set (this, "columns", ro_columns); @@ -490,9 +490,12 @@ System::columns () const } Grob* -System::column (int which) const +System::column (vsize which) const { extract_grob_set (this, "columns", columns); + if (which >= columns.size ()) + return 0; + return columns[which]; }