Index: ChangeLog =================================================================== RCS file: /sources/lilypond/lilypond/ChangeLog,v retrieving revision 1.5304 diff -u -r1.5304 ChangeLog --- ChangeLog 16 Sep 2006 22:34:51 -0000 1.5304 +++ ChangeLog 17 Sep 2006 06:14:52 -0000 @@ -1,3 +1,53 @@ +2006-09-17 Joe Neeman + + * scm/define-music-types.scm (music-descriptions): remove + BreakEvent and fix {Page,Line}{Break,Turn}Event so + Music::to_event doesn't complain. + + * lily/accidental-placement.cc (ape_compare): + * lily/semi-tie.cc (compare): + * lily/note-column.cc (shift_compare): replace by XXX_less + + * lily/tie-formatting-problem.cc (set_chord_outline): + * lily/tie-column.cc (calc_positioning_done): + * lily/system.cc (post_processing) + (get_paper_system): + * lily/stem.cc (note_head_positions) + (calc_positioning_done): + * lily/spanner.cc (do_break_processing) + (find_broken_piece): + * lily/span-bar.cc (print): + * lily/semi-tie-column.cc (calc_positioning_done): + * lily/rest-collision.cc (calc_positioning_done): + * lily/program-option.cc (get_help_string): + * lily/note-collision.cc (get_clash_groups): + * lily/new-fingering-engraver.cc (position_scripts): + * lily/keyword.cc (Keyword_table): + * lily/hara-kiri-group-spanner.cc (request_suicide): + * lily/grob-pq-engraver.cc (stop_translation_timestep): + * lily/accidental-placement.cc (calc_positioning_done): + (stagger_apes): + * lily/beam.cc (get_beam_segments): + * lily/grob-array.cc (remove_duplicates): + use new vector_sort + + * input/mutopia/W.A.Mozart/mozart-hrn3-defs.ily: + ragged-last-bottom = ##f (test the new page breaker) + + * flower/include/std-vector.hh (vector_sort): use STL sort stuff + + * scm/define-context-properties.scm + (all-internal-translation-properties): remove properties that + were used to communicate page-turn stuff to the paper-column + engraver. + + * lily/lily-guile.cc (robust_scm2string): new function + + * lily/paper-column-engraver.cc: Clean up page turn stuff + + * lily/page-turn-engraver.cc: Re-write the page turn logic here + instead of cluttering up paper-column-engraver.cc + 2006-09-17 Han-Wen Nienhuys * scm/script.scm (default-script-alist): set paddings for every Index: flower/include/interval.hh =================================================================== RCS file: /sources/lilypond/lilypond/flower/include/interval.hh,v retrieving revision 1.58 diff -u -r1.58 interval.hh --- flower/include/interval.hh 11 Feb 2006 11:35:18 -0000 1.58 +++ flower/include/interval.hh 17 Sep 2006 06:14:52 -0000 @@ -128,9 +128,9 @@ at (RIGHT) = t; } - static int left_comparison (Interval_t const &a, Interval_t const &b) + static bool left_less (Interval_t const &a, Interval_t const &b) { - return sign (a[LEFT] - b[RIGHT]); + return a[LEFT] < b[RIGHT]; } }; Index: flower/include/std-vector.hh =================================================================== RCS file: /sources/lilypond/lilypond/flower/include/std-vector.hh,v retrieving revision 1.27 diff -u -r1.27 std-vector.hh --- flower/include/std-vector.hh 16 Sep 2006 21:26:48 -0000 1.27 +++ flower/include/std-vector.hh 17 Sep 2006 06:14:52 -0000 @@ -191,46 +191,17 @@ return lb; } -#if 0 -/* FIXME: the COMPARE functionality is broken? */ -template +template void -vector_sort (vector &v, int (*compare) (T const &, T const &), - vsize lower=VPOS, vsize upper=VPOS) +vector_sort (vector &v, + Compare less, + vsize b=0, vsize e=VPOS) { - typename vector::iterator b = v.begin (); - typename vector::iterator e = v.begin (); - if (lower == VPOS) - { - lower = 0; - upper = v.size (); - } - sort (b + lower, e + upper, compare); -} -#else + if (e == VPOS) + e = v.size (); -// ugh, c&p -template void -vector_sort (vector &v, int (*compare) (T const &, T const &), - vsize lower=VPOS, vsize upper=VPOS) -{ - if (lower == VPOS) - { - lower = 0; - upper = v.size () - 1; - } - if (upper == VPOS || lower >= upper) - return; - swap (v[lower], v[(lower + upper) / 2]); - vsize last = lower; - for (vsize i = lower +1; i <= upper; i++) - if (compare (v[i], v[lower]) < 0) - swap (v[++last], v[i]); - swap (v[lower], v[last]); - vector_sort (v, compare, lower, last - 1); - vector_sort (v, compare, last + 1, upper); + sort (v.begin () + b, v.begin () + e, less); } -#endif template void Index: input/mutopia/W.A.Mozart/mozart-hrn3-defs.ily =================================================================== RCS file: /sources/lilypond/lilypond/input/mutopia/W.A.Mozart/mozart-hrn3-defs.ily,v retrieving revision 1.10 diff -u -r1.10 mozart-hrn3-defs.ily --- input/mutopia/W.A.Mozart/mozart-hrn3-defs.ily 16 Mar 2006 23:21:06 -0000 1.10 +++ input/mutopia/W.A.Mozart/mozart-hrn3-defs.ily 17 Sep 2006 06:14:52 -0000 @@ -45,6 +45,7 @@ indent = 10. \mm line-width = 189. \mm + ragged-last-bottom = ##f } Index: lily/accidental-placement.cc =================================================================== RCS file: /sources/lilypond/lilypond/lily/accidental-placement.cc,v retrieving revision 1.71 diff -u -r1.71 accidental-placement.cc --- lily/accidental-placement.cc 19 Jul 2006 21:33:02 -0000 1.71 +++ lily/accidental-placement.cc 17 Sep 2006 06:14:52 -0000 @@ -135,6 +135,12 @@ return sign (ape_priority (a) - ape_priority (b)); } +bool ape_less (Accidental_placement_entry *const &a, + Accidental_placement_entry *const &b) +{ + return ape_priority (a) < ape_priority (b); +} + int ape_rcompare (Accidental_placement_entry *const &a, Accidental_placement_entry *const &b) { @@ -154,7 +160,7 @@ { vector asc = *apes; - vector_sort (asc, &ape_compare); + vector_sort (asc, &ape_less); apes->clear (); @@ -293,7 +299,7 @@ for (vsize i = note_cols.size (); i--;) concat (heads, extract_grob_array (note_cols[i], "note-heads")); - vector_sort (heads, default_compare); + vector_sort (heads, less ()); uniq (heads); common[Y_AXIS] = common_refpoint_of_array (heads, common[Y_AXIS], Y_AXIS); Index: lily/beam.cc =================================================================== RCS file: /sources/lilypond/lilypond/lily/beam.cc,v retrieving revision 1.364 diff -u -r1.364 beam.cc --- lily/beam.cc 22 May 2006 17:45:40 -0000 1.364 +++ lily/beam.cc 17 Sep 2006 06:14:55 -0000 @@ -368,7 +368,7 @@ i != stem_segments.end (); i++) { vector segs = (*i).second; - vector_sort (segs, default_compare); + vector_sort (segs, less ()); Beam_segment current; Index: lily/dot-column.cc =================================================================== RCS file: /sources/lilypond/lilypond/lily/dot-column.cc,v retrieving revision 1.98 diff -u -r1.98 dot-column.cc --- lily/dot-column.cc 15 Feb 2006 13:02:17 -0000 1.98 +++ lily/dot-column.cc 17 Sep 2006 06:14:55 -0000 @@ -233,7 +233,7 @@ } } - vector_sort (dots, &compare_position); + vector_sort (dots, position_less); for (vsize i = dots.size (); i--;) if (!dots[i]->is_live ()) dots.erase (dots.begin () + i); Index: lily/grob-array.cc =================================================================== RCS file: /sources/lilypond/lilypond/lily/grob-array.cc,v retrieving revision 1.14 diff -u -r1.14 grob-array.cc --- lily/grob-array.cc 28 May 2006 18:03:49 -0000 1.14 +++ lily/grob-array.cc 17 Sep 2006 06:14:55 -0000 @@ -87,7 +87,7 @@ { assert (!ordered_); - vector_sort (grobs_, default_compare); + vector_sort (grobs_, less ()); ::uniq (grobs_); } Index: lily/grob-pq-engraver.cc =================================================================== RCS file: /sources/lilypond/lilypond/lily/grob-pq-engraver.cc,v retrieving revision 1.49 diff -u -r1.49 grob-pq-engraver.cc --- lily/grob-pq-engraver.cc 11 Feb 2006 11:35:18 -0000 1.49 +++ lily/grob-pq-engraver.cc 17 Sep 2006 06:14:55 -0000 @@ -15,13 +15,14 @@ { Grob *grob_; Moment end_; - static int compare (Grob_pq_entry const &a, - Grob_pq_entry const &b) - { - return Moment::compare (a.end_, b.end_); - } }; +bool +operator< (Grob_pq_entry const &a, Grob_pq_entry const &b) +{ + return a.end_ < b.end_; +} + class Grob_pq_engraver : public Engraver { public: @@ -95,7 +96,7 @@ while (scm_is_pair (busy) && *unsmob_moment (scm_caar (busy)) == now) busy = scm_cdr (busy); - vector_sort (started_now_, Grob_pq_entry::compare); + vector_sort (started_now_, less ()); SCM lst = SCM_EOL; SCM *tail = &lst; for (vsize i = 0; i < started_now_.size (); i++) Index: lily/hara-kiri-group-spanner.cc =================================================================== RCS file: /sources/lilypond/lilypond/lily/hara-kiri-group-spanner.cc,v retrieving revision 1.56 diff -u -r1.56 hara-kiri-group-spanner.cc --- lily/hara-kiri-group-spanner.cc 24 Jul 2006 11:50:27 -0000 1.56 +++ lily/hara-kiri-group-spanner.cc 17 Sep 2006 06:14:55 -0000 @@ -82,7 +82,7 @@ for (int j = iv[LEFT]; j <= iv[RIGHT]; j++) ranks.push_back (j); } - vector_sort (ranks, default_compare); + vector_sort (ranks, less ()); uniq (ranks); SCM scm_vec = scm_c_make_vector (ranks.size (), SCM_EOL); Index: lily/keyword.cc =================================================================== RCS file: /sources/lilypond/lilypond/lily/keyword.cc,v retrieving revision 1.19 diff -u -r1.19 keyword.cc --- lily/keyword.cc 7 Sep 2006 11:16:10 -0000 1.19 +++ lily/keyword.cc 17 Sep 2006 06:14:55 -0000 @@ -14,17 +14,12 @@ return strcmp (p1.name_, p2.name_) < 0; } -int tabcmp (Keyword_ent const &p1, Keyword_ent const &p2) -{ - return strcmp (p1.name_, p2.name_); -} - Keyword_table::Keyword_table (Keyword_ent *tab) { while (tab->name_) table_.push_back (*tab++); - vector_sort (table_, tabcmp); + vector_sort (table_, tab_less); } vsize Index: lily/lily-guile.cc =================================================================== RCS file: /sources/lilypond/lilypond/lily/lily-guile.cc,v retrieving revision 1.246 diff -u -r1.246 lily-guile.cc --- lily/lily-guile.cc 4 Sep 2006 05:51:14 -0000 1.246 +++ lily/lily-guile.cc 17 Sep 2006 06:14:55 -0000 @@ -653,6 +650,14 @@ return o; } +string +robust_scm2string (SCM k, string s) +{ + if (scm_is_string (k)) + s = ly_scm2string (k); + return s; +} + int robust_scm2int (SCM k, int o) { Index: lily/new-fingering-engraver.cc =================================================================== RCS file: /sources/lilypond/lilypond/lily/new-fingering-engraver.cc,v retrieving revision 1.79 diff -u -r1.79 new-fingering-engraver.cc --- lily/new-fingering-engraver.cc 11 Feb 2006 11:35:17 -0000 1.79 +++ lily/new-fingering-engraver.cc 17 Sep 2006 06:14:55 -0000 @@ -35,12 +35,14 @@ note_event_ = finger_event_ = 0; follow_into_staff_ = false; } - static int compare (Finger_tuple const &c1, Finger_tuple const &c2) - { - return c1.position_- c2.position_; - } }; +bool +operator< (Finger_tuple const &a, Finger_tuple const &b) +{ + return a.position_ < b.position_; +} + class New_fingering_engraver : public Engraver { vector fingerings_; @@ -220,7 +222,7 @@ } } - vector_sort (*scripts, Finger_tuple::compare); + vector_sort (*scripts, less ()); bool up_p = scm_c_memq (ly_symbol2scm ("up"), orientations) != SCM_BOOL_F; bool down_p = scm_c_memq (ly_symbol2scm ("down"), orientations) != SCM_BOOL_F; Index: lily/note-collision.cc =================================================================== RCS file: /sources/lilypond/lilypond/lily/note-collision.cc,v retrieving revision 1.70 diff -u -r1.70 note-collision.cc --- lily/note-collision.cc 7 Sep 2006 21:30:59 -0000 1.70 +++ lily/note-collision.cc 17 Sep 2006 06:14:55 -0000 @@ -371,7 +371,7 @@ do { vector &clashes (clash_groups[d]); - vector_sort (clashes, Note_column::shift_compare); + vector_sort (clashes, Note_column::shift_less); } while ((flip (&d)) != UP); Index: lily/note-column.cc =================================================================== RCS file: /sources/lilypond/lilypond/lily/note-column.cc,v retrieving revision 1.120 diff -u -r1.120 note-column.cc --- lily/note-column.cc 16 Sep 2006 21:26:48 -0000 1.120 +++ lily/note-column.cc 17 Sep 2006 06:14:55 -0000 @@ -34,15 +34,15 @@ return unsmob_grob (me->get_object ("rest")); } -int -Note_column::shift_compare (Grob *const &p1, Grob *const &p2) +bool +Note_column::shift_less (Grob *const &p1, Grob *const &p2) { SCM s1 = p1->get_property ("horizontal-shift"); SCM s2 = p2->get_property ("horizontal-shift"); int h1 = (scm_is_number (s1)) ? scm_to_int (s1) : 0; int h2 = (scm_is_number (s2)) ? scm_to_int (s2) : 0; - return h1 - h2; + return h1 < h2; } Item * Index: lily/page-turn-engraver.cc =================================================================== RCS file: /sources/lilypond/lilypond/lily/page-turn-engraver.cc,v retrieving revision 1.1 diff -u -r1.1 page-turn-engraver.cc --- lily/page-turn-engraver.cc 8 Aug 2006 10:01:22 -0000 1.1 +++ lily/page-turn-engraver.cc 17 Sep 2006 06:14:55 -0000 @@ -13,8 +13,58 @@ #include "grob.hh" #include "international.hh" #include "moment.hh" +#include "paper-column.hh" +#include "stream-event.hh" #include "warn.hh" +#include "translator.icc" + +class Page_turn_event { +public: + SCM permission_; + Real penalty_; + Interval_t duration_; + + Page_turn_event (Rational start, Rational end, SCM perm, Real pen) + { + duration_[LEFT] = start; + duration_[RIGHT] = end; + permission_ = perm; + penalty_ = pen; + } + + /* Suppose we have decided on a possible page turn, only to change + out mind later (for example, if there is a volta repeat and it + would be difficult to turn the page back). Then we need to + re-penalize a region of the piece. Depending on how the events + intersect, we may have to split it into as many as 3 pieces. + */ + vector penalize (Page_turn_event const &penalty) + { + Interval_t intersect = intersection (duration_, penalty.duration_); + vector ret; + + if (intersect.is_empty ()) + { + ret.push_back (*this); + return ret; + } + + Real new_pen = max (penalty_, penalty.penalty_); + + if (duration_[LEFT] < penalty.duration_[LEFT]) + ret.push_back (Page_turn_event (duration_[LEFT], penalty.duration_[LEFT], permission_, penalty_)); + + if (penalty.permission_ != SCM_EOL) + ret.push_back (Page_turn_event (intersect[LEFT], intersect[RIGHT], permission_, new_pen)); + + if (penalty.duration_[RIGHT] < duration_[RIGHT]) + ret.push_back (Page_turn_event (penalty.duration_[RIGHT], duration_[LEFT], permission_, penalty_)); + + return ret; + } +}; + class Page_turn_engraver : public Engraver { Moment rest_begin_; @@ -22,14 +72,28 @@ Moment note_end_; Rational repeat_begin_rest_length_; + vector forced_breaks_; + vector automatic_breaks_; + vector repeat_penalties_; + + /* the next 3 are in sync (ie. same number of elements, etc.) */ + vector breakable_moments_; + vector breakable_columns_; + vector special_barlines_; + + SCM max_permission (SCM perm1, SCM perm2); Real penalty (Rational rest_len); + Grob *breakable_column (Page_turn_event const &); protected: + DECLARE_TRANSLATOR_LISTENER (break); DECLARE_ACKNOWLEDGER (note_head); public: TRANSLATOR_DECLARATIONS (Page_turn_engraver); void stop_translation_timestep (); + void start_translation_timestep (); + void finalize (); }; Page_turn_engraver::Page_turn_engraver () @@ -40,10 +104,32 @@ note_end_ = 0; } +Grob* +Page_turn_engraver::breakable_column (Page_turn_event const &brk) +{ + vsize start = lower_bound (breakable_moments_, brk.duration_[LEFT], less ()); + vsize end = upper_bound (breakable_moments_, brk.duration_[RIGHT], less ()); + + if (start == breakable_moments_.size ()) + return NULL; + if (end == breakable_moments_.size () || breakable_moments_[end] > brk.duration_[RIGHT]) + { + if (end == 0) + return NULL; + end--; + } + + for (vsize i = end + 1; i-- > start;) + if (special_barlines_[i]) + return breakable_columns_[i]; + + return breakable_columns_[end]; +} + Real Page_turn_engraver::penalty (Rational rest_len) { - Rational min_turn = robust_scm2moment (get_property ("minPageTurnLength"), Moment (1)).main_part_; + Rational min_turn = robust_scm2moment (get_property ("minimumPageTurnLength"), Moment (1)).main_part_; return (rest_len < min_turn) ? infinity_f : 0; } @@ -62,10 +148,9 @@ { Real pen = penalty ((now_mom () - rest_begin_).main_part_); if (!isinf (pen)) - { - SCM val = scm_cons (rest_begin_.smobbed_copy (), scm_from_double (pen)); - context ()->get_score_context ()->set_property ("allowPageTurn", val); - } + automatic_breaks_.push_back (Page_turn_event (rest_begin_.main_part_, + now_mom ().main_part_, + ly_symbol2scm ("allow"), 0)); } if (rest_begin_ <= repeat_begin_) @@ -73,9 +158,59 @@ note_end_ = now_mom () + Moment (Duration (dur_log, dot_count).get_length ()); } +IMPLEMENT_TRANSLATOR_LISTENER (Page_turn_engraver, break); +void +Page_turn_engraver::listen_break (Stream_event *ev) +{ + string name = ly_scm2string (scm_symbol_to_string (ev->get_property ("class"))); + + if (name == "page-turn-event") + { + SCM permission = ev->get_property ("break-permission"); + Real penalty = robust_scm2double (ev->get_property ("break-penalty"), 0); + Rational now = now_mom ().main_part_; + + forced_breaks_.push_back (Page_turn_event (now, now, permission, penalty)); + } +} + +void +Page_turn_engraver::start_translation_timestep () +{ + /* What we want to do is to build a list of all the + breakable paper columns. In general, paper-columns won't be marked as + such until the Paper_column_engraver has done stop_translation_timestep. + + Therefore, we just grab /all/ paper columns (in the + stop_translation_timestep, since they're not created here yet) + and remove the non-breakable ones at the beginning of the following + timestep. + */ + + if (breakable_columns_.size () && !Paper_column::is_breakable (breakable_columns_.back ())) + { + breakable_columns_.pop_back (); + breakable_moments_.pop_back (); + special_barlines_.pop_back (); + } +} + void Page_turn_engraver::stop_translation_timestep () { + Grob *pc = unsmob_grob (get_property ("currentCommandColumn")); + + if (pc) + { + breakable_columns_.push_back (pc); + breakable_moments_.push_back (now_mom ().main_part_); + + SCM bar_scm = get_property ("whichBar"); + string bar = robust_scm2string (bar_scm, ""); + + special_barlines_.push_back (bar != "" && bar != "|"); + } + /* C&P from Repeat_acknowledge_engraver */ SCM cs = get_property ("repeatCommands"); bool start = false; @@ -92,17 +227,20 @@ if (end && repeat_begin_.main_part_ >= Moment (0)) { + Rational now = now_mom ().main_part_; Real pen = penalty ((now_mom () - rest_begin_).main_part_ + repeat_begin_rest_length_); Moment *m = unsmob_moment (get_property ("minimumRepeatLengthForPageTurn")); if (m && *m > (now_mom () - repeat_begin_)) pen = infinity_f; - if (pen > 0) - { - SCM val = scm_cons (repeat_begin_.smobbed_copy (), scm_from_double (pen)); - context ()->get_score_context ()->set_property ("revokePageTurns", val); - } + + if (pen == infinity_f) + repeat_penalties_.push_back (Page_turn_event (repeat_begin_.main_part_, now, SCM_EOL, -infinity_f)); + else + repeat_penalties_.push_back (Page_turn_event (repeat_begin_.main_part_, now, ly_symbol2scm ("allow"), pen)); + repeat_begin_ = Moment (-1); } + if (start) { repeat_begin_ = now_mom (); @@ -111,15 +249,92 @@ rest_begin_ = note_end_; } -#include "translator.icc" +/* return the most permissive symbol (where force is the most permissive and + forbid is the least +*/ +SCM +Page_turn_engraver::max_permission (SCM perm1, SCM perm2) +{ + if (perm1 == SCM_EOL) + return perm2; + if (perm1 == ly_symbol2scm ("allow") && perm2 == ly_symbol2scm ("force")) + return perm2; + return perm1; +} + +void +Page_turn_engraver::finalize () +{ + vsize rep_index = 0; + vector auto_breaks; + + /* filter the automatic breaks through the repeat penalties */ + for (vsize i = 0; i < automatic_breaks_.size (); i++) + { + Page_turn_event &brk = automatic_breaks_[i]; + + /* find the next applicable repeat penalty */ + for (; + rep_index < repeat_penalties_.size () + && repeat_penalties_[rep_index].duration_[RIGHT] <= brk.duration_[LEFT]; + rep_index++) + ; + + if (rep_index >= repeat_penalties_.size () + || brk.duration_[RIGHT] <= repeat_penalties_[rep_index].duration_[LEFT]) + auto_breaks.push_back (brk); + else + { + vector split = brk.penalize (repeat_penalties_[rep_index]); + + /* it's possible that the last of my newly-split events overlaps the next repeat_penalty, + in which case we need to refilter that event */ + if (rep_index < repeat_penalties_.size () - 1 + && split.size () + && split.back ().duration_[RIGHT] > repeat_penalties_[rep_index+1].duration_[LEFT]) + { + automatic_breaks_[i] = split.back (); + split.pop_back (); + i--; + } + auto_breaks.insert (auto_breaks.end (), split.begin (), split.end ()); + } + } + + /* apply the automatic breaks */ + for (vsize i = 0; i < auto_breaks.size (); i++) + { + Page_turn_event const &brk = auto_breaks[i]; + Grob *pc = breakable_column (auto_breaks[i]); + if (pc) + { + SCM perm = max_permission (pc->get_property ("page-turn-permission"), brk.permission_); + Real pen = min (robust_scm2double (pc->get_property ("page-turn-penalty"), infinity_f), brk.penalty_); + pc->set_property ("page-turn-permission", perm); + pc->set_property ("page-turn-penalty", scm_from_double (pen)); + } + } + + /* apply the manual breaks */ + for (vsize i = 0; i < forced_breaks_.size (); i++) + { + Page_turn_event const &brk = forced_breaks_[i]; + Grob *pc = breakable_column (forced_breaks_[i]); + if (pc) + { + pc->set_property ("page-turn-permission", brk.permission_); + pc->set_property ("page-turn-penalty", scm_from_double (brk.penalty_)); + } + } +} ADD_ACKNOWLEDGER (Page_turn_engraver, note_head); ADD_TRANSLATOR (Page_turn_engraver, /* doc */ "Decide where page turns are allowed to go", /* create */ "", /* accept */ "", - /* read */ "", - /* write */ - "allowPageTurn " - "revokePageTurns " + /* read */ + "minimumPageTurnLength " + "minimumRepeatLengthForPageTurn ", + /* write */ "" ); Index: lily/paper-column-engraver.cc =================================================================== RCS file: /sources/lilypond/lilypond/lily/paper-column-engraver.cc,v retrieving revision 1.22 diff -u -r1.22 paper-column-engraver.cc --- lily/paper-column-engraver.cc 26 Aug 2006 22:18:26 -0000 1.22 +++ lily/paper-column-engraver.cc 17 Sep 2006 06:14:55 -0000 @@ -28,8 +28,6 @@ musical_column_ = 0; breaks_ = 0; system_ = 0; - last_special_barline_column_ = 0; - last_breakable_column_ = 0; first_ = true; } @@ -171,56 +169,6 @@ } } -/* return either - - the last column with a special (ie. not "|" or "") barline - - the last column - after the given moment -*/ -Paper_column* -Paper_column_engraver::find_turnable_column (Moment after_this) -{ - if (last_special_barline_column_) - { - Moment m = *unsmob_moment (last_special_barline_column_->get_property ("when")); - if (m >= after_this) - return last_special_barline_column_; - } - if (last_breakable_column_) - { - Moment m = *unsmob_moment (last_breakable_column_->get_property ("when")); - if (m >= after_this) - return last_breakable_column_; - } - return 0; -} - -void -Paper_column_engraver::revoke_page_turns (Moment after_this, Real new_penalty) -{ - if (!page_turnable_columns_.size ()) - return; - - for (vsize i = page_turnable_columns_.size () - 1; i--;) - { - Paper_column *col = page_turnable_columns_[i]; - Moment mom = *unsmob_moment (col->get_property ("when")); - if (mom >= after_this) - { - if (isinf (new_penalty)) - { - col->del_property ( ly_symbol2scm ("page-turn-permission")); - page_turnable_columns_.erase (page_turnable_columns_.begin () + i); - } - else - { - Real prev_pen = robust_scm2double (col->get_property ("page-turn-penalty"), 0); - if (new_penalty > prev_pen) - col->set_property ("page-turn-penalty", scm_from_double (new_penalty)); - } - } - } -} - void Paper_column_engraver::stop_translation_timestep () { @@ -245,51 +193,12 @@ else if (Paper_column::is_breakable (command_column_)) { breaks_++; - last_breakable_column_ = command_column_; - - SCM which_bar = get_property ("whichBar"); - if (scm_is_string (which_bar)) - { - string bar = ly_scm2string (which_bar); - if (bar != "" && bar != "|") - last_special_barline_column_ = command_column_; - } if (! (breaks_%8)) progress_indication ("[" + to_string (breaks_) + "]"); } - SCM page_br = get_property ("allowPageTurn"); - if (scm_is_pair (page_br) && last_breakable_column_) - { - SCM pen = scm_cdr (page_br); - Moment *m = unsmob_moment (scm_car (page_br)); - if (m) - { - Paper_column *turn = find_turnable_column (*m); - if (turn) - { - turn->set_property ("page-turn-permission", ly_symbol2scm ("allow")); - turn->set_property ("page-turn-penalty", pen); - page_turnable_columns_.push_back (turn); - } - } - } - - /* The page-turn-engraver is allowed to change its mind and revoke previously-allowed - page turns (for example if there is a volta repeat where a turn is inconvenient) */ - SCM revokes = get_property ("revokePageTurns"); - if (scm_is_pair (revokes)) - { - Moment *start = unsmob_moment (scm_car (revokes)); - Real pen = robust_scm2double (scm_cdr (revokes), infinity_f); - if (start) - revoke_page_turns (*start, pen); - } - context ()->get_score_context ()->unset_property (ly_symbol2scm ("forbidBreak")); - context ()->get_score_context ()->unset_property (ly_symbol2scm ("allowPageTurn")); - context ()->get_score_context ()->unset_property (ly_symbol2scm ("revokePageTurns")); first_ = false; break_events_.clear (); @@ -326,13 +235,9 @@ /* accept */ "break-event", /* read */ "forbidBreak " - "allowPageTurn " - "revokePageTurns " , /* write */ "forbidBreak " - "allowPageTurn " - "revokePageTurns " "currentCommandColumn " "currentMusicalColumn " ); Index: lily/program-option.cc =================================================================== RCS file: /sources/lilypond/lilypond/lily/program-option.cc,v retrieving revision 1.28 diff -u -r1.28 program-option.cc --- lily/program-option.cc 7 Sep 2006 13:11:29 -0000 1.28 +++ lily/program-option.cc 17 Sep 2006 06:14:55 -0000 @@ -133,7 +133,7 @@ } string help ("Options supported by ly:set-option\n\n"); - vector_sort (opts, string_compare); + vector_sort (opts, less ()); for (vsize i = 0; i < opts.size (); i++) help += opts[i]; Index: lily/rest-collision.cc =================================================================== RCS file: /sources/lilypond/lilypond/lily/rest-collision.cc,v retrieving revision 1.131 diff -u -r1.131 rest-collision.cc --- lily/rest-collision.cc 16 Sep 2006 21:26:49 -0000 1.131 +++ lily/rest-collision.cc 17 Sep 2006 06:14:55 -0000 @@ -151,7 +151,7 @@ Direction d = LEFT; do - vector_sort (ordered_rests[d], Note_column::shift_compare); + vector_sort (ordered_rests[d], Note_column::shift_less); while (flip (&d) != LEFT) ; Index: lily/semi-tie-column.cc =================================================================== RCS file: /sources/lilypond/lilypond/lily/semi-tie-column.cc,v retrieving revision 1.1 diff -u -r1.1 semi-tie-column.cc --- lily/semi-tie-column.cc 21 Feb 2006 23:53:34 -0000 1.1 +++ lily/semi-tie-column.cc 17 Sep 2006 06:14:55 -0000 @@ -45,7 +45,7 @@ extract_grob_set (me, "ties", lv_ro_ties); vector lv_ties (lv_ro_ties); - vector_sort (lv_ties, &Semi_tie::compare); + vector_sort (lv_ties, Semi_tie::less); Ties_configuration ties_config; Index: lily/semi-tie.cc =================================================================== RCS file: /sources/lilypond/lilypond/lily/semi-tie.cc,v retrieving revision 1.1 diff -u -r1.1 semi-tie.cc --- lily/semi-tie.cc 21 Feb 2006 23:53:34 -0000 1.1 +++ lily/semi-tie.cc 17 Sep 2006 06:14:55 -0000 @@ -70,10 +70,10 @@ return (int) rint (Staff_symbol_referencer::get_position (h)); } -int -Semi_tie::compare (Grob *const &s1, - Grob *const &s2) +bool +Semi_tie::less (Grob *const &s1, + Grob *const &s2) { - return sign (get_position (s1) - get_position (s2)); + return get_position (s1) < get_position (s2); } Index: lily/span-bar.cc =================================================================== RCS file: /sources/lilypond/lilypond/lily/span-bar.cc,v retrieving revision 1.122 diff -u -r1.122 span-bar.cc --- lily/span-bar.cc 11 Feb 2006 11:35:17 -0000 1.122 +++ lily/span-bar.cc 17 Sep 2006 06:14:55 -0000 @@ -72,7 +72,7 @@ if (!model_bar) model_bar = me; - vector_sort (extents, Interval::left_comparison); + vector_sort (extents, Interval::left_less); Stencil span_bar; for (vsize i = 1; i < extents.size (); i++) Index: lily/spanner.cc =================================================================== RCS file: /sources/lilypond/lilypond/lily/spanner.cc,v retrieving revision 1.152 diff -u -r1.152 spanner.cc --- lily/spanner.cc 16 Sep 2006 21:43:22 -0000 1.152 +++ lily/spanner.cc 17 Sep 2006 06:14:55 -0000 @@ -124,7 +124,7 @@ } } } - vector_sort (broken_intos_, Spanner::compare); + vector_sort (broken_intos_, Spanner::less); for (vsize i = broken_intos_.size (); i--;) broken_intos_[i]->break_index_ = i; } @@ -238,7 +238,7 @@ Grob * Spanner::find_broken_piece (System *l) const { - vsize idx = binary_search (broken_intos_, (Spanner *)l, Spanner::less_than); + vsize idx = binary_search (broken_intos_, (Spanner *)l, Spanner::less); if (idx != VPOS) return broken_intos_ [idx]; return 0; @@ -251,7 +251,7 @@ } bool -Spanner::less_than (Spanner *const &a, Spanner *const &b) +Spanner::less (Spanner *const &a, Spanner *const &b) { return a->get_system ()->get_rank () < b->get_system ()->get_rank (); } Index: lily/staff-symbol-referencer.cc =================================================================== RCS file: /sources/lilypond/lilypond/lily/staff-symbol-referencer.cc,v retrieving revision 1.88 diff -u -r1.88 staff-symbol-referencer.cc --- lily/staff-symbol-referencer.cc 9 Jun 2006 02:20:22 -0000 1.88 +++ lily/staff-symbol-referencer.cc 17 Sep 2006 06:14:55 -0000 @@ -156,6 +156,13 @@ - Staff_symbol_referencer::get_position ((Grob *) b)); } +bool +position_less (Grob *const &a, Grob *const &b) +{ + return Staff_symbol_referencer::get_position (a) + < Staff_symbol_referencer::get_position (b); +} + ADD_INTERFACE (Staff_symbol_referencer, "staff-symbol-referencer-interface", "An object whose Y position is meant relative to a staff " "symbol. " Index: lily/stem.cc =================================================================== RCS file: /sources/lilypond/lilypond/lily/stem.cc,v retrieving revision 1.311 diff -u -r1.311 stem.cc --- lily/stem.cc 14 Jun 2006 11:55:58 -0000 1.311 +++ lily/stem.cc 17 Sep 2006 06:14:56 -0000 @@ -180,12 +180,6 @@ return exthead; } -static int -integer_compare (int const &a, int const &b) -{ - return a - b; -} - /* The positions, in ascending order. */ vector Stem::note_head_positions (Grob *me) @@ -201,7 +195,7 @@ ps.push_back (p); } - vector_sort (ps, integer_compare); + vector_sort (ps, less ()); return ps; } @@ -410,7 +404,7 @@ extract_grob_set (me, "note-heads", ro_heads); vector heads (ro_heads); - vector_sort (heads, compare_position); + vector_sort (heads, position_less); Direction dir = get_grob_direction (me); if (dir < 0) Index: lily/system.cc =================================================================== RCS file: /sources/lilypond/lilypond/lily/system.cc,v retrieving revision 1.146 diff -u -r1.146 system.cc --- lily/system.cc 4 Sep 2006 05:31:27 -0000 1.146 +++ lily/system.cc 17 Sep 2006 06:14:56 -0000 @@ -317,7 +317,7 @@ anyway. */ vector all_elts_sorted (all_elements_->array ()); - vector_sort (all_elts_sorted, default_compare); + vector_sort (all_elts_sorted, std::less ()); uniq (all_elts_sorted); this->get_stencil (); for (vsize i = all_elts_sorted.size (); i--;) @@ -357,7 +357,7 @@ entries.push_back (e); } - vector_sort (entries, default_compare); + vector_sort (entries, std::less ()); for (vsize j = 0; j < entries.size (); j++) { Grob *g = entries[j].grob_; Index: lily/tie-column.cc =================================================================== RCS file: /sources/lilypond/lilypond/lily/tie-column.cc,v retrieving revision 1.72 diff -u -r1.72 tie-column.cc --- lily/tie-column.cc 21 Feb 2006 12:48:50 -0000 1.72 +++ lily/tie-column.cc 17 Sep 2006 06:14:57 -0000 @@ -83,7 +83,7 @@ return SCM_BOOL_T; } - vector_sort (ties, &Tie::compare); + vector_sort (ties, Tie::less); Tie_formatting_problem problem; problem.from_ties (ties); Index: lily/tie-formatting-problem.cc =================================================================== RCS file: /sources/lilypond/lilypond/lily/tie-formatting-problem.cc,v retrieving revision 1.36 diff -u -r1.36 tie-formatting-problem.cc --- lily/tie-formatting-problem.cc 18 Jun 2006 12:57:37 -0000 1.36 +++ lily/tie-formatting-problem.cc 17 Sep 2006 06:14:57 -0000 @@ -219,7 +219,7 @@ for (vsize i = 0; i < bounds.size (); i++) ranks.push_back (bounds[i]->get_column ()->get_rank ()); - vector_sort (ranks, default_compare); + vector_sort (ranks, less ()); uniq (ranks); for (vsize i = 0; i < ranks.size (); i++) Index: lily/tie.cc =================================================================== RCS file: /sources/lilypond/lilypond/lily/tie.cc,v retrieving revision 1.185 diff -u -r1.185 tie.cc --- lily/tie.cc 16 May 2006 12:36:54 -0000 1.185 +++ lily/tie.cc 17 Sep 2006 06:14:57 -0000 @@ -28,11 +28,11 @@ #include "warn.hh" -int -Tie::compare (Grob *const &s1, - Grob *const &s2) +bool +Tie::less (Grob *const &s1, + Grob *const &s2) { - return sign (Tie::get_position (s1) - Tie::get_position (s2)); + return Tie::get_position (s1) < Tie::get_position (s2); } void Index: lily/include/lily-guile.hh =================================================================== RCS file: /sources/lilypond/lilypond/lily/include/lily-guile.hh,v retrieving revision 1.176 diff -u -r1.176 lily-guile.hh --- lily/include/lily-guile.hh 4 Sep 2006 05:51:14 -0000 1.176 +++ lily/include/lily-guile.hh 17 Sep 2006 06:14:57 -0000 @@ -64,6 +64,7 @@ Drul_array robust_scm2booldrul (SCM, Drul_array); Interval robust_scm2interval (SCM, Drul_array); Offset robust_scm2offset (SCM, Offset); +string robust_scm2string (SCM, string); SCM ly_quote_scm (SCM s); bool type_check_assignment (SCM val, SCM sym, SCM type_symbol); Index: lily/include/note-column.hh =================================================================== RCS file: /sources/lilypond/lilypond/lily/include/note-column.hh,v retrieving revision 1.52 diff -u -r1.52 note-column.hh --- lily/include/note-column.hh 6 Jan 2006 09:13:24 -0000 1.52 +++ lily/include/note-column.hh 17 Sep 2006 06:14:57 -0000 @@ -19,7 +19,7 @@ class Note_column { public: - static int shift_compare (Grob *const &, Grob *const &); + static bool shift_less (Grob *const &, Grob *const &); static Direction dir (Grob *me); static Grob *accidentals (Grob *me); static Grob *arpeggio (Grob *me); Index: lily/include/paper-column-engraver.hh =================================================================== RCS file: /sources/lilypond/lilypond/lily/include/paper-column-engraver.hh,v retrieving revision 1.11 diff -u -r1.11 paper-column-engraver.hh --- lily/include/paper-column-engraver.hh 8 Aug 2006 10:01:22 -0000 1.11 +++ lily/include/paper-column-engraver.hh 17 Sep 2006 06:14:57 -0000 @@ -44,9 +44,6 @@ bool first_; Moment last_moment_; - Paper_column *last_special_barline_column_; - Paper_column *last_breakable_column_; - vector page_turnable_columns_; public: }; Index: lily/include/semi-tie.hh =================================================================== RCS file: /sources/lilypond/lilypond/lily/include/semi-tie.hh,v retrieving revision 1.1 diff -u -r1.1 semi-tie.hh --- lily/include/semi-tie.hh 21 Feb 2006 23:53:34 -0000 1.1 +++ lily/include/semi-tie.hh 17 Sep 2006 06:14:57 -0000 @@ -20,8 +20,8 @@ DECLARE_SCHEME_CALLBACK (calc_direction, (SCM)); DECLARE_SCHEME_CALLBACK (calc_control_points, (SCM)); - static int compare (Grob *const &s1, - Grob *const &s2); + static bool less (Grob *const &s1, + Grob *const &s2); static int get_position (Grob *); }; Index: lily/include/spanner.hh =================================================================== RCS file: /sources/lilypond/lilypond/lily/include/spanner.hh,v retrieving revision 1.83 diff -u -r1.83 spanner.hh --- lily/include/spanner.hh 7 Sep 2006 11:16:10 -0000 1.83 +++ lily/include/spanner.hh 17 Sep 2006 06:14:58 -0000 @@ -56,7 +56,7 @@ Real spanner_length () const; static int compare (Spanner *const &, Spanner *const &); - static bool less_than (Spanner *const &, Spanner *const &); + static bool less (Spanner *const &, Spanner *const &); virtual Grob *find_broken_piece (System *) const; virtual void derived_mark () const; static bool has_interface (Grob *); Index: lily/include/staff-symbol-referencer.hh =================================================================== RCS file: /sources/lilypond/lilypond/lily/include/staff-symbol-referencer.hh,v retrieving revision 1.41 diff -u -r1.41 staff-symbol-referencer.hh --- lily/include/staff-symbol-referencer.hh 19 Jan 2006 22:39:13 -0000 1.41 +++ lily/include/staff-symbol-referencer.hh 17 Sep 2006 06:14:58 -0000 @@ -40,6 +40,7 @@ static int get_rounded_position (Grob *); }; -int compare_position (Grob *const &, Grob *const &); +int compare_position (Grob *const &, Grob *const &);\ +bool position_less (Grob *const &, Grob *const &); #endif /* STAFF_SYMBOL_REFERENCER_HH */ Index: lily/include/tie.hh =================================================================== RCS file: /sources/lilypond/lilypond/lily/include/tie.hh,v retrieving revision 1.70 diff -u -r1.70 tie.hh --- lily/include/tie.hh 21 Feb 2006 12:48:51 -0000 1.70 +++ lily/include/tie.hh 17 Sep 2006 06:14:58 -0000 @@ -33,8 +33,8 @@ DECLARE_SCHEME_CALLBACK (set_spacing_rods, (SCM)); DECLARE_SCHEME_CALLBACK (calc_direction, (SCM)); DECLARE_SCHEME_CALLBACK (calc_control_points, (SCM)); - static int compare (Grob *const &s1, - Grob *const &s2); + static bool less (Grob *const &s1, + Grob *const &s2); }; Index: scm/define-context-properties.scm =================================================================== RCS file: /sources/lilypond/lilypond/scm/define-context-properties.scm,v retrieving revision 1.84 diff -u -r1.84 define-context-properties.scm --- scm/define-context-properties.scm 23 Aug 2006 21:19:36 -0000 1.84 +++ scm/define-context-properties.scm 17 Sep 2006 06:14:58 -0000 @@ -39,8 +39,6 @@ "If true, then the accidentals are aligned in bass figure context.") (allowBeamBreak ,boolean? "If true allow line breaks for beams over bar lines.") - (allowPageTurn ,pair? "In the form (moment-start . penalty). Allow a page turn -at the most recent breakpoint if it was after moment-start.") (associatedVoice ,string? "Name of the @code{Voice} that has the melody for this @code{Lyrics} line.") (autoBeamSettings ,list? "Specifies @@ -313,6 +311,9 @@ (midiMaximumVolume ,number? "Analogous to @code{midiMinimumVolume}.") (minimumFret ,number? "The tablature auto string-selecting mechanism selects the highest string with a fret at least @code{minimumFret}") + (minimumPageTurnLength ,ly:moment? "Minimum length of a rest for a page turn to be allowed") + (minimumRepeatLengthForPageTurn ,ly:moment? "Minimum length of a repeated section for a page +turn to be allowed within that section") (minimumVerticalExtent ,number-pair? "minimum vertical extent, same format as @var{verticalExtent}") (output ,ly:music-output? "The output produced by a score-level translator during music interpretation") @@ -346,7 +347,6 @@ (restNumberThreshold ,number? "If a multimeasure rest has more measures than this, a number is printed. ") - (revokePageTurns ,pair? "Signals to the paper-column-engraver to revoke (or increase the penalties for) all the page turns within a time interval. Used to disable page turns that occur within an unturnable volta repeat.") (shapeNoteStyles ,vector? "Vector of symbols, listing style for each note head relative to the tonic (qv.) of the scale.") (shortInstrumentName ,markup? "See @code{instrument}") Index: scm/define-music-types.scm =================================================================== RCS file: /sources/lilypond/lilypond/scm/define-music-types.scm,v retrieving revision 1.93 diff -u -r1.93 define-music-types.scm --- scm/define-music-types.scm 24 Aug 2006 14:45:10 -0000 1.93 +++ scm/define-music-types.scm 17 Sep 2006 06:15:04 -0000 @@ -104,17 +104,10 @@ c8-[ c c-] c8") (types . (general-music event beam-event span-event)) )) - (BendAfterEvent . ((description . "A drop/fall/doit jazz articulation") (types . (general-music bend-after-event event)))) - (BreakEvent - . ( - (description . "Create a line break, Syntax: \\break or page break, Syntax: \\pagebreak.") - - (types . (general-music break-event event)) - )) (BreathingEvent . ( (description . "Creates a `breath mark' or `comma'. @@ -343,12 +336,12 @@ (PageBreakEvent . ( (description . "Allow, forbid or force a page break.") - (types . (general-music break-event event)) + (types . (general-music break-event page-break-event event)) )) (PageTurnEvent . ( (description . "Allow, forbid or force a page turn.") - (types . (general-music break-event event)) + (types . (general-music break-event page-turn-event event)) )) (PartCombineMusic . (