]> git.donarmstrong.com Git - lilypond.git/commitdiff
Merge branch 'master' of git+ssh://jneem@git.sv.gnu.org/srv/git/lilypond
authorJoe Neeman <joeneeman@gmail.com>
Sun, 7 Jan 2007 09:25:53 +0000 (11:25 +0200)
committerJoe Neeman <joeneeman@gmail.com>
Sun, 7 Jan 2007 09:25:53 +0000 (11:25 +0200)
input/regression/page-turn-page-breaking-badturns.ly
input/regression/page-turn-page-breaking-repeats.ly [new file with mode: 0644]
input/regression/page-turn-page-breaking.ly
lily/accidental.cc
lily/grob.cc
lily/include/accidental-interface.hh
lily/page-turn-page-breaking.cc
scm/define-grobs.scm

index 0292751d52b78e68aaaf4fda075a8c553fa67020..df8386d1ccbf3cc6d1faf4b2bf0426f011a8fbde 100644 (file)
@@ -7,16 +7,20 @@ should appear on 3 pages.
 "
 }
 
-\paper {
-  #(define page-breaking ly:page-turn-breaking)
-  paper-height = #70
-  print-page-number = ##t
-}
+\book {
+  \paper {
+    #(define page-breaking ly:page-turn-breaking)
+    paper-height = #65
+    print-page-number = ##t
+  }
 
-\relative c' {
-  a b c d a b c d \break
-  c d e f c d e f \break
-  d e f g d e f g
+  \score {
+    \relative c' {
+      a b c d a b c d \break
+      c d e f c d e f \break
+      d e f g d e f g
+    }
+  }
 }
 
 
diff --git a/input/regression/page-turn-page-breaking-repeats.ly b/input/regression/page-turn-page-breaking-repeats.ly
new file mode 100644 (file)
index 0000000..f43184d
--- /dev/null
@@ -0,0 +1,43 @@
+\version "2.10.0"
+
+\header {
+  texidoc = "The page-turn engraver will not count potential page
+turns if they occur in the middle of a repeat unless there is a
+long gap at the beginning or at the end of the repeat.
+"
+}
+
+\layout {
+  \context {
+    \Staff
+    \consists "Page_turn_engraver"
+  }
+}
+
+\book {
+  \paper {
+    #(define page-breaking ly:page-turn-breaking)
+    paper-height = #80
+    print-page-number = ##t
+    print-first-page-number = ##t
+  }
+
+  \score {
+    \relative {
+      \set Score.skipBars = ##t
+      % this should be kept on one page
+      \repeat volta 2 {
+       \repeat unfold 7 {a4 b c d16 d d d} R1*10
+       \repeat unfold 8 {a4 b c d16 d d d} \pageTurn
+      }
+      % use up a page
+      a4 b c d a b c d \pageBreak
+
+      % this should be allowed to have a page turn
+      \repeat volta 2 {
+       \repeat unfold 7 {a4 b c d16 d d d} R1*10
+       \repeat unfold 7 {a4 b c d16 d d d} R1*3
+      }
+    }
+  }
+}
\ No newline at end of file
index 8c296b71b6b5c3ad43b81ad5cf2537d213608f6e..686622b7d5b7436deebe6acd142de23d42facf4f 100644 (file)
@@ -7,14 +7,6 @@ in which case the turn will go after the special barline.
 "
 }
 
-\paper {
-  #(define page-breaking ly:page-turn-breaking)
-  paper-height = #70
-  auto-first-page-number = ##t
-  print-page-number = ##t
-  print-first-page-number = ##t
-}
-
 \layout {
   \context {
     \Staff
@@ -22,11 +14,24 @@ in which case the turn will go after the special barline.
   }
 }
 
-\relative c' {
-  a b c d a b c d \break
-  c d e f c d e f R1*4
-  \repeat unfold 15 {d4 e f g} \break
-  c d e f c d e f R1*2 \bar "||" R1*2
-  \repeat unfold 15 {d4 e f g}
+\book {
+
+  \paper {
+    #(define page-breaking ly:page-turn-breaking)
+    paper-height = #65
+    auto-first-page-number = ##t
+    print-page-number = ##t
+    print-first-page-number = ##t
+  }
+
+  \score {
+    \relative c' {
+      a b c d a b c d \break
+      c d e f c d e f R1*4
+      \repeat unfold 15 {d4 e f g} \break
+      c d e f c d e f R1*2 \bar "||" R1*2
+      \repeat unfold 15 {d4 e f g}
+    }
+  }
 }
 
index a54a87efbc3c31e6cf07f1af9902038122439d10..ba352e5b84032a315795f68643fcdd3e52d10299 100644 (file)
@@ -11,6 +11,7 @@
 #include "international.hh"
 #include "item.hh"
 #include "output-def.hh"
+#include "paper-column.hh"
 #include "pitch.hh"
 #include "stencil.hh"
 
@@ -49,6 +50,21 @@ Accidental_interface::after_line_breaking (SCM smob)
   return SCM_UNSPECIFIED;
 }
 
+MAKE_SCHEME_CALLBACK (Accidental_interface, pure_height, 3);
+SCM
+Accidental_interface::pure_height (SCM smob, SCM start_scm, SCM)
+{
+  Item *me = dynamic_cast<Item*> (unsmob_grob (smob));
+  int start = scm_to_int (start_scm);
+  int rank = me->get_column ()->get_rank ();
+
+  bool visible = to_boolean (me->get_property ("forced"))
+    || !unsmob_grob (me->get_object ("tie"))
+    || rank != start + 1; /* we are in the middle of a line */
+
+  return visible ? Grob::stencil_height (smob) : ly_interval2scm (Interval ());
+}
+
 vector<Box>
 Accidental_interface::accurate_boxes (Grob *me, Grob **common)
 {
index 0591ab115f6cc6ac8ed0ffddb2960141c4e77695..0738e80869fa17a73063d7f8cc033979834f2990 100644 (file)
@@ -429,11 +429,21 @@ Grob::extent (Grob *refp, Axis a) const
 Interval
 Grob::pure_height (Grob *refp, int start, int end)
 {
-  SCM proc = get_property_data ( ly_symbol2scm ("Y-extent"));
-  Interval iv = robust_scm2interval (call_pure_function (proc,
-                                                        scm_list_1 (self_scm ()),
-                                                        start, end),
-                                    Interval (0, 0));
+  SCM proc = get_property_data (ly_symbol2scm ("Y-extent"));
+  SCM pure_proc = get_property_data (ly_symbol2scm ("pure-Y-extent"));
+  SCM iv_scm;
+
+  if (ly_is_procedure (pure_proc))
+    iv_scm = scm_apply_3 (pure_proc,
+                         self_scm (),
+                         scm_from_int (start),
+                         scm_from_int (end), SCM_EOL);
+  else
+    iv_scm = call_pure_function (proc,
+                                scm_list_1 (self_scm ()),
+                                start, end);
+  
+  Interval iv = robust_scm2interval (iv_scm, Interval (0, 0));
   Real offset = pure_relative_y_coordinate (refp, start, end);
 
   SCM min_ext = get_property ("minimum-Y-extent");
@@ -635,6 +645,7 @@ ADD_INTERFACE (Grob,
               "outside-staff-horizontal-padding "
               "outside-staff-padding "
               "outside-staff-priority "
+              "pure-Y-extent "
               "rotation "
               "springs-and-rods "
               "staff-symbol "
index 13646895e63443e91477fcdcb2ff6910505ad292..2a2888c20affe6498d0165b3e30e66e31e11281d 100644 (file)
@@ -21,6 +21,7 @@ public:
   DECLARE_SCHEME_CALLBACK (print, (SCM));
   DECLARE_SCHEME_CALLBACK (calc_stencils, (SCM));
   DECLARE_SCHEME_CALLBACK (after_line_breaking, (SCM));
+  DECLARE_SCHEME_CALLBACK (pure_height, (SCM, SCM, SCM));
   
   DECLARE_GROB_INTERFACE();
   static string get_fontcharname (string style, int alteration);
index 911e83467b6ff0a7bad8a58fa0a4daf16f481d66..e4739291a7b784ef3500f5d3cc6a851434403010 100644 (file)
@@ -53,7 +53,7 @@ Page_turn_page_breaking::put_systems_on_pages (vsize start,
   /* If [START, END] does not contain an intermediate
      breakpoint, we may need to consider solutions that result in a bad turn.
      In this case, we won't abort if the min_page_count is too big */
-  if (start < end - 1 && min_p_count > 2)
+  if (start < end - 1 && min_p_count + (page_number % 2) > 2)
     return Break_node ();
 
   /* if PAGE-NUMBER is odd, we are starting on a right hand page. That is, we
@@ -115,7 +115,7 @@ vsize
 Page_turn_page_breaking::final_page_num (Break_node const &b)
 {
   vsize end = b.first_page_number_ + b.page_count_;
-  return end + 1 - (end % 2);
+  return end - 1 + (end % 2);
 }
 
 void
@@ -171,7 +171,7 @@ Page_turn_page_breaking::calc_subproblem (vsize ending_breakpoint)
               cur = put_systems_on_pages (start, end, line, div[d], p_num);
 
               if (isinf (cur.demerits_)
-                 || (cur.page_count_ > 2
+                 || (cur.page_count_  + (p_num % 2) > 2
                      && (!isinf (this_start_best.demerits_))
                      && final_page_num (cur) > final_page_num (this_start_best)))
                 {
index 35ed14771297a1a667ac22895fcd93856b9b5cf9..d3270748bbfa28263ee66322d2ce502ffa7df8aa 100644 (file)
@@ -23,6 +23,7 @@
        (glyph-name-alist . ,standard-alteration-glyph-name-alist)
        (alteration . ,accidental-interface::calc-alteration) 
        (stencil . ,ly:accidental-interface::print)
+       (pure-Y-extent . ,ly:accidental-interface::pure-height)
        (after-line-breaking
         . ,ly:accidental-interface::after-line-breaking)
        (meta . ((class . Item)
@@ -35,6 +36,7 @@
        (glyph-name-alist . ,standard-alteration-glyph-name-alist)
        (alteration . ,accidental-interface::calc-alteration) 
        (stencil . ,ly:accidental-interface::print)
+       (pure-Y-extent . ,ly:accidental-interface::pure-height)
        (after-line-breaking
         . ,ly:accidental-interface::after-line-breaking)
        (meta . ((class . Item)
        (X-offset . ,ly:side-position-interface::x-aligned-side)
        (direction . ,LEFT)
        (stencil . ,ly:accidental-interface::print)
+       (pure-Y-extent . ,ly:accidental-interface::pure-height)
        (glyph-name-alist . ,standard-alteration-glyph-name-alist)      
        (after-line-breaking . ,ly:accidental-interface::after-line-breaking)
        (side-axis . ,X)