lilypond-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: page-breaking: allow ragged pages to be compressed; issue 3281 (issu


From: k-ohara5a5a
Subject: Re: page-breaking: allow ragged pages to be compressed; issue 3281 (issue 25710043)
Date: Thu, 14 Nov 2013 21:48:26 +0000

Reviewers: lemzwerg,


https://codereview.appspot.com/25710043/diff/40001/Documentation/notation/spacing.itely
File Documentation/notation/spacing.itely (right):

https://codereview.appspot.com/25710043/diff/40001/Documentation/notation/spacing.itely#newcode411
Documentation/notation/spacing.itely:411:
On 2013/11/14 05:49:28, lemzwerg wrote:
Reading this it's not clear to me whether you have to use this flag in
addition
to `ragged-bottom' and `ragged-last-bottom', or whether this overrides
the other
two flags.

This flag controls how many systems fit on a ragged-bottom page, with
the old flags determining which pages have ragged bottoms.  It does not
override the old flags.

If I see an example of how the old rule against compressing
ragged-bottom pages can be useful, I'll try to work it into a regression
test.  If I do not, I will remove this flag, simplifying the code.

https://codereview.appspot.com/25710043/diff/40001/lily/page-breaking.cc
File lily/page-breaking.cc (right):

https://codereview.appspot.com/25710043/diff/40001/lily/page-breaking.cc#newcode1503
lily/page-breaking.cc:1503: Real ragged_compress_force = rigid () ?
infinity_f : 0.0;
Oops, we need to fall-back to the natural force on the page, not 0.0.

Description:
page-breaking: allow ragged pages to be compressed; issue 3281

Please review this at https://codereview.appspot.com/25710043/

Affected files (+39, -18 lines):
  M Documentation/notation/spacing.itely
  M lily/include/page-breaking.hh
  M lily/include/page-spacing.hh
  M lily/page-breaking.cc
  M lily/page-layout-problem.cc
  M lily/page-spacing.cc


Index: Documentation/notation/spacing.itely
diff --git a/Documentation/notation/spacing.itely b/Documentation/notation/spacing.itely index 9aa7224320d0d6f943e7cddbb244d56160211d5c..7b5bd176d74168cacada752f5e8e7d2a0a0a8fbe 100644
--- a/Documentation/notation/spacing.itely
+++ b/Documentation/notation/spacing.itely
@@ -391,18 +391,23 @@ default value is scaled accordingly.
 @funindex ragged-bottom

 If set to true, systems will not spread vertically down the page.
-This does not affect the last page.  This should be set to true
-for pieces that have only two or three systems per page, for
-example orchestral scores.
+This does not affect the last page.  Setting this to true could
+be desirable for pieces that have only two or three systems per page,
+for example orchestral scores.

 @item ragged-last-bottom
 @funindex ragged-last-bottom

 If set to false, systems will spread vertically down the last
-page.  Pieces that amply fill two pages or more should have this
-set to false.  It also affects the last page of book parts, i.e.
+page.  It also affects the last page of book parts, i.e.
 parts of a book created with @code{\bookpart} blocks.

address@hidden ragged-bottom-rigid-spacing
address@hidden ragged-bottom-rigid-spacing
+
+If set to true, ragged-bottom pages refuse to be compressed,
+pushing systems onto the next page as required.
+
 @end table

 @seealso
@@ -1518,9 +1523,9 @@ inserted at top-level, between scores and top-level markups.

 There are also analogous settings to @code{ragged-right} and
 @code{ragged-last} which have the same effect on vertical spacing:
address@hidden and @code{ragged-last-bottom}.  If set to
address@hidden the systems on all pages or just the last page
-respectively will not be justified vertically.  See
address@hidden for all pages, and @code{ragged-last-bottom}
+for just the final page.  When these are set to @code{#t} empty space
+is allowed at the bottom of the page.  See
@ref{Fixed vertical spacing paper variables,,Fixed vertical spacing @address@hidden variables}.

 Page breaks are computed by the @code{page-breaking} function.  LilyPond
Index: lily/include/page-breaking.hh
diff --git a/lily/include/page-breaking.hh b/lily/include/page-breaking.hh
index c84a56e67902eddad5d9314cb844f2ff6cf84884..723bd324a7d71b1f199be7184647f445af0693aa 100644
--- a/lily/include/page-breaking.hh
+++ b/lily/include/page-breaking.hh
@@ -115,6 +115,7 @@ public:
   virtual ~Page_breaking ();

   bool ragged () const;
+  bool rigid () const;
   bool ragged_last () const;
   bool is_last () const;
   bool ends_score () const;
@@ -186,6 +187,7 @@ private:
   vector<Constrained_breaking> line_breaking_;
   bool ragged_;
   bool ragged_last_;
+  bool rigid_;
   int systems_per_page_;
   int max_systems_per_page_;
   int min_systems_per_page_;
Index: lily/include/page-spacing.hh
diff --git a/lily/include/page-spacing.hh b/lily/include/page-spacing.hh
index 8f524537bd5a5373fe0800efa4f4167f8f2beac2..c2e10c0b2e2bc28d7e84ccc3bf9bc3f4df7aff36 100644
--- a/lily/include/page-spacing.hh
+++ b/lily/include/page-spacing.hh
@@ -89,6 +89,7 @@ private:

   bool ragged_;
   bool ragged_last_;
+  bool rigid_;

   void resize (vsize page_count);
   bool calc_subproblem (vsize page, vsize lines);
Index: lily/page-breaking.cc
diff --git a/lily/page-breaking.cc b/lily/page-breaking.cc
index 9a6f8f40f25c0edbe47f45ecde1780c2babc89b6..7f5b4c436b9ef6d1b28c5b2788fc03dedee6f8e5 100644
--- a/lily/page-breaking.cc
+++ b/lily/page-breaking.cc
@@ -249,6 +249,7 @@ Page_breaking::Page_breaking (Paper_book *pb, Break_predicate is_break, Prob_bre paper_height_ = robust_scm2double (pb->paper_->c_variable ("paper-height"), 1.0);
   ragged_ = to_boolean (pb->paper_->c_variable ("ragged-bottom"));
ragged_last_ = to_boolean (pb->paper_->c_variable ("ragged-last-bottom")); + rigid_ = to_boolean (pb->paper_->c_variable ("ragged-bottom-rigid-spacing")); systems_per_page_ = max (0, robust_scm2int (pb->paper_->c_variable ("systems-per-page"), 0)); max_systems_per_page_ = max (0, robust_scm2int (pb->paper_->c_variable ("max-systems-per-page"), 0)); min_systems_per_page_ = max (0, robust_scm2int (pb->paper_->c_variable ("min-systems-per-page"), 0));
@@ -303,6 +304,12 @@ Page_breaking::ragged_last () const
   return ragged_last_;
 }

+bool
+Page_breaking::rigid () const
+{
+  return rigid_;
+}
+
 int
 Page_breaking::systems_per_page () const
 {
@@ -632,7 +639,10 @@ Page_breaking::make_pages (vector<vsize> lines_per_page, SCM systems)
       else
         config = layout.solution (rag);

-      last_page_force = layout.force ();
+      if (rag && rigid () && layout.force () < 0.0)
+ warning (_ ("cannot fit music on page: ragged-spacing was requested, but page was compressed"));
+      else
+        last_page_force = layout.force ();

systems_configs_fncounts = scm_cons (scm_cons (lines, config), systems_configs_fncounts);
       footnote_count += fn_lines;
@@ -1124,7 +1134,7 @@ Page_breaking::min_page_count (vsize configuration, vsize first_page_num)
       Real spring_len = (i > 0) ? prev->spring_length (cur) : 0;
       Real next_rod_height = cur_rod_height + ext_len;
       Real next_spring_height = cur_spring_height + spring_len;
- Real next_height = next_rod_height + (ragged () ? next_spring_height : 0) + Real next_height = next_rod_height + (rigid () ? next_spring_height : 0)
                          + min_whitespace_at_bottom_of_page (cur);
int next_line_count = line_count + cur.compressed_nontitle_lines_count_;

@@ -1169,7 +1179,7 @@ Page_breaking::min_page_count (vsize configuration, vsize first_page_num) cur_page_height -= min_whitespace_at_top_of_page (cached_line_details_[page_starter]); cur_page_height -= min_whitespace_at_bottom_of_page (cached_line_details_.back ());

- Real cur_height = cur_rod_height + ((ragged_last () || ragged ()) ? cur_spring_height : 0); + Real cur_height = cur_rod_height + (rigid () ? cur_spring_height : 0); if (!too_few_lines (line_count - cached_line_details_.back ().compressed_nontitle_lines_count_)
           && cur_height > cur_page_height
/* don't increase the page count if the last page had only one system */ @@ -1541,13 +1551,17 @@ Page_breaking::space_systems_on_2_pages (vsize configuration, vsize first_page_n page1_line_count += cached_line_details_[i].compressed_nontitle_lines_count_; page2_line_count += cached_line_details_[cached_line_details_.size () - 1 - i].compressed_nontitle_lines_count_;

- page1_force[i] = (ragged1 && page1.force_ < 0 && i > 0) ? infinity_f : page1.force_;
+      page1_force[i] = (ragged1 && rigid () && page1.force_ < 0 && i > 0)
+                       ? infinity_f : page1.force_;
       page1_penalty[i] = line_count_penalty (page1_line_count);
       page1_status[i] = line_count_status (page1_line_count);

       if (ragged2)
-        page2_force[page2_force.size () - 1 - i]
- = (page2.force_ < 0 && i + 1 < page1_force.size ()) ? infinity_f : 0;
+        if (page2.force_ < 0 && i + 1 < page1_force.size ())
+          page2_force[page2_force.size () - 1 - i]
+            = rigid () ? infinity_f : page2.force_;
+        else
+          page2_force[page2_force.size () - 1 - i] = 0.0;
       else
         page2_force[page2_force.size () - 1 - i] = page2.force_;
page2_penalty[page2_penalty.size () - 1 - i] = line_count_penalty (page2_line_count);
Index: lily/page-layout-problem.cc
diff --git a/lily/page-layout-problem.cc b/lily/page-layout-problem.cc
index 5885a661359b6accd9055228bd11b10cf8f19f88..92325c04669d60458773270a02bd82e2be00c14a 100644
--- a/lily/page-layout-problem.cc
+++ b/lily/page-layout-problem.cc
@@ -727,9 +727,7 @@ Page_layout_problem::solve_rod_spring_problem (bool ragged, Real fixed_force)
     {
       Real overflow = spacer.configuration_length (spacer.force ())
                       - page_height_;
-      if (ragged && overflow < 1e-6)
- warning (_ ("cannot fit music on page: ragged-spacing was requested, but page was compressed"));
-      else
+      if (overflow > 1e-6)
         {
           warning (_f ("cannot fit music on page: overflow is %f",
                        overflow));
Index: lily/page-spacing.cc
diff --git a/lily/page-spacing.cc b/lily/page-spacing.cc
index a705827d2274df700b56503bc8b60bb06d58dcb8..26c0fe164ace48772d8446af4a0dd4bff63fa145 100644
--- a/lily/page-spacing.cc
+++ b/lily/page-spacing.cc
@@ -142,6 +142,7 @@ Page_spacer::Page_spacer (vector<Line_details> const &lines, vsize first_page_nu
   max_page_count_ = 0;
   ragged_ = breaker->ragged ();
   ragged_last_ = breaker->is_last () && breaker->ragged_last ();
+  rigid_ = breaker->rigid ();
 }

 Page_spacing_result
@@ -329,7 +330,7 @@ Page_spacer::calc_subproblem (vsize page, vsize line)
       space.prepend_system (lines_[page_start]);

       bool overfull = (space.rod_height_ > paper_height
-                       || (ragged
+                       || (ragged && rigid_
&& (space.rod_height_ + space.spring_len_ > paper_height))); // This 'if' statement is a little hard to parse. It won't consider this configuration // if it is overfull unless the current configuration is the first one with this start





reply via email to

[Prev in Thread] Current Thread [Next in Thread]