]> git.donarmstrong.com Git - lilypond.git/commitdiff
* Documentation/user/changing-defaults.itely (Creating titles):
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Fri, 26 Nov 2004 13:33:30 +0000 (13:33 +0000)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Fri, 26 Nov 2004 13:33:30 +0000 (13:33 +0000)
add breakbefore variable.

* lily/paper-book.cc (set_system_penalty): new function. Set
penalty_ based on breakBefore setting

ChangeLog
Documentation/user/changing-defaults.itely
input/regression/page-layout.ly
lily/include/paper-system.hh
lily/paper-book.cc
lily/paper-system.cc
scm/page-layout.scm
scm/safe-lily.scm

index 33e6d4ad2200c0895aee2873581d873a2aa4d541..ae8e10b5059eebe4b67af0197d63e5e164ce2599 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
 2004-11-26  Han-Wen Nienhuys  <hanwen@xs4all.nl>
 
 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 
 
        * lily/context-specced-music-iterator.cc (construct_children):
        interpret special context id $uniqueContextId 
 
index f47925cf04b7041bbc5dd43ce46a1aba296978af..11102c2088ba0eb5b21ddff7a59f9e67cf61e2ef 100644 (file)
@@ -2109,6 +2109,11 @@ To whom the piece is dedicated.
 
 @item piece
 Name of the piece, flush-left below the instrument.
 
 @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, 
 @end table
 
 Here is a demonstration of the fields available, 
@@ -2183,7 +2188,7 @@ field).
   By default, headers are defined such that the page number is on the
   outside edge, and the instrument is centered.
 
   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
   This is the page footer for odd-numbered pages. 
   
 @item evenFooterMarkup
@@ -2201,6 +2206,20 @@ field).
 @cindex page layout
 @cindex titles
 
 @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
+
 
 
 
 
 
 
index 98a47fce01fa573b1f7e52eaed2008a724751fc3..1fd4c9a4ff37165f2cc74ee15df29eba252a9a1c 100644 (file)
@@ -56,7 +56,10 @@ This file is best viewed outside the collated files document.
                 \repeat unfold 4 {c4}
             }
         }
                 \repeat unfold 4 {c4}
             }
         }
-        \header {piece = "Piece II"}
+        \header {
+         breakbefore = ##f
+         piece = "Piece II"
+       }
         \layout {linewidth = 9\cm}
     }
 }
         \layout {linewidth = 9\cm}
     }
 }
index 92a394729f0b02c5ba6f2273a7401b86278d4b2e..50b4b4404b5770decdbd2b7e01bb82c2744bc639 100644 (file)
@@ -25,7 +25,7 @@ class Paper_system
   bool is_title_;
 public:
   Interval staff_refpoints_;
   bool is_title_;
 public:
   Interval staff_refpoints_;
-  Real penalty_;
+  Real break_before_penalty_;
   int number_;
 
   Paper_system (Stencil, bool);
   int number_;
 
   Paper_system (Stencil, bool);
@@ -33,7 +33,7 @@ public:
   Stencil to_stencil () const;
   SCM stencils () const;
   bool is_title () const;
   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);
 };
 
 DECLARE_UNSMOB (Paper_system, paper_system);
index d2227ed86c17ef0de6418c8360132a06c1ca8d0f..446725543b34f5952ddd2ae023058328a075bd7c 100644 (file)
@@ -343,7 +343,23 @@ Paper_book::score_title (int i)
   
   return title;
 }
   
   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 ()
 {
 SCM
 Paper_book::systems ()
 {
@@ -356,6 +372,8 @@ Paper_book::systems ()
   if (!title.is_empty ())
     {
       Paper_system *ps = new Paper_system (title, true);
   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 ());
     }
       systems_ = scm_cons (ps->self_scm (), systems_);
       scm_gc_unprotect_object (ps->self_scm ());
     }
@@ -369,6 +387,9 @@ Paper_book::systems ()
          Paper_system *ps = new Paper_system (title, true);
          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)
        }
       
       if (scm_vector_p (score_systems_[i].systems_) == SCM_BOOL_T)
@@ -390,9 +411,10 @@ Paper_book::systems ()
       Paper_system *ps = unsmob_paper_system (scm_car (s));
       ps->number_ = ++i;
 
       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;
     }
   
       last = ps;
     }
   
index 3a5835079c59f66a54ef0e58b0da922bf272ef5d..49fe5cb0b726e686dd2904665535ccbb92793b70 100644 (file)
@@ -22,7 +22,7 @@ Paper_system::Paper_system (Stencil s, bool is_title)
 {
   is_title_ = is_title;
   number_ = 0;
 {
   is_title_ = is_title;
   number_ = 0;
-  penalty_ = 0;
+  break_before_penalty_ = 0;
   smobify_self ();
   stencil_ = s;
   staff_refpoints_ = Interval(0,0);
   smobify_self ();
   stencil_ = s;
   staff_refpoints_ = Interval(0,0);
@@ -48,7 +48,7 @@ Paper_system::print_smob (SCM smob, SCM port, scm_print_state*)
   scm_puts (" ", port);
   scm_puts (to_string (p->number_).to_str0 (), port);
   scm_puts ("p ", port);
   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);
   if (p->is_title ())
     scm_puts (" t", port);
   scm_puts (" >", port);
@@ -62,9 +62,9 @@ Paper_system::is_title () const
 }
 
 Real
 }
 
 Real
-Paper_system::penalty () const
+Paper_system::break_before_penalty () const
 {
 {
-  return penalty_;
+  return break_before_penalty_;
 }
 
 Stencil
 }
 
 Stencil
@@ -104,13 +104,13 @@ LY_DEFINE (ly_paper_system_number, "ly:paper-system-number",
   return scm_int2num (ps->number_);
 }
 
   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");
           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",
 }
 
 LY_DEFINE (ly_paper_system_stencil, "ly:paper-system-stencil",
index 365bf6d49c8298f45beb6cd2008dd2ad4847aa2a..89ef9a7d8d04c86de4a4f0f50f474619dc0ed750 100644 (file)
@@ -343,7 +343,15 @@ CURRENT-BEST is the best result sofar, or #f."
                          satisfied-constraints)
                      10000))
           (positions (cdr vertical-spacing))
                          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))
            (total-penalty (combine-penalties
                            force user-penalty
                           best-paths))
@@ -364,7 +372,7 @@ CURRENT-BEST is the best result sofar, or #f."
                           #:penalty total-penalty)
                          current-best)))
       
                           #:penalty total-penalty)
                          current-best)))
       
-      (if #f ;; debug
+      (if #t ;; debug
           (display
            (list
             "\nuser pen " user-penalty
           (display
            (list
             "\nuser pen " user-penalty
index 417a77b453aac3896658bfc61637cd4a8a56ed06..a90a6c30565b5b1daab11f32cb9c2fb322ef4d9f 100644 (file)
@@ -99,7 +99,7 @@
      ly:layout-def?
      ly:paper-get-font
      ly:paper-get-number
      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
      ly:paper-system-extent
      ly:paper-system-number
      ly:paper-system-stencil