This patch has 2 purposes, but they intersect in paper-column-engraver.cc so I
thought it was easier to send it as one patch.
First of all, instead of penalty, breakable and page-penalty, we now have:
break-penalty, break-permission
page-break-penalty, page-break-permission
page-turn-penalty, page-turn-permission
where XXX-permission can be 'allow, 'force or 'forbid.
\break, \pageBreak etc. use the -permission properties and the line breakers
respect both permissions and penalties. page-turn-XXX is not yet used
anywhere.
The second change is something we discussed a while ago -- in order to forbid
line breaks, engravers will set forbidBreak = #t in the Score context instead
of doing it with function calls through Score_engraver.
2006-05-05 Joe Neeman <[EMAIL PROTECTED]>
* scm/define-context-properties.scm:
* scm/define-grob-properties.scm:
* scm/define-grobs.scm:
* scm/define-music-properties.scm:
* ly/declarations-init.ly:
* lily/include/constrained-breaking.hh:
* lily/system.cc:
* lily/spaceable-grob.cc:
* lily/simple-spacer.cc:
* lily/paper-score.cc:
* lily/paper-column.cc:
* lily/paper-column-engraver.cc:
* lily/item.cc:
* lily/gourlay-breaking.cc:
* lily/constrained-breaking.cc:
* python/convertrules.py:
Change "penalty", "page-penalty" and "breakable" to "break-penalty",
"page-break-penalty" and "break-permission".
Add "page-break-permission", "page-turn-permission" and
"page-turn-penalty".
* lily/bar-engraver.cc:
* lily/beam-engraver.cc:
* lily/forbid-break-engraver.cc:
* lily/ligature-engraver.cc:
* lily/paper-column-engraver.cc:
* lily/percent-repeat-engraver.cc:
* lily/score-engraver.cc:
* lily/score-engraver.hh:
* lily/paper-column-engraver.hh:
Inter-engraver communication regarding line breaks is done through
context
properties (Score.forbidBreak) instead of function calls.
Index: ChangeLog
===================================================================
RCS file: /sources/lilypond/lilypond/ChangeLog,v
retrieving revision 1.4921
diff -u -r1.4921 ChangeLog
--- ChangeLog 4 May 2006 11:56:19 -0000 1.4921
+++ ChangeLog 5 May 2006 06:25:29 -0000
@@ -1,3 +1,37 @@
+2006-05-05 Joe Neeman <[EMAIL PROTECTED]>
+
+ * scm/define-context-properties.scm:
+ * scm/define-grob-properties.scm:
+ * scm/define-grobs.scm:
+ * scm/define-music-properties.scm:
+ * ly/declarations-init.ly:
+ * lily/include/constrained-breaking.hh:
+ * lily/system.cc:
+ * lily/spaceable-grob.cc:
+ * lily/simple-spacer.cc:
+ * lily/paper-score.cc:
+ * lily/paper-column.cc:
+ * lily/paper-column-engraver.cc:
+ * lily/item.cc:
+ * lily/gourlay-breaking.cc:
+ * lily/constrained-breaking.cc:
+ * python/convertrules.py:
+ Change "penalty", "page-penalty" and "breakable" to "break-penalty",
+ "page-break-penalty" and "break-permission".
+ Add "page-break-permission", "page-turn-permission" and "page-turn-penalty".
+
+ * lily/bar-engraver.cc:
+ * lily/beam-engraver.cc:
+ * lily/forbid-break-engraver.cc:
+ * lily/ligature-engraver.cc:
+ * lily/paper-column-engraver.cc:
+ * lily/percent-repeat-engraver.cc:
+ * lily/score-engraver.cc:
+ * lily/score-engraver.hh:
+ * lily/paper-column-engraver.hh:
+ Inter-engraver communication regarding line breaks is done through context
+ properties (Score.forbidBreak) instead of function calls.
+
2006-05-04 Han-Wen Nienhuys <[EMAIL PROTECTED]>
* mf/GNUmakefile (NCSB_OTFS): remove old ncsb detection further.
Index: scm/define-context-properties.scm
===================================================================
RCS file: /sources/lilypond/lilypond/scm/define-context-properties.scm,v
retrieving revision 1.74
diff -u -r1.74 define-context-properties.scm
--- scm/define-context-properties.scm 12 Apr 2006 23:26:55 -0000 1.74
+++ scm/define-context-properties.scm 5 May 2006 06:25:29 -0000
@@ -32,6 +32,8 @@
"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
@@ -220,6 +222,8 @@
(fontSize ,number?
"The relative size of all grobs in a context. ")
+ (forbidBreak ,boolean? "If set to ##t, prevent a line break at this point.")
+
(fingeringOrientations ,list?
"List of symbols, containing
@samp{left}, @samp{right}, @samp{up} and/or @samp{down}. This list
Index: scm/define-grob-properties.scm
===================================================================
RCS file: /sources/lilypond/lilypond/scm/define-grob-properties.scm,v
retrieving revision 1.160
diff -u -r1.160 define-grob-properties.scm
--- scm/define-grob-properties.scm 1 May 2006 19:17:57 -0000 1.160
+++ scm/define-grob-properties.scm 5 May 2006 06:25:30 -0000
@@ -111,8 +111,6 @@
(break-visibility ,vector? "A vector of 3 booleans, #(end-of-line unbroken begin-of-line).
#t means visible, #f means killed.")
- (breakable ,boolean? "Can this object appear at a line break,
-like clefs and bar lines?")
(c0-position ,integer? "An integer indicating the position of
middle C.")
(cautionary-style ,symbol? "How to print cautionary
@@ -323,15 +321,24 @@
tightly as possible.")
(padding ,ly:dimension? "Add this much extra space between
objects that are next to each other.")
- (page-penalty ,number? "Penalty for page break at
-this column. 10000 or more means forbid linebreak, -10000 or less
-means force page break. Other values influence page breaking decisions
-as a real penalty.")
- (penalty ,number? "Penalty for line break at
-this column. 10000 or more means forbid line break, -10000 or less
-means force line break. Other values influence line breaking decisions
-as a real penalty.")
-
+ (page-break-permission ,symbol? "Instructs the page breaker on whether to
+put a page break at this column. Can be 'forbid, 'force, or 'allow.")
+ (page-turn-permission ,symbol? "Instructs the page breaker on whether to
+put a page turn at this column. Can be 'forbid, 'force, or 'allow.")
+ (break-permission ,symbol? "Instructs the line breaker on whether to
+put a line break at this column. Can be 'forbid, 'force, or 'allow.")
+ (page-break-penalty ,number? "Penalty for page break at
+this column. This affects the choices of the page breaker; it will avoid a page
+break at a column with a positive penalty and prefer a page break at a column
+with a negative penalty.")
+ (page-turn-penalty ,number? "Penalty for a page turn at this column.
+This affects the choices of the page breaker; it will avoid a page
+turn at a column with a positive penalty and prefer a page turn at a column
+with a negative penalty.")
+ (break-penalty ,number? "Penalty for a line break at this column.
+This affects the choices of the line breaker; it will avoid a line
+break at a column with a positive penalty and prefer a line break at a column
+with a negative penalty.")
(positions ,pair?
"Pair of staff coordinates @code{(@var{left}
. @var{right})}, where both @var{left} and @var{right} are in the
Index: scm/define-grobs.scm
===================================================================
RCS file: /sources/lilypond/lilypond/scm/define-grobs.scm,v
retrieving revision 1.330
diff -u -r1.330 define-grobs.scm
--- scm/define-grobs.scm 17 Apr 2006 00:30:19 -0000 1.330
+++ scm/define-grobs.scm 5 May 2006 06:25:30 -0000
@@ -74,7 +74,7 @@
(staff-bar . (extra-space . 0.0))
(time-signature . (extra-space . 0.0))
(first-note . (fixed-space . 0.0))))
- (breakable . #t)
+ (break-permission . allow)
(break-align-symbol . ambitus)
(break-visibility . ,begin-of-line-visible)
(meta . ((class . Item)
@@ -144,7 +144,7 @@
(glyph . "|")
(layer . 0)
(break-visibility . ,all-visible)
- (breakable . #t)
+ (break-permission . allow)
(stencil . ,ly:bar-line::print)
(glyph-name . ,bar-line::calc-glyph-name)
@@ -177,7 +177,7 @@
(BarNumber
. (
(stencil . ,ly:text-interface::print)
- (breakable . #t)
+ (break-permission . allow)
(break-visibility . ,begin-of-line-visible)
(padding . 1.0)
(direction . ,UP)
@@ -299,7 +299,7 @@
(BreakAlignment
. (
- (breakable . #t)
+ (break-permission . allow)
(stacking-dir . 1)
(positioning-done . ,ly:break-align-interface::calc-positioning-done)
(X-extent . ,ly:axis-group-interface::width)
@@ -354,7 +354,7 @@
(BreathingSign
. (
(break-align-symbol . breathing-sign)
- (breakable . #t)
+ (break-permission . allow)
(space-alist . (
(ambitus . (extra-space . 2.0))
(custos . (minimum-space . 1.0))
@@ -378,7 +378,7 @@
. (
(stencil . ,ly:clef::print)
(glyph-name . ,ly:clef::calc-glyph-name)
- (breakable . #t)
+ (break-permission . allow)
(font-family . music)
(break-align-symbol . clef)
(break-visibility . ,begin-of-line-visible)
@@ -450,7 +450,7 @@
(Custos
. (
(break-align-symbol . custos)
- (breakable . #t)
+ (break-permission . allow)
(stencil . ,ly:custos::print)
(break-visibility . ,end-of-line-visible)
(style . vaticana)
@@ -489,7 +489,7 @@
(DoublePercentRepeat
. (
(stencil . ,ly:percent-repeat-item-interface::double-percent)
- (breakable . #t)
+ (break-permission . allow)
(slope . 1.0)
(font-encoding . fetaMusic)
(width . 2.0)
@@ -616,7 +616,7 @@
(style . line)
(gap . 0.5)
(zigzag-width . 0.75)
- (breakable . #t)
+ (break-permission . allow)
(X-extent . #f)
(Y-extent . #f)
(stencil . ,ly:line-spanner::print)
@@ -705,7 +705,7 @@
(Y-offset . ,ly:staff-symbol-referencer::callback)
(break-align-symbol . key-cancellation)
(break-visibility . ,begin-of-line-invisible)
- (breakable . #t)
+ (break-permission . allow)
(meta . ((class . Item)
(interfaces . (key-signature-interface
font-interface
@@ -721,7 +721,7 @@
(Y-offset . ,ly:staff-symbol-referencer::callback)
(break-align-symbol . key-signature)
(break-visibility . ,begin-of-line-visible)
- (breakable . #t)
+ (break-permission . allow)
(meta . ((class . Item)
(interfaces . (key-signature-interface
font-interface
@@ -768,7 +768,7 @@
. (
(break-align-symbol . left-edge)
(X-extent . (0 . 0))
- (breakable . #t)
+ (break-permission . allow)
(break-visibility . ,center-invisible)
(space-alist . (
(custos . (extra-space . 0.0))
@@ -1101,7 +1101,7 @@
(X-extent . ,ly:axis-group-interface::width)
;; (stencil . ,ly:paper-column::print)
- (breakable . #t)
+ (break-permission . allow)
;; debugging stuff: print column number.
;; (font-size . -6) (font-name . "sans") (Y-extent . #f)
@@ -1171,7 +1171,7 @@
(Y-offset . ,ly:side-position-interface::y-aligned-side)
(self-alignment-X . 0)
(direction . ,UP)
- (breakable . #t)
+ (break-permission . allow)
(font-size . 2)
(baseline-skip . 2)
(break-visibility . ,end-of-line-invisible)
@@ -1341,7 +1341,7 @@
(break-align-symbol . staff-bar)
(Y-extent . ())
(layer . 0)
- (breakable . #t)
+ (break-permission . allow)
(stencil . ,ly:span-bar::print)
(bar-size . ,ly:span-bar::calc-bar-size)
(X-extent . ,ly:span-bar::width)
@@ -1379,7 +1379,7 @@
(StaffSpacing
. (
- (breakable . #t)
+ (break-permission . allow)
(stem-spacing-correction . 0.4)
(meta . ((class . Item)
(interfaces . (spacing-interface
@@ -1678,7 +1678,7 @@
(first-note . (fixed-space . 2.0))
(right-edge . (extra-space . 0.5))
(staff-bar . (minimum-space . 2.0))))
- (breakable . #t)
+ (break-permission . allow)
(style . C)
(meta . ((class . Item)
(interfaces . (time-signature-interface
@@ -1860,7 +1860,7 @@
. (
(style . line)
(gap . 0.5)
- (breakable . #t)
+ (break-permission . allow)
(X-extent . #f)
(Y-extent . #f)
(stencil . ,ly:line-spanner::print)
Index: scm/define-music-properties.scm
===================================================================
RCS file: /sources/lilypond/lilypond/scm/define-music-properties.scm,v
retrieving revision 1.50
diff -u -r1.50 define-music-properties.scm
--- scm/define-music-properties.scm 12 Feb 2006 16:40:03 -0000 1.50
+++ scm/define-music-properties.scm 5 May 2006 06:25:30 -0000
@@ -32,6 +32,8 @@
(augmented ,boolean? "This figure is for an augmented figured bass (with +) sign.")
(associated-context ,string? "Name of the Voice context associated with this \\newaddlyrics section")
(bass ,boolean? "Set if this note is a bass note in a chord")
+ (break-penalty ,number? "Penalty for line break hint.")
+ (break-permission ,symbol? "Whether to allow, forbid or force a line break.")
(cautionary ,boolean? "If set, this alteration needs cautionary accidental")
(change-to-id ,string? "name of the context to change to ")
(change-to-type ,symbol? "type of the context to change to.")
@@ -69,8 +71,10 @@
For chord inversions, this is negative.")
(origin ,ly:input-location? "where was this piece of music defined?")
(parenthesize ,boolean? "Enclose resulting objects in parentheses?")
- (page-penalty ,number? "Penalty for page break hint.")
- (penalty ,number? "Penalty for line break hint.")
+ (page-break-penalty ,number? "Penalty for page break hint.")
+ (page-break-permission ,symbol? "Whether to allow, forbid or force a page break.")
+ (page-turn-penalty ,number? "Penalty for page turn hint.")
+ (page-turn-permission ,symbol? "Whether to allow, forbid or force a page turn.")
(pitch ,ly:pitch? "the pitch of this note")
(pitch-alist ,list? "list of pitches jointly forming the scale of a key signature")
(pop-first ,boolean? "Do a revert before we try to do a override on some grob property.")
Index: scm/music-functions.scm
===================================================================
RCS file: /sources/lilypond/lilypond/scm/music-functions.scm,v
retrieving revision 1.167
diff -u -r1.167 music-functions.scm
--- scm/music-functions.scm 2 Apr 2006 23:36:51 -0000 1.167
+++ scm/music-functions.scm 5 May 2006 06:25:31 -0000
@@ -472,10 +472,11 @@
(define-public (set-time-signature num den . rest)
(ly:export (apply make-time-signature-set `(,num ,den . ,rest))))
-(define-safe-public (make-penalty-music pen page-pen)
+(define-safe-public (make-penalty-music pen page-pen page-turn-pen)
(make-music 'BreakEvent
- 'penalty pen
- 'page-penalty page-pen))
+ 'break-penalty pen
+ 'page-break-penalty page-pen
+ 'page-turn-penalty page-turn-pen))
(define-safe-public (make-articulation name)
(make-music 'ArticulationEvent
Index: ly/declarations-init.ly
===================================================================
RCS file: /sources/lilypond/lilypond/ly/declarations-init.ly,v
retrieving revision 1.99
diff -u -r1.99 declarations-init.ly
--- ly/declarations-init.ly 6 Apr 2006 00:23:02 -0000 1.99
+++ ly/declarations-init.ly 5 May 2006 06:25:31 -0000
@@ -35,10 +35,12 @@
%% try \once \set Score.allowBeamBreak = ##t
%% rather name \newline, \pageBreak ?
-break = #(make-event-chord (list (make-penalty-music -10001 0)))
-noBreak = #(make-event-chord (list (make-penalty-music 10001 0)))
-pageBreak = #(make-event-chord (list (make-penalty-music -10001 -10001)))
-noPageBreak = #(make-event-chord (list (make-penalty-music 0 10001)))
+break = #(make-event-chord (list (make-music 'BreakEvent 'break-permission 'force)))
+noBreak = #(make-event-chord (list (make-music 'BreakEvent 'break-permission 'forbid)))
+pageBreak = #(make-event-chord (list (make-music 'BreakEvent
+ 'break-permission 'force
+ 'page-break-permission 'force)))
+noPageBreak = #(make-event-chord (list (make-music 'BreakEvent 'page-break-permission 'forbid)))
stopStaff = #(make-event-chord (list (make-span-event 'StaffSpanEvent STOP)))
startStaff = #(make-event-chord (list (make-span-event 'StaffSpanEvent START)))
Index: lily/include/score-engraver.hh
===================================================================
RCS file: /sources/lilypond/lilypond/lily/include/score-engraver.hh,v
retrieving revision 1.41
diff -u -r1.41 score-engraver.hh
--- lily/include/score-engraver.hh 11 Feb 2006 11:35:16 -0000 1.41
+++ lily/include/score-engraver.hh 5 May 2006 06:25:31 -0000
@@ -42,7 +42,6 @@
public:
Score_engraver ();
- void forbid_breaks ();
virtual SCM get_output ();
};
Index: lily/include/paper-column-engraver.hh
===================================================================
RCS file: /sources/lilypond/lilypond/lily/include/paper-column-engraver.hh,v
retrieving revision 1.8
diff -u -r1.8 paper-column-engraver.hh
--- lily/include/paper-column-engraver.hh 11 Feb 2006 11:35:16 -0000 1.8
+++ lily/include/paper-column-engraver.hh 5 May 2006 06:25:31 -0000
@@ -37,9 +37,10 @@
vector<Item*> items_;
bool first_;
Moment last_moment_;
+
+ Moment last_breakable_moment_;
+ Paper_column *last_breakable_column_;
public:
- // ug.h
- void forbid_breaks ();
};
#endif /* PAPER_COLUMN_ENGRAVER_HH */
Index: lily/include/constrained-breaking.hh
===================================================================
RCS file: /sources/lilypond/lilypond/lily/include/constrained-breaking.hh,v
retrieving revision 1.6
diff -u -r1.6 constrained-breaking.hh
--- lily/include/constrained-breaking.hh 4 May 2006 11:15:12 -0000 1.6
+++ lily/include/constrained-breaking.hh 5 May 2006 06:25:31 -0000
@@ -11,12 +11,7 @@
#define CONSTRAINED_BREAKING_HH
#include "break-algorithm.hh"
-
-enum Fordfor {
- FORBID = -1,
- DEFAULT = 0,
- FORCE = 1
-};
+#include "lily-guile.hh"
struct Line_details {
Real force_;
@@ -25,9 +20,9 @@
Real space_; /* spring length (stretches over extent_ but not over padding_) */
Real inverse_hooke_;
- Fordfor line_break_;
- Fordfor page_break_;
- Fordfor page_turn_;
+ SCM break_permission_;
+ SCM page_permission_;
+ SCM turn_permission_;
Real break_penalty_;
Real page_penalty_;
Real turn_penalty_;
@@ -39,9 +34,9 @@
padding_ = 0;
space_ = 0;
inverse_hooke_ = 1;
- line_break_ = DEFAULT;
- page_break_ = DEFAULT;
- page_turn_ = DEFAULT;
+ break_permission_ = ly_symbol2scm ("allow");
+ page_permission_ = ly_symbol2scm ("allow");
+ turn_permission_ = ly_symbol2scm ("allow");
break_penalty_ = 0;
page_penalty_ = 0;
turn_penalty_ = 0;
Index: lily/system.cc
===================================================================
RCS file: /sources/lilypond/lilypond/lily/system.cc,v
retrieving revision 1.140
diff -u -r1.140 system.cc
--- lily/system.cc 4 May 2006 09:49:37 -0000 1.140
+++ lily/system.cc 5 May 2006 06:25:31 -0000
@@ -375,8 +375,15 @@
SCM prop_init = left_bound->get_property ("line-break-system-details");
Prob *pl = make_paper_system (prop_init);
paper_system_set_stencil (pl, sys_stencil);
- pl->set_property ("penalty",
- left_bound->get_property ("page-penalty"));
+
+ /* backwards-compatibility hack for the old page-breaker */
+ SCM turn_perm = left_bound->get_property ("page-break-permission");
+ if (turn_perm == ly_symbol2scm ("forbid"))
+ pl->set_property ("penalty", scm_from_double (10001.0));
+ else if (turn_perm == ly_symbol2scm ("force"))
+ pl->set_property ("penalty", scm_from_double (-10001.0));
+ else
+ pl->set_property ("penalty", scm_from_double (0.0));
if (!scm_is_pair (pl->get_property ("refpoint-Y-extent")))
{
Index: lily/spaceable-grob.cc
===================================================================
RCS file: /sources/lilypond/lilypond/lily/spaceable-grob.cc,v
retrieving revision 1.51
diff -u -r1.51 spaceable-grob.cc
--- lily/spaceable-grob.cc 6 Jan 2006 09:13:25 -0000 1.51
+++ lily/spaceable-grob.cc 5 May 2006 06:25:31 -0000
@@ -122,6 +122,14 @@
ADD_INTERFACE (Spaceable_grob, "spaceable-grob-interface",
"A layout object that takes part in the spacing problem. ",
- "measure-length spacing-wishes penalty minimum-distances ideal-distances "
- "keep-inside-line left-neighbors right-neighbors");
+ /* properties */
+ "measure-length "
+ "spacing-wishes "
+ "break-penalty "
+ "break-permission "
+ "minimum-distances "
+ "ideal-distances "
+ "keep-inside-line "
+ "left-neighbors "
+ "right-neighbors");
Index: lily/simple-spacer.cc
===================================================================
RCS file: /sources/lilypond/lilypond/lily/simple-spacer.cc,v
retrieving revision 1.97
diff -u -r1.97 simple-spacer.cc
--- lily/simple-spacer.cc 4 May 2006 09:49:37 -0000 1.97
+++ lily/simple-spacer.cc 5 May 2006 06:25:31 -0000
@@ -519,12 +519,12 @@
int sz = ret.cols_.size ();
for (int i = sz; i--;)
{
- SCM p = ret.cols_[i]->get_property ("penalty");
- if (scm_is_number (p))
+ SCM p = ret.cols_[i]->get_property ("break-permission");
+ if (scm_is_symbol (p))
{
- if (scm_to_double (p) < -9999)
+ if (p == ly_symbol2scm ("force"))
ret.satisfies_constraints_ = ret.satisfies_constraints_ && (i == 0 || i == sz -1);
- if (scm_to_double (p) > 9999)
+ if (p == ly_symbol2scm ("forbid"))
ret.satisfies_constraints_ = ret.satisfies_constraints_ && ! (i == 0 || i == sz -1);
}
}
Index: lily/separating-line-group-engraver.cc
===================================================================
RCS file: /sources/lilypond/lilypond/lily/separating-line-group-engraver.cc,v
retrieving revision 1.95
diff -u -r1.95 separating-line-group-engraver.cc
--- lily/separating-line-group-engraver.cc 11 Feb 2006 11:35:17 -0000 1.95
+++ lily/separating-line-group-engraver.cc 5 May 2006 06:25:34 -0000
@@ -133,7 +133,7 @@
if (ib)
{
- p_ref_->set_property ("breakable", SCM_BOOL_T);
+ p_ref_->set_property ("break-permission", ly_symbol2scm ("allow"));
context ()->set_property ("breakableSeparationItem", p_ref_->self_scm ());
}
Index: lily/score-engraver.cc
===================================================================
RCS file: /sources/lilypond/lilypond/lily/score-engraver.cc,v
retrieving revision 1.163
diff -u -r1.163 score-engraver.cc
--- lily/score-engraver.cc 21 Mar 2006 12:21:43 -0000 1.163
+++ lily/score-engraver.cc 5 May 2006 06:25:34 -0000
@@ -136,20 +136,6 @@
return o->self_scm ();
}
-/*
- UGH UGH
-*/
-void
-Score_engraver::forbid_breaks ()
-{
- for (SCM s = simple_trans_list_; scm_is_pair (s); s = scm_cdr (s))
- {
- Translator *tr = unsmob_translator (scm_car (s));
- if (Paper_column_engraver *pce = dynamic_cast<Paper_column_engraver *> (tr))
- pce->forbid_breaks ();
- }
-}
-
bool
Score_engraver::try_music (Music *m)
{
@@ -163,9 +149,9 @@
/* doc */ "Top level engraver. Takes care of generating columns and the complete system (ie. System) "
"\n\n "
"This engraver decides whether a column is breakable. The default is "
- "that a column is always breakable. However, when every Bar_engraver "
- "that does not have a barline at a certain point will call "
- "Score_engraver::forbid_breaks to stop linebreaks. In practice, this "
+ "that a column is always breakable. However, every Bar_engraver "
+ "that does not have a barline at a certain point will set "
+ "forbidBreaks to stop linebreaks. In practice, this "
"means that you can make a breakpoint by creating a barline (assuming "
"that there are no beams or notes that prevent a breakpoint.) ",
/* create */
Index: lily/percent-repeat-engraver.cc
===================================================================
RCS file: /sources/lilypond/lilypond/lily/percent-repeat-engraver.cc,v
retrieving revision 1.54
diff -u -r1.54 percent-repeat-engraver.cc
--- lily/percent-repeat-engraver.cc 10 Feb 2006 01:22:12 -0000 1.54
+++ lily/percent-repeat-engraver.cc 5 May 2006 06:25:34 -0000
@@ -16,6 +16,7 @@
#include "misc.hh"
#include "percent-repeat-iterator.hh"
#include "repeated-music.hh"
+#include "score-context.hh"
#include "side-position-interface.hh"
#include "spanner.hh"
#include "warn.hh"
@@ -193,7 +194,7 @@
Ugh. Why can't this be regular communication between
contexts?
*/
- get_score_engraver ()->forbid_breaks ();
+ context ()->get_score_context ()->set_property ("forbidBreak", SCM_BOOL_T);
}
next_moment_ = next_moment_ + body_length_;
next_moment_.grace_part_ = Rational (0);
@@ -276,4 +277,5 @@
"currentCommandColumn "
"countPercentRepeats",
- /* write */ "");
+ /* write */
+ "forbidBreak");
Index: lily/paper-score.cc
===================================================================
RCS file: /sources/lilypond/lilypond/lily/paper-score.cc,v
retrieving revision 1.101
diff -u -r1.101 paper-score.cc
--- lily/paper-score.cc 4 May 2006 09:49:37 -0000 1.101
+++ lily/paper-score.cc 5 May 2006 06:25:34 -0000
@@ -119,8 +119,8 @@
doubly, also done in Score_engraver */
vector<Grob*> pc (system_->columns ());
- pc[0]->set_property ("breakable", SCM_BOOL_T);
- pc.back ()->set_property ("breakable", SCM_BOOL_T);
+ pc[0]->set_property ("break-permission", ly_symbol2scm ("allow"));
+ pc.back ()->set_property ("break-permission", ly_symbol2scm ("allow"));
system_->pre_processing ();
}
Index: lily/paper-column.cc
===================================================================
RCS file: /sources/lilypond/lilypond/lily/paper-column.cc,v
retrieving revision 1.93
diff -u -r1.93 paper-column.cc
--- lily/paper-column.cc 11 Feb 2006 11:35:17 -0000 1.93
+++ lily/paper-column.cc 5 May 2006 06:25:34 -0000
@@ -193,7 +193,10 @@
"between-cols "
"bounded-by-me "
"line-break-system-details "
- "page-penalty "
+ "page-break-penalty "
+ "page-break-permission "
+ "page-turn-penalty "
+ "page-turn-permission "
"shortest-playing-duration "
"shortest-starter-duration "
"used "
Index: lily/paper-column-engraver.cc
===================================================================
RCS file: /sources/lilypond/lilypond/lily/paper-column-engraver.cc,v
retrieving revision 1.13
diff -u -r1.13 paper-column-engraver.cc
--- lily/paper-column-engraver.cc 7 Mar 2006 16:08:39 -0000 1.13
+++ lily/paper-column-engraver.cc 5 May 2006 06:25:34 -0000
@@ -14,6 +14,7 @@
#include "note-spacing.hh"
#include "pointer-group-interface.hh"
#include "context.hh"
+#include "score-context.hh"
#include "axis-group-interface.hh"
#include "warn.hh"
@@ -28,6 +29,8 @@
break_event_ = 0;
system_ = 0;
first_ = true;
+ last_breakable_column_ = 0;
+ last_breakable_moment_.set_infinite (1);
}
void
@@ -38,7 +41,7 @@
if (command_column_)
{
- command_column_->set_property ("breakable", SCM_BOOL_T);
+ command_column_->set_property ("break-permission", ly_symbol2scm ("allow"));
system_->set_bound (RIGHT, command_column_);
}
}
@@ -66,7 +69,7 @@
make_columns ();
system_->set_bound (LEFT, command_column_);
- command_column_->set_property ("breakable", SCM_BOOL_T);
+ command_column_->set_property ("break-permission", ly_symbol2scm ("allow"));
}
void
@@ -106,13 +109,6 @@
system_->add_column (musical_column_);
}
-void
-Paper_column_engraver::forbid_breaks ()
-{
- if (command_column_ && !first_)
- command_column_->set_property ("breakable", SCM_EOL);
-}
-
bool
Paper_column_engraver::try_music (Music *m)
{
@@ -121,31 +117,32 @@
return true;
}
+static char* penalty_names[] = {"break-penalty", "page-break-penalty", "page-turn-penalty"};
+static char* permission_names[] = {"break-permission", "page-break-permission", "page-turn-permission"};
+
void
Paper_column_engraver::process_music ()
{
if (break_event_)
{
- SCM pen = command_column_->get_property ("penalty");
- Real total_penalty = scm_is_number (pen) ? scm_to_double (pen) : 0.0;
-
- SCM mpen = break_event_->get_property ("penalty");
- if (scm_is_number (mpen))
- total_penalty += scm_to_double (mpen);
-
- command_column_->set_property ("penalty", scm_from_double (total_penalty));
-
- /* ugh. arbitrary, hardcoded */
- if (total_penalty > 10000.0)
- forbid_breaks ();
-
- SCM page_pen = command_column_->get_property ("page-penalty");
- Real total_pp = scm_is_number (page_pen) ? scm_to_double (page_pen) : 0.0;
- SCM mpage_pen = break_event_->get_property ("page-penalty");
- if (scm_is_number (mpage_pen))
- total_pp += scm_to_double (mpage_pen);
+ for (vsize i = 0; i < sizeof (penalty_names) / sizeof (char*); i++)
+ {
+ const char *pen_str = penalty_names[i];
+ const char *perm_str = permission_names[i];
- command_column_->set_property ("page-penalty", scm_from_double (total_pp));
+ SCM cur_pen = command_column_->get_property (pen_str);
+ SCM pen = break_event_->get_property (pen_str);
+ SCM perm = break_event_->get_property (perm_str);
+
+ if (scm_is_number (pen))
+ {
+ Real new_pen = robust_scm2double (cur_pen, 0.0) + scm_to_double (pen);
+ command_column_->set_property (pen_str, scm_from_double (new_pen));
+ command_column_->set_property (perm_str, ly_symbol2scm ("allow"));
+ }
+ if (scm_is_symbol (perm))
+ command_column_->set_property (perm_str, perm);
+ }
}
bool start_of_measure = (last_moment_.main_part_ != now_mom ().main_part_
@@ -175,19 +172,38 @@
if (!elem->get_parent (X_AXIS)
|| !unsmob_grob (elem->get_object ("axis-group-parent-X")))
{
- bool br = to_boolean (elem->get_property ("breakable"));
+ bool br = Item::is_breakable (elem);
Axis_group_interface::add_element (br ? command_column_ : musical_column_, elem);
}
}
items_.clear ();
- if (to_boolean (command_column_->get_property ("breakable")))
+ if (to_boolean (get_property ("forbidBreak")))
+ command_column_->set_property ("break-permission", ly_symbol2scm ("forbid"));
+ else if (Item::is_breakable (command_column_))
{
breaks_++;
+ last_breakable_column_ = command_column_;
+ last_breakable_moment_ = now_mom ();
if (! (breaks_%8))
progress_indication ("[" + to_string (breaks_) + "]");
}
+ SCM page_br = get_property ("allowPageTurn");
+ if (scm_is_pair (page_br) && !last_breakable_moment_.main_part_.is_infinity ())
+ {
+ SCM pen = scm_cdr (page_br);
+ Moment *m = unsmob_moment (scm_car (page_br));
+ if (m && scm_is_number (pen) && *m <= last_breakable_moment_)
+ {
+ last_breakable_column_->set_property ("page-turn-permission", ly_symbol2scm ("allow"));
+ last_breakable_column_->set_property ("page-turn-penalty", pen);
+ }
+ }
+
+ context ()->get_score_context ()->unset_property ( ly_symbol2scm ("forbidBreak"));
+ context ()->get_score_context ()->unset_property ( ly_symbol2scm ("allowPageTurn"));
+
first_ = false;
break_event_ = 0;
}
@@ -210,9 +226,9 @@
/* doc */ "Takes care of generating columns."
"\n\n "
"This engraver decides whether a column is breakable. The default is "
- "that a column is always breakable. However, when every Bar_engraver "
- "that does not have a barline at a certain point will call "
- "Score_engraver::forbid_breaks to stop linebreaks. In practice, this "
+ "that a column is always breakable. However, every Bar_engraver "
+ "that does not have a barline at a certain point will set forbidBreaks "
+ "in the score context to stop linebreaks. In practice, this "
"means that you can make a breakpoint by creating a barline (assuming "
"that there are no beams or notes that prevent a breakpoint.) ",
@@ -221,7 +237,11 @@
"NonMusicalPaperColumn",
/* accept */ "break-event",
- /* read */ "",
+ /* read */
+ "forbidBreak "
+ "allowPageTurn",
/* write */
+ "forbidBreak "
+ "allowPageTurn "
"currentCommandColumn "
"currentMusicalColumn");
Index: lily/ligature-engraver.cc
===================================================================
RCS file: /sources/lilypond/lilypond/lily/ligature-engraver.cc,v
retrieving revision 1.59
diff -u -r1.59 ligature-engraver.cc
--- lily/ligature-engraver.cc 11 Feb 2006 11:35:17 -0000 1.59
+++ lily/ligature-engraver.cc 5 May 2006 06:25:34 -0000
@@ -12,7 +12,7 @@
#include "international.hh"
#include "note-head.hh"
#include "rest.hh"
-#include "score-engraver.hh"
+#include "score-context.hh"
#include "spanner.hh"
#include "warn.hh"
@@ -117,7 +117,7 @@
if (ligature_)
{
// TODO: maybe forbid breaks only if not transcribing
- get_score_engraver ()->forbid_breaks ();
+ context ()->get_score_context ()->set_property ("forbidBreak", SCM_BOOL_T);
}
if (events_drul_[START])
Index: lily/item.cc
===================================================================
RCS file: /sources/lilypond/lilypond/lily/item.cc,v
retrieving revision 1.123
diff -u -r1.123 item.cc
--- lily/item.cc 6 Jan 2006 09:13:26 -0000 1.123
+++ lily/item.cc 5 May 2006 06:25:34 -0000
@@ -46,7 +46,12 @@
me->programming_error ("only items can be breakable.");
Item *i = dynamic_cast<Item *> (me->get_parent (X_AXIS));
- return (i) ? Item::is_breakable (i) : to_boolean (me->get_property ("breakable"));
+ if (!i)
+ {
+ SCM break_perm = me->get_property ("break-permission");
+ return break_perm == ly_symbol2scm ("allow") || break_perm == ly_symbol2scm ("force");
+ }
+ return Item::is_breakable (i);
}
Paper_column *
@@ -210,4 +215,8 @@
" end-of-line-invisible no yes yes\n"
" center-invisible yes no yes\n"
"@end example\n",
- "no-spacing-rods break-visibility breakable")
+
+ /* properties */
+ "no-spacing-rods "
+ "break-visibility "
+ "break-penalty break-permission")
Index: lily/gourlay-breaking.cc
===================================================================
RCS file: /sources/lilypond/lilypond/lily/gourlay-breaking.cc,v
retrieving revision 1.96
diff -u -r1.96 gourlay-breaking.cc
--- lily/gourlay-breaking.cc 4 May 2006 09:49:37 -0000 1.96
+++ lily/gourlay-breaking.cc 5 May 2006 06:25:34 -0000
@@ -226,7 +226,7 @@
Grob *pc = this_one.cols_.back ();
if (pc->original ())
{
- SCM pen = pc->get_property ("penalty");
+ SCM pen = pc->get_property ("break-penalty");
if (scm_is_number (pen) && fabs (scm_to_double (pen)) < 10000)
break_penalties += scm_to_double (pen);
}
Index: lily/forbid-break-engraver.cc
===================================================================
RCS file: /sources/lilypond/lilypond/lily/forbid-break-engraver.cc,v
retrieving revision 1.26
diff -u -r1.26 forbid-break-engraver.cc
--- lily/forbid-break-engraver.cc 12 Aug 2005 00:04:47 -0000 1.26
+++ lily/forbid-break-engraver.cc 5 May 2006 06:25:34 -0000
@@ -5,13 +5,14 @@
(c) 2002--_2005 Han-Wen Nienhuys <[EMAIL PROTECTED]>
*/
-#include "rhythmic-head.hh"
+#include "duration.hh"
#include "grob.hh"
-#include "score-engraver.hh"
+#include "engraver.hh"
#include "input.hh"
-#include "pitch.hh"
-#include "duration.hh"
#include "moment.hh"
+#include "pitch.hh"
+#include "rhythmic-head.hh"
+#include "score-context.hh"
#include "translator.icc"
@@ -42,7 +43,7 @@
{
Grob *g = unsmob_grob (scm_cdar (busy));
if (g->internal_has_interface (ly_symbol2scm ("rhythmic-grob-interface")))
- get_score_engraver ()->forbid_breaks ();
+ context ()->get_score_context ()->set_property ("forbidBreak", SCM_BOOL_T);
busy = scm_cdr (busy);
}
}
@@ -53,4 +54,4 @@
/* create */ "",
/* accept */ "",
/* read */ "busyGrobs",
- /* write */ "");
+ /* write */ "forbidBreak");
Index: lily/constrained-breaking.cc
===================================================================
RCS file: /sources/lilypond/lilypond/lily/constrained-breaking.cc,v
retrieving revision 1.5
diff -u -r1.5 constrained-breaking.cc
--- lily/constrained-breaking.cc 4 May 2006 09:49:37 -0000 1.5
+++ lily/constrained-breaking.cc 5 May 2006 06:25:34 -0000
@@ -172,7 +172,7 @@
bool last = j == breaks_.size () - 1;
bool ragged = ragged_right || (last && ragged_last);
int k = i*lines_rank_ + j;
- SCM pen = all_[breaks_[j]]->get_property ("penalty");
+ SCM pen = all_[breaks_[j]]->get_property ("break-penalty");
if (scm_is_number (pen))
lines_[k].break_penalty_ = scm_to_double (pen);
Index: lily/break-align-engraver.cc
===================================================================
RCS file: /sources/lilypond/lilypond/lily/break-align-engraver.cc,v
retrieving revision 1.77
diff -u -r1.77 break-align-engraver.cc
--- lily/break-align-engraver.cc 6 Jan 2006 09:13:27 -0000 1.77
+++ lily/break-align-engraver.cc 5 May 2006 06:25:34 -0000
@@ -63,9 +63,7 @@
if (item->get_parent (X_AXIS))
return;
- SCM bp = item->get_property ("breakable");
- bool breakable = (to_boolean (bp));
- if (!breakable)
+ if (!Item::is_breakable (item))
return;
SCM align_name = item->get_property ("break-align-symbol");
Index: lily/beam-engraver.cc
===================================================================
RCS file: /sources/lilypond/lilypond/lily/beam-engraver.cc,v
retrieving revision 1.135
diff -u -r1.135 beam-engraver.cc
--- lily/beam-engraver.cc 11 Feb 2006 11:35:18 -0000 1.135
+++ lily/beam-engraver.cc 5 May 2006 06:25:34 -0000
@@ -15,7 +15,7 @@
#include "international.hh"
#include "item.hh"
#include "rest.hh"
-#include "score-engraver.hh"
+#include "score-context.hh"
#include "spanner.hh"
#include "stem.hh"
#include "warn.hh"
@@ -127,7 +127,7 @@
Beam_engraver::process_music ()
{
if (beam_ && !to_boolean (get_property ("allowBeamBreak")))
- get_score_engraver ()->forbid_breaks ();
+ context ()->get_score_context ()->set_property ("forbidBreak", SCM_BOOL_T);
if (start_ev_)
{
@@ -282,7 +282,7 @@
/* create */ "Beam",
/* accept */ "beam-event",
/* read */ "beamMelismaBusy beatLength subdivideBeams",
- /* write */ "");
+ /* write */ "forbidBreak");
class Grace_beam_engraver : public Beam_engraver
{
Index: lily/bar-engraver.cc
===================================================================
RCS file: /sources/lilypond/lilypond/lily/bar-engraver.cc,v
retrieving revision 1.86
diff -u -r1.86 bar-engraver.cc
--- lily/bar-engraver.cc 11 Feb 2006 11:35:18 -0000 1.86
+++ lily/bar-engraver.cc 5 May 2006 06:25:34 -0000
@@ -8,6 +8,8 @@
*/
#include "bar-line.hh"
+#include "context.hh"
+#include "score-context.hh"
#include "score-engraver.hh"
#include "warn.hh"
#include "item.hh"
@@ -89,8 +91,7 @@
Bar_engraver::stop_translation_timestep ()
{
if (!bar_)
- /* guh. Use properties! */
- get_score_engraver ()->forbid_breaks ();
+ context ()->get_score_context ()->set_property ("forbidBreak", SCM_BOOL_T);
else
typeset_bar ();
}
@@ -101,4 +102,4 @@
/* create */ "BarLine",
/* accept */ "",
/* read */ "whichBar",
- /* write */ "");
+ /* write */ "forbidBreak");
Index: python/convertrules.py
===================================================================
RCS file: /sources/lilypond/lilypond/python/convertrules.py,v
retrieving revision 1.48
diff -u -r1.48 convertrules.py
--- python/convertrules.py 30 Apr 2006 20:18:53 -0000 1.48
+++ python/convertrules.py 5 May 2006 06:25:34 -0000
@@ -2781,3 +2781,11 @@
conversions.append (((2, 7, 40), conv,
"rehearsalMarkAlignSymbol/barNumberAlignSymbol -> break-align-symbol"))
+
+
+def conv (str):
+ str = re.sub ('page-penalty', 'page-break-penalty')
+ str = re.sub ('([^-])penalty', '\1break-penalty')
+ return str
+
+conversions.append (((2, 9, 4), conv, """(page-)penalty -> (page-)break-penalty"""))
_______________________________________________
lilypond-devel mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/lilypond-devel