2005-09-27 Han-Wen Nienhuys <hanwen@xs4all.nl>
+ * lily/include/paper-system.hh (class Paper_system): remove
+ number_ variable. Remove is_title_. Remove break_before_penalty_
+
+ * lily/paper-book.cc (systems): use 'number property iso. number_
+ member.
+
+ * lily/paper-system-scheme.cc: remove ly:paper-system-break-before-penalty
+ remove ly:paper-system-number.
+
+ * scm/lily-library.scm (paper-system-title?): new function.
+
* lily/book.cc (process): bugfix: flip ?: cases.
* Documentation/user/changing-defaults.itely (Difficult tweaks):
-\version "2.6.0"
+\version "2.7.10"
\header {
-texidoc = "With @code{\\applycontext}, @code{\\properties} can be modified
+texidoc = "With @code{\\applyContext}, @code{\\properties} can be modified
procedurally. Applications include: checking bar numbers, smart
octavation.
%% todo: should put something interesting in the .tex output.
- \applycontext
+ \applyContext
#(lambda (tr)
(format #t "\nWe were called in barnumber ~a.\n"
(ly:context-property tr 'currentBarNumber)))
-\version "2.6.0"
+\version "2.7.10"
\header {
- texidoc = "The @code{\applyoutput} expression is the most flexible way to
+ texidoc = "The @code{\applyOutput} expression is the most flexible way to
tune properties for individual grobs.
Here, the layout of a note head is changed depending on its vertical
\stemUp
\set autoBeaming = ##f
{ <d f g b>8
- \context Voice \applyoutput #mc-squared
+ \context Voice \applyOutput #mc-squared
<d f g b>
}
texidoc = "With balloon texts, objects in the output can be marked,
with lines and explanatory text added."
}
-\version "2.6.0"
+\version "2.7.10"
\layout{ raggedright = ##t }
%% use predefd function.
- \context Voice \applyoutput #(add-balloon-text
+ \context Voice \applyOutput #(add-balloon-text
'NoteHead "heads, or tails?"
'(0 . -3))
raggedright= ##t
}
-\version "2.6.0"
+\version "2.7.10"
\new PianoStaff <<
\context Staff = "up" {
s1 *2
}
\context Staff = "down" <<
- \applymusic #notes-to-clusters \relative c { <c e>4 <f a> <b e> \change Staff = up <e a>
+ \applyMusic #notes-to-clusters \relative c { <c e>4 <f a> <b e> \change Staff = up <e a>
<a d> <d g> }
{ \clef bass s1 * 2 }
-\version "2.6.0"
+\version "2.7.10"
\header {
texidoc = "Clusters are a device to denote that a complete range of
notes is to be played."
<<
\new Staff \fragment
- \new Staff \applymusic #notes-to-clusters \fragment
+ \new Staff \applyMusic #notes-to-clusters \fragment
>>
-\version "2.6.0"
+\version "2.7.10"
\header{
texidoc="
\relative c''{
\context Bottom
- \applyoutput #(outputproperty-compatibility
+ \applyOutput #(outputproperty-compatibility
(make-type-checker 'note-head-interface)
'extra-offset '(2 . 3))
c2
c
\context Score {
- \applyoutput #(outputproperty-compatibility (make-type-checker 'mark-interface) 'extra-offset '(-1 . 4))
+ \applyOutput #(outputproperty-compatibility (make-type-checker 'mark-interface) 'extra-offset '(-1 . 4))
}
\mark A
d1
}
-\version "2.6.0"
+\version "2.7.10"
#(define (notes-to-skip m)
"Convert all stuff with duration (notes, lyrics, bass figures, etc.) to skips.
\relative c'' \context Voice {
\foobar
- << \applymusic #(lambda (x) (music-map notes-to-skip x))
+ << \applyMusic #(lambda (x) (music-map notes-to-skip x))
\foobar
{ d2 d2 } >>
}
-\version "2.6.0"
+\version "2.7.10"
\header {
texidoc = "Unfolding tremolo repeats. All fragments fill one
{
\time 2/4
- \applymusic #unfold-repeats
+ \applyMusic #unfold-repeats
{ \repeat tremolo 4 { c'16 e' } |
\repeat tremolo 8 c'16 } |
\time 3/4
- \applymusic #unfold-repeats
+ \applyMusic #unfold-repeats
{ \repeat tremolo 6 { c'16 e' } |
\repeat tremolo 12 c'16 } | \bar "|."
-\version "2.6.0"
+\version "2.7.10"
\header {
\score {
\relative c'' {
- a b \applymusic #(lambda (x) (music-map add-staccato x)) { c c }
+ a b \applyMusic #(lambda (x) (music-map add-staccato x)) { c c }
}
\layout{ raggedright = ##t }
}
-\version "2.6.0"
+\version "2.7.10"
\header {
texidoc= "@cindex make-music Fingering
m)
\score {
- \applymusic #(lambda (x) (add-text-script x "6") (display-music x) x ) { c'4-3 }
+ \applyMusic #(lambda (x) (add-text-script x "6") (display-music x) x ) { c'4-3 }
\layout{ raggedright = ##t }
}
-\version "2.6.0"
+\version "2.7.10"
% TODO: split ancient-font into seperate files; possibly in
% different locations.
\header {
% this is broken until further notice -- see refman
% \override Staff.StaffSymbol #'line-count = #5
- \context Staff \applyoutput #(outputproperty-compatibility (make-type-checker 'staff-symbol-interface) 'line-count 5)
+ \context Staff \applyOutput #(outputproperty-compatibility (make-type-checker 'staff-symbol-interface) 'line-count 5)
\transpose c c {
\set autoBeaming = ##f
-\version "2.6.0"
+\version "2.7.10"
\header {
texidoc = "@cindex Bar Number Every Fifth Reset
@code{set-bar-number-visibility}, to set automatically
@code{barNumberVisibility}, so that the bar numbers appear at regular
intervals, starting from the measure in which
-@code{set-bar-number-visibility} is set using @code{\applycontext}.
+@code{set-bar-number-visibility} is set using @code{\applyContext}.
"
}
-resetBarnum = \context Score \applycontext
+resetBarnum = \context Score \applyContext
#(set-bar-number-visibility 4)
\score {
<<
-\version "2.6.0"
+\version "2.7.10"
% possible rename to scheme- or something like that. -gp
\header { texidoc = "@cindex Scheme Move Text
Objects, like text, can be moved around by using some Scheme code.
\score {
\relative c''' {
\stemUp
- \applyoutput #(outputproperty-compatibility (make-text-checker (make-simple-markup "m.d."))
+ \applyOutput #(outputproperty-compatibility (make-text-checker (make-simple-markup "m.d."))
'extra-offset '(-3.5 . -4.5))
a^2^"m.d."
}
-\version "2.6.0"
+\version "2.7.10"
\include "deutsch.ly"
% possible rename to scheme- something. -gp
% TODO: ask if it needs to have so many empty bars in the middle. -gp
-\version "2.6.0"
+\version "2.7.10"
pat = \transpose c c' \repeat unfold 2 {
<< { \context Staff = "up" {r8 e16 f g e f g } }
\transpose c c' \context PianoStaff <<
\context Staff = "up" { \clef "G" }
\context Staff = "down" { \clef "F" }
- { \applymusic #transform {
+ { \applyMusic #transform {
\pat {c e g c' e' }
\pat {c d a d' f' }
}
-\version "2.6.0"
+\version "2.7.10"
% possible rename to scheme-something.
\header { texidoc="@cindex Scheme Reverse Music
Symmetric, or palindromical music can be produced, first, by printing
\score {
\context Voice {
\music
- \applymusic #reverse-music \music
+ \applyMusic #reverse-music \music
}
\layout { raggedright = ##t}
}
-\version "2.6.0"
+\version "2.7.10"
\header {
texidoc="@cindex Smart Transpose
\score {
\context Staff {
\transpose c ais \music
- \applymusic #naturalise \transpose c ais \music
+ \applyMusic #naturalise \transpose c ais \music
\transpose c deses \music
- \applymusic #naturalise \transpose c deses \music
+ \applyMusic #naturalise \transpose c deses \music
}
\layout { raggedright = ##t}
}
-\version "2.6.0"
+\version "2.7.10"
\header {
texidoc = "Applying the standard function @code{unfold-repeats} unfolds
\score { {
\mel \break
- \applymusic #unfold-repeats \mel
+ \applyMusic #unfold-repeats \mel
}
}
{
DECLARE_SMOBS (Paper_system,);
Stencil stencil_;
- bool is_title_;
- SCM details_;
+ SCM mutable_property_alist_;
+ SCM immutable_property_alist_;
+
+ void init_vars ();
public:
Interval staff_refpoints_;
- Real break_before_penalty_;
- int number_;
- Paper_system (Stencil, bool);
- void read_left_bound (Item*);
+ Paper_system (Stencil, SCM);
Stencil to_stencil () const;
SCM stencils () const;
SCM internal_get_property (SCM sym) const;
+ void internal_set_property (SCM sym, SCM val);
bool is_title () const;
Real break_before_penalty () const;
Interval staff_refpoints () const;
if (SCM_VARIABLEP (force)
&& scm_is_bool (SCM_VARIABLE_REF (force)))
{
- ps->break_before_penalty_ = to_boolean (SCM_VARIABLE_REF (force))
- ? -10000
- : 10000;
+ ps->set_property ("penalty",
+ scm_from_int(to_boolean (SCM_VARIABLE_REF (force))
+ ? -10000
+ : 10000));
}
}
}
title = score_title (header_);
if (!title.is_empty ())
{
- Paper_system *ps = new Paper_system (title, true);
+ // TODO: init properties, from where?
+ Paper_system *ps = new Paper_system (title, SCM_EOL);
+ ps->set_property ("is-title", SCM_BOOL_T);
systems_ = scm_cons (ps->self_scm (), systems_);
ps->unprotect ();
set_system_penalty (ps, header);
if (!title.is_empty ())
{
- Paper_system *ps = new Paper_system (title, true);
+ Paper_system *ps = new Paper_system (title, SCM_EOL);
+ ps->set_property ("is-title", SCM_BOOL_T);
set_system_penalty (ps, header_);
systems_ = scm_cons (ps->self_scm (), systems_);
SCM t = Text_interface::interpret_markup (paper_->self_scm (),
page_properties,
scm_car (s));
- // FIXME: title=true?
- Paper_system *ps = new Paper_system (*unsmob_stencil (t), true);
+
+ // TODO: init props
+ Paper_system *ps = new Paper_system (*unsmob_stencil (t), SCM_EOL);
+ ps->set_property ("is-title", SCM_BOOL_T);
systems_ = scm_cons (ps->self_scm (), systems_);
ps->unprotect ();
for (SCM s = systems_; s != SCM_EOL; s = scm_cdr (s))
{
Paper_system *ps = unsmob_paper_system (scm_car (s));
- ps->number_ = ++i;
+ ps->set_property ("number", scm_from_int (++i));
if (last
- && last->is_title ()
- && !ps->break_before_penalty_)
- ps->break_before_penalty_ = 10000;
+ && to_boolean (last->get_property ("is-title"))
+ && !scm_is_number (ps->get_property ("penalty")))
+ ps->set_property ("penalty", scm_from_int (10000));
last = ps;
}
return ly_interval2scm (ps->to_stencil ().extent (ax));
}
-LY_DEFINE (ly_paper_system_title_p, "ly:paper-system-title?",
- 1, 0, 0, (SCM system),
- "Is @var{system} a title system?")
-{
- Paper_system *ps = unsmob_paper_system (system);
- SCM_ASSERT_TYPE (ps, system, SCM_ARG1, __FUNCTION__, "paper-system");
- return SCM_BOOL (ps->is_title ());
-}
-
-LY_DEFINE (ly_paper_system_number, "ly:paper-system-number",
- 1, 0, 0, (SCM system),
- "Return the number of @var{system}.")
-{
- Paper_system *ps = unsmob_paper_system (system);
- SCM_ASSERT_TYPE (ps, system, SCM_ARG1, __FUNCTION__, "paper-system");
- return scm_from_int (ps->number_);
-}
-
-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_from_int (int (ps->break_before_penalty ()));
-}
-
LY_DEFINE (ly_paper_system_stencil, "ly:paper-system-stencil",
1, 0, 0, (SCM system),
"Return the height of @var{system}.")
IMPLEMENT_TYPE_P (Paper_system, "ly:paper-system?");
IMPLEMENT_DEFAULT_EQUAL_P (Paper_system);
-Paper_system::Paper_system (Stencil s, bool is_title)
+Paper_system::Paper_system (Stencil s, SCM immutable_init)
{
- is_title_ = is_title;
- number_ = 0;
- break_before_penalty_ = 0;
+ mutable_property_alist_ = SCM_EOL;
+ immutable_property_alist_ = immutable_init;
smobify_self ();
stencil_ = s;
staff_refpoints_ = Interval (0, 0);
+ init_vars ();
}
+
Paper_system::~Paper_system ()
{
}
Paper_system::mark_smob (SCM smob)
{
Paper_system *system = (Paper_system *) SCM_CELL_WORD_1 (smob);
- scm_gc_mark (system->details_);
+ scm_gc_mark (system->mutable_property_alist_);
return system->stencil_.expr ();
}
Paper_system *p = (Paper_system *) SCM_CELL_WORD_1 (smob);
scm_puts ("#<", port);
scm_puts (classname (p), port);
- scm_puts ("n ", port);
- scm_puts (to_string (p->number_).to_str0 (), port);
- scm_puts (", p ", port);
- scm_puts (to_string (p->break_before_penalty_).to_str0 (), port);
- if (p->is_title ())
- scm_puts (" t", port);
+ scm_display (p->mutable_property_alist_, port);
+
scm_puts (" >", port);
return 1;
}
-bool
-Paper_system::is_title () const
-{
- return is_title_;
-}
-
-Real
-Paper_system::break_before_penalty () const
-{
- return break_before_penalty_;
-}
Stencil
Paper_system::to_stencil () const
}
void
-Paper_system::read_left_bound (Item *left)
+Paper_system::init_vars ()
{
- break_before_penalty_
- = robust_scm2double (left->get_property ("page-penalty"), 0.0);
-
- details_
- = left->get_property ("line-break-system-details");
-
- SCM yext
- = scm_assq (ly_symbol2scm ("Y-extent"), details_);
-
- SCM staff_ext
- = scm_assq (ly_symbol2scm ("refpoint-Y-extent"), details_);
+ SCM yext = get_property ("Y-extent");
+ SCM staff_ext = get_property ("refpoint-Y-extent");
if (scm_is_pair (yext)
&& is_number_pair (scm_cdr (yext)))
SCM
Paper_system::internal_get_property (SCM sym) const
{
- SCM handle = scm_assq (sym, details_);
- if (scm_is_pair (handle))
- return scm_cdr (handle);
- else
- return SCM_EOL;
+ /*
+ TODO: type checking
+ */
+ SCM s = scm_sloppy_assq (sym, mutable_property_alist_);
+ if (s != SCM_BOOL_F)
+ return scm_cdr (s);
+
+ s = scm_sloppy_assq (sym, immutable_property_alist_);
+
+
+ return (s == SCM_BOOL_F) ? SCM_EOL : scm_cdr (s);
+}
+
+void
+Paper_system::internal_set_property (SCM sym, SCM val)
+{
+ mutable_property_alist_ = scm_assq_set_x (mutable_property_alist_, sym, val);
}
/*
staff_refpoints.add_point (g->relative_coordinate (this, Y_AXIS));
}
- Paper_system *pl = new Paper_system (sys_stencil, false);
+ Grob *left_bound = this->get_bound (LEFT);
+ SCM prop_init = left_bound->get_property ("line-break-system-details");
+ Paper_system *pl = new Paper_system (sys_stencil,
+ prop_init);
+
pl->staff_refpoints_ = staff_refpoints;
- pl->read_left_bound (this->get_bound (LEFT));
+ pl->set_property ("penalty",
+ left_bound->get_property ("page-penalty"));
return pl->unprotect ();
}
def conv (str):
- str = re.sub(r'\\applyoutput', '\\applyOutput', str)
- str = re.sub(r'\\applycontext', '\\applyContext', str)
- str = re.sub(r'\\applymusic', '\\applyMusic', str)
+ str = re.sub(r'\\applyoutput', r'\\applyOutput', str)
+ str = re.sub(r'\\applycontext', r'\\applyContext', str)
+ str = re.sub(r'\\applymusic', r'\\applyMusic', str)
str = re.sub(r'ly:grob-suicide', 'ly:grob-suicide!', str)
return str
(not
(ly:get-option 'preview-include-book-title))
(< 1 (length systems))
- (ly:paper-system-title? (list-ref systems 0))
- (ly:paper-system-title? (list-ref systems 1)))
+ (paper-system-title? (list-ref systems 0))
+ (paper-system-title? (list-ref systems 1)))
(set! systems (cdr systems)))
(for-each
(lambda (sys)
(if (or
- (ly:paper-system-title? sys)
+ (paper-system-title? sys)
(not (pair? to-dump-systems))
- (ly:paper-system-title? (car to-dump-systems)))
+ (paper-system-title? (car to-dump-systems)))
(set! to-dump-systems (cons sys to-dump-systems))))
systems)
(let* ((paper (ly:paper-book-paper book))
(systems (ly:paper-book-systems book))
(scale (ly:output-def-lookup paper 'outputscale))
- (titles (take-while ly:paper-system-title? systems))
+ (titles (take-while paper-system-title? systems))
(non-title (find (lambda (x)
- (not (ly:paper-system-title? x))) systems))
+ (not (paper-system-title? x))) systems))
(dump-me
(stack-stencils Y DOWN 0.0
(map ly:paper-system-stencil
(ly:score-process score header paper layout base)
))
+
+(define-public (paper-system-title? ps)
+ (equal? #t (ly:paper-system-property ps 'is-title)
+ ))
+
;;;;;;;;;;;;;;;;
;; alist
(define-public assoc-get ly:assoc-get)
"\n")))
(define-method (node-system-numbers (node <optimally-broken-page-node>))
- (map ly:paper-system-number (node-lines node)))
+ (map ly:paper-system-property (node-lines node) 'number))
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(let* ((system (car stencil-position))
(stencil (ly:paper-system-stencil system))
(y (cadr stencil-position))
- (is-title (ly:paper-system-title?
+ (is-title (paper-system-title?
(car stencil-position))))
(add-to-page stencil y)
(if (and (ly:stencil? system-separator-stencil)
last-system
- (not (ly:paper-system-title? system))
- (not (ly:paper-system-title? last-system)))
+ (not (paper-system-title? system))
+ (not (paper-system-title? last-system)))
(add-to-page
system-separator-stencil
(average (- last-y
"Return pages as a list starting with 1st page. Each page is a list
of lines. "
-
(define MAXPENALTY 1e9)
(define paper (ly:paper-book-paper paper-book))
(define scopes (ly:paper-book-scopes paper-book))
fixed-dist)
(interval-start this-system-ext))))
(title1? (and (vector-ref system-vector idx)
- (ly:paper-system-title? (vector-ref system-vector idx))))
+ (paper-system-title? (vector-ref system-vector idx)
+ )))
(title2? (and
(vector-ref system-vector (1+ idx))
- (ly:paper-system-title? (vector-ref system-vector (1+ idx)))))
+ (paper-system-title? (vector-ref system-vector (1+ idx)))))
(ideal (+
(cond
((and title2? title1?)
satisfied-constraints)
10000))
(positions (cdr vertical-spacing))
+ (get-break-penalty (lambda (sys)
+ (ly:paper-system-property sys 'penalty 0.0)))
(user-nobreak-penalties
(-
(apply + (filter negative?
- (map ly:paper-system-break-before-penalty
+ (map get-break-penalty
(cdr current-lines))))))
(user-penalty
(+
- (max (ly:paper-system-break-before-penalty (car current-lines)) 0.0)
+ (max (get-break-penalty (car current-lines)) 0.0)
user-nobreak-penalties))
(total-penalty (combine-penalties
force user-penalty
(cdr todo)))))
(define (line-number node)
- (ly:paper-system-number (car (node-lines node))))
+ (ly:paper-system-property (car (node-lines node)) 'number))
(ly:message (_ "Calculating page breaks..."))
(set! force-equalization-factor
ly:layout-def?
ly:paper-get-font
ly:paper-get-number
- ly:paper-system-break-before-penalty
ly:paper-system-extent
- ly:paper-system-number
ly:paper-system-stencil
ly:paper-system?
ly:output-def-lookup