add breakbefore variable.
* lily/paper-book.cc (set_system_penalty): new function. Set
penalty_ based on breakBefore setting
2004-11-26 Han-Wen Nienhuys <hanwen@xs4all.nl>
+ * Documentation/user/changing-defaults.itely (Creating titles):
+ add breakbefore variable.
+
+ * lily/paper-book.cc (set_system_penalty): new function. Set
+ penalty_ based on breakBefore setting
+
* lily/context-specced-music-iterator.cc (construct_children):
interpret special context id $uniqueContextId
@item piece
Name of the piece, flush-left below the instrument.
+
+
+@cindex page breaks, forcing
+@item breakbefore
+ This forces the title to start on a new page.
@end table
Here is a demonstration of the fields available,
By default, headers are defined such that the page number is on the
outside edge, and the instrument is centered.
- @item oddFooterMarkup
+@item oddFooterMarkup
This is the page footer for odd-numbered pages.
@item evenFooterMarkup
@cindex page layout
@cindex titles
+The following definition will put the title flush left, and the
+composer flush right on a single line.
+
+@verbatim
+\paper {
+ bookTitleMarkup = \markup {
+ \fill-line <
+ \fromproperty #'header:title
+ \fromproperty #'header:composer
+ >
+ }
+}
+@end verbatim
+
\repeat unfold 4 {c4}
}
}
- \header {piece = "Piece II"}
+ \header {
+ breakbefore = ##f
+ piece = "Piece II"
+ }
\layout {linewidth = 9\cm}
}
}
bool is_title_;
public:
Interval staff_refpoints_;
- Real penalty_;
+ Real break_before_penalty_;
int number_;
Paper_system (Stencil, bool);
Stencil to_stencil () const;
SCM stencils () const;
bool is_title () const;
- Real penalty () const;
+ Real break_before_penalty () const;
};
DECLARE_UNSMOB (Paper_system, paper_system);
return title;
}
-
+
+void
+set_system_penalty (Paper_system * ps, SCM header)
+{
+ if (ly_c_module_p (header))
+ {
+ SCM force = ly_module_lookup (header, ly_symbol2scm ("breakbefore"));
+ if (SCM_VARIABLEP(force)
+ && scm_is_bool (SCM_VARIABLE_REF(force)))
+ {
+ ps->break_before_penalty_ = to_boolean (SCM_VARIABLE_REF(force))
+ ? -10000
+ : 10000;
+ }
+ }
+}
+
SCM
Paper_book::systems ()
{
if (!title.is_empty ())
{
Paper_system *ps = new Paper_system (title, true);
+ set_system_penalty (ps, header_);
+
systems_ = scm_cons (ps->self_scm (), systems_);
scm_gc_unprotect_object (ps->self_scm ());
}
Paper_system *ps = new Paper_system (title, true);
systems_ = scm_cons (ps->self_scm (), systems_);
scm_gc_unprotect_object (ps->self_scm ());
+
+ set_system_penalty (ps, score_systems_[i].header_);
+
}
if (scm_vector_p (score_systems_[i].systems_) == SCM_BOOL_T)
Paper_system *ps = unsmob_paper_system (scm_car (s));
ps->number_ = ++i;
- if (last && last->is_title ())
- // ugh, hardcoded.
- ps->penalty_ = 10000;
+ if (last
+ && last->is_title ()
+ && !ps->break_before_penalty_)
+ ps->break_before_penalty_ = 10000;
last = ps;
}
{
is_title_ = is_title;
number_ = 0;
- penalty_ = 0;
+ break_before_penalty_ = 0;
smobify_self ();
stencil_ = s;
staff_refpoints_ = Interval(0,0);
scm_puts (" ", port);
scm_puts (to_string (p->number_).to_str0 (), port);
scm_puts ("p ", port);
- scm_puts (to_string (p->penalty_).to_str0 (), port);
+ scm_puts (to_string (p->break_before_penalty_).to_str0 (), port);
if (p->is_title ())
scm_puts (" t", port);
scm_puts (" >", port);
}
Real
-Paper_system::penalty () const
+Paper_system::break_before_penalty () const
{
- return penalty_;
+ return break_before_penalty_;
}
Stencil
return scm_int2num (ps->number_);
}
-LY_DEFINE (ly_paper_system_break_score, "ly:paper-system-break-penalty",
+LY_DEFINE (ly_paper_system_break_before_penalty, "ly:paper-system-break-before-penalty",
1, 0, 0, (SCM system),
"Return the score for page break after @var{system}.")
{
Paper_system *ps = unsmob_paper_system (system);
SCM_ASSERT_TYPE (ps, system, SCM_ARG1, __FUNCTION__, "paper-system");
- return scm_int2num (int (ps->penalty ()));
+ return scm_int2num (int (ps->break_before_penalty ()));
}
LY_DEFINE (ly_paper_system_stencil, "ly:paper-system-stencil",
satisfied-constraints)
10000))
(positions (cdr vertical-spacing))
- (user-penalty (ly:paper-system-break-penalty (car current-lines)))
+ (user-nobreak-penalties
+ (-
+ (apply + (filter negative?
+ (map ly:paper-system-break-before-penalty
+ (cdr current-lines))))))
+ (user-penalty
+ (+
+ (max (ly:paper-system-break-before-penalty (car current-lines)) 0.0)
+ user-nobreak-penalties))
(total-penalty (combine-penalties
force user-penalty
best-paths))
#:penalty total-penalty)
current-best)))
- (if #f ;; debug
+ (if #t ;; debug
(display
(list
"\nuser pen " user-penalty
ly:layout-def?
ly:paper-get-font
ly:paper-get-number
- ly:paper-system-break-penalty
+ ly:paper-system-break-before-penalty
ly:paper-system-extent
ly:paper-system-number
ly:paper-system-stencil