CVSROOT: /cvsroot/lilypond Module name: lilypond Branch: Changes by: Han-Wen Nienhuys <[EMAIL PROTECTED]> 05/09/27 10:01:16
Modified files: . : ChangeLog Documentation/user: changing-defaults.itely global.itely introduction.itely programming-interface.itely lily : book.cc multi-measure-rest-engraver.cc paper-system-scheme.cc paper-system.cc piano-pedal-engraver.cc separating-line-group-engraver.cc spacing-engraver.cc lily/include : paper-system.hh ly : music-functions-init.ly paper-defaults.ly scm : page-layout.scm paper.scm Added files: input/regression: page-spacing.ly page-top-space.ly Log message: * lily/book.cc (process): bugfix: flip ?: cases. * Documentation/user/changing-defaults.itely (Difficult tweaks): add outputProperty. * ly/music-functions-init.ly: add outputProperty music function. * scm/paper.scm (set-paper-dimension-variables): add pagetopspace * scm/page-layout.scm (ly:optimal-page-breaks): read next-space and next-padding. (optimal-page-breaks): rename from ly:optimal-page-breaks. * lily/paper-system-scheme.cc (LY_DEFINE): new function. * lily/paper-system.cc (internal_get_property): new function. * Documentation/user/global.itely (Vertical spacing): refer to page-spacing.ly * scm/page-layout.scm (ly:optimal-page-breaks): add support for pagetopspace * input/regression/page-spacing.ly: new file. * input/regression/page-top-space.ly: new file. * lily/paper-system.cc (read_left_bound): new function. Read line-break-system-details from left bound to determine extents. * Documentation/user/programming-interface.itely (Using LilyPond syntax inside Scheme): change applyxxx -> applyXxx. * ly/music-functions-init.ly: add outputProperty music function. * ly/music-functions-init.ly: applyxxx -> applyXxx CVSWeb URLs: http://savannah.gnu.org/cgi-bin/viewcvs/lilypond/lilypond/ChangeLog.diff?tr1=1.4136&tr2=1.4137&r1=text&r2=text http://savannah.gnu.org/cgi-bin/viewcvs/lilypond/lilypond/Documentation/user/changing-defaults.itely.diff?tr1=1.135&tr2=1.136&r1=text&r2=text http://savannah.gnu.org/cgi-bin/viewcvs/lilypond/lilypond/Documentation/user/global.itely.diff?tr1=1.34&tr2=1.35&r1=text&r2=text http://savannah.gnu.org/cgi-bin/viewcvs/lilypond/lilypond/Documentation/user/introduction.itely.diff?tr1=1.143&tr2=1.144&r1=text&r2=text http://savannah.gnu.org/cgi-bin/viewcvs/lilypond/lilypond/Documentation/user/programming-interface.itely.diff?tr1=1.45&tr2=1.46&r1=text&r2=text http://savannah.gnu.org/cgi-bin/viewcvs/lilypond/lilypond/input/regression/page-spacing.ly?rev=1.1 http://savannah.gnu.org/cgi-bin/viewcvs/lilypond/lilypond/input/regression/page-top-space.ly?rev=1.1 http://savannah.gnu.org/cgi-bin/viewcvs/lilypond/lilypond/lily/book.cc.diff?tr1=1.49&tr2=1.50&r1=text&r2=text http://savannah.gnu.org/cgi-bin/viewcvs/lilypond/lilypond/lily/multi-measure-rest-engraver.cc.diff?tr1=1.113&tr2=1.114&r1=text&r2=text http://savannah.gnu.org/cgi-bin/viewcvs/lilypond/lilypond/lily/paper-system-scheme.cc.diff?tr1=1.5&tr2=1.6&r1=text&r2=text http://savannah.gnu.org/cgi-bin/viewcvs/lilypond/lilypond/lily/paper-system.cc.diff?tr1=1.18&tr2=1.19&r1=text&r2=text http://savannah.gnu.org/cgi-bin/viewcvs/lilypond/lilypond/lily/piano-pedal-engraver.cc.diff?tr1=1.103&tr2=1.104&r1=text&r2=text http://savannah.gnu.org/cgi-bin/viewcvs/lilypond/lilypond/lily/separating-line-group-engraver.cc.diff?tr1=1.87&tr2=1.88&r1=text&r2=text http://savannah.gnu.org/cgi-bin/viewcvs/lilypond/lilypond/lily/spacing-engraver.cc.diff?tr1=1.77&tr2=1.78&r1=text&r2=text http://savannah.gnu.org/cgi-bin/viewcvs/lilypond/lilypond/lily/include/paper-system.hh.diff?tr1=1.11&tr2=1.12&r1=text&r2=text http://savannah.gnu.org/cgi-bin/viewcvs/lilypond/lilypond/ly/music-functions-init.ly.diff?tr1=1.38&tr2=1.39&r1=text&r2=text http://savannah.gnu.org/cgi-bin/viewcvs/lilypond/lilypond/ly/paper-defaults.ly.diff?tr1=1.14&tr2=1.15&r1=text&r2=text http://savannah.gnu.org/cgi-bin/viewcvs/lilypond/lilypond/scm/page-layout.scm.diff?tr1=1.79&tr2=1.80&r1=text&r2=text http://savannah.gnu.org/cgi-bin/viewcvs/lilypond/lilypond/scm/paper.scm.diff?tr1=1.56&tr2=1.57&r1=text&r2=text Patches: Index: lilypond/ChangeLog diff -u lilypond/ChangeLog:1.4136 lilypond/ChangeLog:1.4137 --- lilypond/ChangeLog:1.4136 Tue Sep 27 07:56:17 2005 +++ lilypond/ChangeLog Tue Sep 27 10:01:14 2005 @@ -1,5 +1,31 @@ 2005-09-27 Han-Wen Nienhuys <[EMAIL PROTECTED]> + * lily/book.cc (process): bugfix: flip ?: cases. + + * Documentation/user/changing-defaults.itely (Difficult tweaks): + add outputProperty. + + * ly/music-functions-init.ly: add outputProperty music function. + + * scm/paper.scm (set-paper-dimension-variables): add pagetopspace + + * scm/page-layout.scm (ly:optimal-page-breaks): read next-space + and next-padding. + (optimal-page-breaks): rename from ly:optimal-page-breaks. + + * lily/paper-system-scheme.cc (LY_DEFINE): new function. + + * lily/paper-system.cc (internal_get_property): new function. + + * Documentation/user/global.itely (Vertical spacing): refer to page-spacing.ly + + * scm/page-layout.scm (ly:optimal-page-breaks): add support for + pagetopspace + + * input/regression/page-spacing.ly: new file. + + * input/regression/page-top-space.ly: new file. + * lily/spacing-spanner.cc: cmath -> math.h * lily/paper-system.cc (read_left_bound): new function. Read Index: lilypond/Documentation/user/changing-defaults.itely diff -u lilypond/Documentation/user/changing-defaults.itely:1.135 lilypond/Documentation/user/changing-defaults.itely:1.136 --- lilypond/Documentation/user/changing-defaults.itely:1.135 Tue Sep 20 11:21:01 2005 +++ lilypond/Documentation/user/changing-defaults.itely Tue Sep 27 10:01:15 2005 @@ -229,20 +229,20 @@ any context of type @var{type}, regardless of its given name. This variant is used with music expressions that can be interpreted at -several levels. For example, the @code{\applyoutput} command (see +several levels. For example, the @code{\applyOutput} command (see @ref{Running a function on all layout objects}). Without an explicit @code{\context}, it is usually applied to @context{Voice} @example -\applyoutput [EMAIL PROTECTED] % apply to Voice +\applyOutput [EMAIL PROTECTED] % apply to Voice @end example To have it interpreted at the @context{Score} or @context{Staff} level use these forms @example -\context Score \applyoutput [EMAIL PROTECTED] -\context Staff \applyoutput [EMAIL PROTECTED] +\context Score \applyOutput [EMAIL PROTECTED] +\context Staff \applyOutput [EMAIL PROTECTED] @end example @@ -1226,11 +1226,16 @@ @node Difficult tweaks @subsection Difficult tweaks -There are two classes of difficult adjustments. First, when there are +There are a few classes of difficult adjustments. + [EMAIL PROTECTED] @bullet +First, when there are several of the same objects at one point, and you want to adjust only -one. For example, if you want to change only one note head in a chord. +one. -In this case, the @code{\applyoutput} function must be used. The +For example, if you want to change only one note head in a chord. + +In this case, the @code{\applyOutput} function must be used. The next example defines a Scheme function @code{set-position-font-size} that sets the @code{font-size} property, but only on objects that have @internalsref{note-head-interface} and are at the @@ -1254,7 +1259,7 @@ \relative { c - \applyoutput #(set-position-font-size -2 4) + \applyOutput #(set-position-font-size -2 4) <c e g> } @end lilypond @@ -1263,6 +1268,7 @@ A similar technique can be used for accidentals. In that case, the function should check for @code{accidental-interface}. [EMAIL PROTECTED] Another difficult adjustment is the appearance of spanner objects, such as slur and tie. Initially, only one of these objects is created, and they can be adjusted with the normal mechanism. However, in some @@ -1323,3 +1329,18 @@ is one. For example, if using this with @code{Slur}, @code{Slur::after_line_breaking} should also be called. + [EMAIL PROTECTED] Some objects cannot be changed with @code{\override} for +technical reasons. Examples of those are @code{NonMusicalPaperColumn} +and @code{PaperColumn}. They can be changed with the [EMAIL PROTECTED] function, which works similar to @code{\once +\override}, but uses a different syntax, + [EMAIL PROTECTED] +\outputProperty +#"Score.NonMusicalPaperColumn" % Grob name +#'line-break-system-details % Property name +#'((next-padding . 20)) % Value [EMAIL PROTECTED] example + [EMAIL PROTECTED] itemize Index: lilypond/Documentation/user/global.itely diff -u lilypond/Documentation/user/global.itely:1.34 lilypond/Documentation/user/global.itely:1.35 --- lilypond/Documentation/user/global.itely:1.34 Thu Sep 8 06:54:44 2005 +++ lilypond/Documentation/user/global.itely Tue Sep 27 10:01:15 2005 @@ -298,6 +298,12 @@ @item footsep Distance between the bottom-most music system and the page footer. [EMAIL PROTECTED] @code{pagetopspace} +Distance from the top of the printable area to the center of the first +staff. This only works for staves which are vertically small. Big staves +are set with the top of their bounding box aligned to the top of the +printable area. + @cindex @code{raggedbottom} @item raggedbottom If set to true, systems will not be spread across the page. @@ -513,6 +519,13 @@ @end example [EMAIL PROTECTED] let's wait for a some comments before writing more. + +The vertical spacing on a page can also be changed for each system individually. +Some examples are found in the example file [EMAIL PROTECTED]/regression/,page-spacing.ly}. + + @seealso Internals: Vertical alignment of staves is handled by the @@ -520,6 +533,9 @@ specifying the vertical extent are described in connection with the @internalsref{Axis_group_engraver}. +Example files: @inputfileref{input/regression/,page-spacing.ly}. + + @refbugs @code{minimumVerticalExtent} is syntactic sugar for setting @@ -576,16 +592,15 @@ @code{forced-distance} cannot be changed per system. - @node Horizontal spacing @subsection Horizontal Spacing -The spacing engine translates differences in durations into -stretchable distances (``springs'') of differring lengths. Longer -durations get more space, shorter durations get less. The shortest -durations get a fixed amount of space (which is controlled by [EMAIL PROTECTED] in the @internalsref{SpacingSpanner} object). -The longer the duration, the more space it gets: doubling a +The spacing engine translates differences in durations into stretchable +distances (``springs'') of differring lengths. Longer durations get +more space, shorter durations get less. The shortest durations get a +fixed amount of space (which is controlled by [EMAIL PROTECTED] in the @internalsref{SpacingSpanner} +object). The longer the duration, the more space it gets: doubling a duration adds a fixed amount (this amount is controlled by @code{spacing-increment}) of space to the note. Index: lilypond/Documentation/user/introduction.itely diff -u lilypond/Documentation/user/introduction.itely:1.143 lilypond/Documentation/user/introduction.itely:1.144 --- lilypond/Documentation/user/introduction.itely:1.143 Thu Sep 8 06:54:44 2005 +++ lilypond/Documentation/user/introduction.itely Tue Sep 27 10:01:15 2005 @@ -340,11 +340,11 @@ <d f g> \once \override NoteHead #'style = #'cross <d f g> - \applyoutput #mc-squared + \applyOutput #mc-squared <d f g> << { d8[ es-( fis^^ g] fis2-) } - \repeat unfold 5 { \applyoutput #mc-squared s8 } + \repeat unfold 5 { \applyOutput #mc-squared s8 } >> } @end lilypond Index: lilypond/Documentation/user/programming-interface.itely diff -u lilypond/Documentation/user/programming-interface.itely:1.45 lilypond/Documentation/user/programming-interface.itely:1.46 --- lilypond/Documentation/user/programming-interface.itely:1.45 Mon Sep 26 23:25:58 2005 +++ lilypond/Documentation/user/programming-interface.itely Tue Sep 27 10:01:15 2005 @@ -746,13 +746,13 @@ @cindex calling code on layout objects [EMAIL PROTECTED] @code{\applyoutput} [EMAIL PROTECTED] @code{\applyOutput} -The most versatile way of tuning an object is @code{\applyoutput}. Its +The most versatile way of tuning an object is @code{\applyOutput}. Its syntax is @example -\applyoutput @var{proc} +\applyOutput @var{proc} @end example @noindent @@ -763,7 +763,7 @@ @itemize @bullet @item the layout object itself, @item the context where the layout object was created, and [EMAIL PROTECTED] the context where @code{\applyoutput} is processed. [EMAIL PROTECTED] the context where @code{\applyOutput} is processed. @end itemize @@ -773,7 +773,7 @@ @internalsref{NoteHead} event, and for a @internalsref{Stem} object, this is a @internalsref{NoteHead} object. -Here is a function to use for @code{\applyoutput}; it blanks +Here is a function to use for @code{\applyOutput}; it blanks note-heads on the center-line: @example Index: lilypond/lily/book.cc diff -u lilypond/lily/book.cc:1.49 lilypond/lily/book.cc:1.50 --- lilypond/lily/book.cc:1.49 Tue Sep 20 10:54:50 2005 +++ lilypond/lily/book.cc Tue Sep 27 10:01:15 2005 @@ -86,7 +86,7 @@ if (score->error_found_) return 0; - Output_def *paper = paper_ ? default_paper : paper_; + Output_def *paper = paper_ ? paper_ : default_paper; if (!paper) return 0; Index: lilypond/lily/include/paper-system.hh diff -u lilypond/lily/include/paper-system.hh:1.11 lilypond/lily/include/paper-system.hh:1.12 --- lilypond/lily/include/paper-system.hh:1.11 Mon Sep 26 23:25:59 2005 +++ lilypond/lily/include/paper-system.hh Tue Sep 27 10:01:15 2005 @@ -22,7 +22,7 @@ DECLARE_SMOBS (Paper_system,); Stencil stencil_; bool is_title_; - + SCM details_; public: Interval staff_refpoints_; Real break_before_penalty_; @@ -32,6 +32,7 @@ void read_left_bound (Item*); Stencil to_stencil () const; SCM stencils () const; + SCM internal_get_property (SCM sym) const; bool is_title () const; Real break_before_penalty () const; Interval staff_refpoints () const; Index: lilypond/lily/multi-measure-rest-engraver.cc diff -u lilypond/lily/multi-measure-rest-engraver.cc:1.113 lilypond/lily/multi-measure-rest-engraver.cc:1.114 --- lilypond/lily/multi-measure-rest-engraver.cc:1.113 Thu Aug 18 15:34:31 2005 +++ lilypond/lily/multi-measure-rest-engraver.cc Tue Sep 27 10:01:15 2005 @@ -252,5 +252,11 @@ "should use a whole rest or a breve rest to represent 1 measure ", /* create */ "MultiMeasureRest MultiMeasureRestNumber MultiMeasureRestText", /* accept */ "multi-measure-rest-event multi-measure-text-event", - /* read */ "currentBarNumber restNumberThreshold breakableSeparationItem currentCommandColumn measurePosition measureLength", + /* read */ + "currentBarNumber " + "restNumberThreshold " + "breakableSeparationItem " + "currentCommandColumn " + "measurePosition " + "measureLength", /* write */ ""); Index: lilypond/lily/paper-system-scheme.cc diff -u lilypond/lily/paper-system-scheme.cc:1.5 lilypond/lily/paper-system-scheme.cc:1.6 --- lilypond/lily/paper-system-scheme.cc:1.5 Mon Sep 26 23:25:58 2005 +++ lilypond/lily/paper-system-scheme.cc Tue Sep 27 10:01:15 2005 @@ -64,3 +64,26 @@ return ly_interval2scm (ps->staff_refpoints ()); } + + +LY_DEFINE (ly_paper_system_property, "ly:paper-system-property", + 2, 1, 0, (SCM system, SCM sym, SCM dfault), + "Return the value for @var{sym}. Properties may be set by " + "setting the @code{line-break-system-details} property of " + "NonMusicalPaperColumn. If the property is not found, " + "return @var{dfault}, " + "or @code{'()} if undefined.") +{ + Paper_system *ps = unsmob_paper_system (system); + SCM_ASSERT_TYPE (ps, system, SCM_ARG1, __FUNCTION__, "paper-system"); + if (dfault == SCM_UNDEFINED) + dfault = SCM_EOL; + + SCM retval = ps->internal_get_property (sym); + if (retval == SCM_EOL) + return dfault; + else + return retval; +} + + Index: lilypond/lily/paper-system.cc diff -u lilypond/lily/paper-system.cc:1.18 lilypond/lily/paper-system.cc:1.19 --- lilypond/lily/paper-system.cc:1.18 Mon Sep 26 23:25:58 2005 +++ lilypond/lily/paper-system.cc Tue Sep 27 10:01:15 2005 @@ -33,6 +33,7 @@ Paper_system::mark_smob (SCM smob) { Paper_system *system = (Paper_system *) SCM_CELL_WORD_1 (smob); + scm_gc_mark (system->details_); return system->stencil_.expr (); } @@ -76,14 +77,14 @@ break_before_penalty_ = robust_scm2double (left->get_property ("page-penalty"), 0.0); - SCM details + details_ = left->get_property ("line-break-system-details"); SCM yext - = scm_assoc (ly_symbol2scm ("Y-extent"), details); + = scm_assq (ly_symbol2scm ("Y-extent"), details_); SCM staff_ext - = scm_assoc (ly_symbol2scm ("refpoint-Y-extent"), details); + = scm_assq (ly_symbol2scm ("refpoint-Y-extent"), details_); if (scm_is_pair (yext) && is_number_pair (scm_cdr (yext))) @@ -101,6 +102,19 @@ } } +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: move to Paper_system property. + */ Interval Paper_system::staff_refpoints () const { Index: lilypond/lily/piano-pedal-engraver.cc diff -u lilypond/lily/piano-pedal-engraver.cc:1.103 lilypond/lily/piano-pedal-engraver.cc:1.104 --- lilypond/lily/piano-pedal-engraver.cc:1.103 Sat Aug 13 21:35:22 2005 +++ lilypond/lily/piano-pedal-engraver.cc Tue Sep 27 10:01:15 2005 @@ -515,7 +515,10 @@ /* create */ "SostenutoPedal SustainPedal UnaCordaPedal SostenutoPedalLineSpanner SustainPedalLineSpanner UnaCordaPedalLineSpanner", /* accept */ "pedal-event", /* read */ "currentCommandColumn " - "pedalSostenutoStrings pedalSustainStrings " - "pedalUnaCordaStrings pedalSostenutoStyle " - "pedalSustainStyle pedalUnaCordaStyle", + "pedalSostenutoStrings " + "pedalSustainStrings " + "pedalUnaCordaStrings " + "pedalSostenutoStyle " + "pedalSustainStyle " + "pedalUnaCordaStyle", /* write */ ""); Index: lilypond/lily/separating-line-group-engraver.cc diff -u lilypond/lily/separating-line-group-engraver.cc:1.87 lilypond/lily/separating-line-group-engraver.cc:1.88 --- lilypond/lily/separating-line-group-engraver.cc:1.87 Sat Aug 13 21:35:22 2005 +++ lilypond/lily/separating-line-group-engraver.cc Tue Sep 27 10:01:15 2005 @@ -73,7 +73,6 @@ void Separating_line_group_engraver::process_music () { - if (!sep_span_) { sep_span_ = make_spanner ("SeparatingGroupSpanner", SCM_EOL); @@ -218,7 +217,11 @@ ADD_ACKNOWLEDGER (Separating_line_group_engraver, item); ADD_TRANSLATOR (Separating_line_group_engraver, /* doc */ "Generates objects for computing spacing parameters.", - /* create */ "SeparationItem SeparatingGroupSpanner StaffSpacing", + + /* create */ + "SeparationItem " + "SeparatingGroupSpanner " + "StaffSpacing", /* accept */ "", /* read */ "createSpacing", /* write */ "breakableSeparationItem"); Index: lilypond/lily/spacing-engraver.cc diff -u lilypond/lily/spacing-engraver.cc:1.77 lilypond/lily/spacing-engraver.cc:1.78 --- lilypond/lily/spacing-engraver.cc:1.77 Fri Aug 12 00:04:45 2005 +++ lilypond/lily/spacing-engraver.cc Tue Sep 27 10:01:15 2005 @@ -204,5 +204,9 @@ /* create */ "SpacingSpanner", /* accept */ "", - /* read */ "currentMusicalColumn currentCommandColumn proportionalNotationDuration", + /* read */ + "currentMusicalColumn " + "currentCommandColumn " + "proportionalNotationDuration", + /* write */ ""); Index: lilypond/ly/music-functions-init.ly diff -u lilypond/ly/music-functions-init.ly:1.38 lilypond/ly/music-functions-init.ly:1.39 --- lilypond/ly/music-functions-init.ly:1.38 Mon Sep 26 23:25:59 2005 +++ lilypond/ly/music-functions-init.ly Tue Sep 27 10:01:15 2005 @@ -65,21 +65,37 @@ 'procedure proc)) outputProperty = -#(def-music-function (parser location name prop value) - (symbol? symbol? scheme?) +#(def-music-function (parser location name property value) + (string? symbol? scheme?) - "Set @var{prop} to @var{value} in all grobs named @var{name} " + "Set @var{property} to @var{value} in all grobs named @var{name}. +The @var{name} argument is a string of the form @code{\"Context.GrobName\"} +or @code{\"GrobName\"}" - (make-music 'ApplyOutputEvent - 'origin location - 'procedure - (lambda (grob orig-context context) - (if (equal? - (cdr (assoc 'name (ly:grob-property grob 'meta))) - name) - (set! (ly:grob-property grob prop) value) - )))) + (let* + ((name-components (string-split name #\.)) + (context-name 'Bottom) + (grob-name #f)) + + (if (> 2 (length name-components)) + (set! grob-name (string->symbol (car name-components))) + (begin + (set! grob-name (string->symbol (list-ref name-components 1))) + (set! context-name (string->symbol (list-ref name-components 0))))) + + (context-spec-music + (make-music 'ApplyOutputEvent + 'origin location + 'procedure + (lambda (grob orig-context context) + (if (equal? + (cdr (assoc 'name (ly:grob-property grob 'meta))) + grob-name) + (set! (ly:grob-property grob property) value) + ))) + + context-name))) breathe = #(def-music-function (parser location) () Index: lilypond/ly/paper-defaults.ly diff -u lilypond/ly/paper-defaults.ly:1.14 lilypond/ly/paper-defaults.ly:1.15 --- lilypond/ly/paper-defaults.ly:1.14 Fri Jul 8 17:53:41 2005 +++ lilypond/ly/paper-defaults.ly Tue Sep 27 10:01:15 2005 @@ -40,7 +40,8 @@ %% staves themselves. %% betweensystemspace = #(* 20 mm) - + + %% %% fixed space between systems. %% @@ -50,6 +51,14 @@ beforetitlespace = 10 \mm betweentitlespace = 2 \mm + + %% + %% Small staves are aligned so they come out on the same place on + %% across different pages. + %% + pagetopspace = #(* 12 mm) + + raggedbottom = ##f %% @@ -75,7 +84,7 @@ (baseline-skip . 3) (word-space . 0.6))) - #(define page-breaking ly:optimal-page-breaks) + #(define page-breaking optimal-page-breaks) #(define page-music-height default-page-music-height ) #(define page-make-stencil default-page-make-stencil ) Index: lilypond/scm/page-layout.scm diff -u lilypond/scm/page-layout.scm:1.79 lilypond/scm/page-layout.scm:1.80 --- lilypond/scm/page-layout.scm:1.79 Fri Jul 22 22:52:25 2005 +++ lilypond/scm/page-layout.scm Tue Sep 27 10:01:15 2005 @@ -185,8 +185,7 @@ ;; - separate function for word-wrap style breaking? ;; - raggedbottom? raggedlastbottom? -(define-public (ly:optimal-page-breaks - lines paper-book) +(define-public (optimal-page-breaks lines paper-book) "Return pages as a list starting with 1st page. Each page is a list of lines. " @@ -230,90 +229,120 @@ user))) (define (space-systems page-height lines ragged?) - (let* ((inter-system-space + (let* ((global-inter-system-space (ly:output-def-lookup paper 'betweensystemspace)) + (top-space + (ly:output-def-lookup paper 'pagetopspace)) + (global-fixed-dist (ly:output-def-lookup paper 'betweensystempadding)) + (system-vector (list->vector (append lines (if (= (length lines) 1) '(#f) '())))) - (staff-extents - (list->vector - (append (map ly:paper-system-staff-extents lines) - (if (= (length lines) 1) - '((0 . 0)) - '())))) - (real-extents - (list->vector - (append - (map - (lambda (sys) (ly:paper-system-extent sys Y)) lines) - (if (= (length lines) 1) - '((0 . 0)) - '())))) - (no-systems (vector-length real-extents)) - (topskip (interval-end (vector-ref real-extents 0))) - (space-left (- page-height - (apply + (map interval-length (vector->list real-extents))))) - - (space (- page-height - topskip - (- (interval-start (vector-ref real-extents (1- no-systems)))))) - - (fixed-dist (ly:output-def-lookup paper 'betweensystempadding)) - (calc-spring - (lambda (idx) - (let* ((this-system-ext (vector-ref staff-extents idx)) - (next-system-ext (vector-ref staff-extents (1+ idx))) - (fixed (max 0 (- (+ (interval-end next-system-ext) - fixed-dist) - (interval-start this-system-ext)))) - (title1? (and (vector-ref system-vector idx) - (ly: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))))) - (ideal (+ - (cond - ((and title2? title1?) - (ly:output-def-lookup paper 'betweentitlespace)) - (title1? - (ly:output-def-lookup paper 'aftertitlespace)) - (title2? - (ly:output-def-lookup paper 'beforetitlespace)) - (else inter-system-space)) - fixed)) - (hooke (/ 1 (- ideal fixed)))) - (list ideal hooke)))) - - (springs (map calc-spring (iota (1- no-systems)))) - (calc-rod - (lambda (idx) - (let* ((this-system-ext (vector-ref real-extents idx)) - (next-system-ext (vector-ref real-extents (1+ idx))) - (distance (max (- (+ (interval-end next-system-ext) - fixed-dist) - (interval-start this-system-ext) - ) 0)) - (entry (list idx (1+ idx) distance))) - entry))) - (rods (map calc-rod (iota (1- no-systems)))) - - ;; we don't set ragged based on amount space left. - ;; raggedbottomlast = ##T is much more predictable - (result (ly:solve-spring-rod-problem - springs rods space - ragged?)) - - (force (car result)) - (positions - (map (lambda (y) - (+ y topskip)) - (cdr result)))) + (staff-extents + (list->vector + (append (map ly:paper-system-staff-extents lines) + (if (= (length lines) 1) + '((0 . 0)) + '())))) + + (real-extents + (list->vector + (append + (map + (lambda (sys) (ly:paper-system-extent sys Y)) lines) + (if (= (length lines) 1) + '((0 . 0)) + '())))) + + (system-count (vector-length real-extents)) + (topskip (max + (+ + top-space + (interval-end (vector-ref staff-extents 0))) + (interval-end (vector-ref real-extents 0)) + )) + (last-system (vector-ref system-vector (1- system-count))) + (bottom-space (if (ly:paper-system? last-system) + (ly:paper-system-property last-system 'bottom-space 0.0) + 0.0)) + (space-left (- page-height + bottom-space + (apply + (map interval-length + (vector->list real-extents))))) + + (space (- page-height + topskip + bottom-space + (- (interval-start + (vector-ref real-extents (1- system-count)))))) + + (calc-spring + (lambda (idx) + (let* ( + (upper-system (vector-ref system-vector idx)) + (between-space (ly:paper-system-property upper-system 'next-space + global-inter-system-space)) + (fixed-dist (ly:paper-system-property upper-system 'next-padding + global-fixed-dist)) + + (this-system-ext (vector-ref staff-extents idx)) + (next-system-ext (vector-ref staff-extents (1+ idx))) + (fixed (max 0 (- (+ (interval-end next-system-ext) + fixed-dist) + (interval-start this-system-ext)))) + (title1? (and (vector-ref system-vector idx) + (ly: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))))) + (ideal (+ + (cond + ((and title2? title1?) + (ly:output-def-lookup paper 'betweentitlespace)) + (title1? + (ly:output-def-lookup paper 'aftertitlespace)) + (title2? + (ly:output-def-lookup paper 'beforetitlespace)) + (else between-space)) + fixed)) + (hooke (/ 1 (- ideal fixed)))) + (list ideal hooke)))) + + (springs (map calc-spring (iota (1- system-count)))) + (calc-rod + (lambda (idx) + (let* ( + (upper-system (vector-ref system-vector idx)) + (fixed-dist (ly:paper-system-property upper-system 'next-padding + global-fixed-dist)) + (this-system-ext (vector-ref real-extents idx)) + (next-system-ext (vector-ref real-extents (1+ idx))) + + (distance (max (- (+ (interval-end next-system-ext) + fixed-dist) + (interval-start this-system-ext) + ) 0)) + (entry (list idx (1+ idx) distance))) + entry))) + (rods (map calc-rod (iota (1- system-count)))) + + ;; we don't set ragged based on amount space left. + ;; raggedbottomlast = ##T is much more predictable + (result (ly:solve-spring-rod-problem + springs rods space + ragged?)) + + (force (car result)) + (positions + (map (lambda (y) + (+ y topskip)) + (cdr result)))) (if #f ;; debug. (begin - (display (list "\n# systems: " no-systems + (display (list "\n# systems: " system-count "\nreal-ext" real-extents "\nstaff-ext" staff-extents "\ninterscore" inter-system-space "\nspace-letf" space-left Index: lilypond/scm/paper.scm diff -u lilypond/scm/paper.scm:1.56 lilypond/scm/paper.scm:1.57 --- lilypond/scm/paper.scm:1.56 Thu Jul 21 01:11:50 2005 +++ lilypond/scm/paper.scm Tue Sep 27 10:01:15 2005 @@ -7,6 +7,7 @@ (define-public (set-paper-dimension-variables mod) (module-define! mod 'dimension-variables '(pt mm cm in staffheight staff-space + pagetopspace betweensystemspace betweensystempadding linewidth indent hsize vsize horizontalshift staffspace linethickness ledgerlinethickness _______________________________________________ Lilypond-cvs mailing list Lilypond-cvs@gnu.org http://lists.gnu.org/mailman/listinfo/lilypond-cvs