lilypond-devel
[Top][All Lists]
Advanced

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

Re: Loose-lines honor padding between systems (issue4553060)


From: k-ohara5a5a
Subject: Re: Loose-lines honor padding between systems (issue4553060)
Date: Wed, 25 May 2011 04:49:26 +0000

Reviewers: Trevor Daniels, joeneeman,

Message:
Thanks for comments.
I'll wait one more day before I push.

Description:
Loose-lines honor padding between systems

When placing a loose line (e.g. Lyrics) at the top or bottom of a
system, include as a constraint the padding to the neighboring
system or markup.  Fix 1654.

Please review this at http://codereview.appspot.com/4553060/

Affected files:
  A input/regression/page-spacing-nonstaff-lines-between-2.ly
  M lily/include/page-layout-problem.hh
  M lily/page-layout-problem.cc


Index: input/regression/page-spacing-nonstaff-lines-between-2.ly
diff --git a/input/regression/page-spacing-nonstaff-lines-between-2.ly b/input/regression/page-spacing-nonstaff-lines-between-2.ly
new file mode 100644
index 0000000000000000000000000000000000000000..4767f6a975059f5b68b61a16bd413fcd13f54ece
--- /dev/null
+++ b/input/regression/page-spacing-nonstaff-lines-between-2.ly
@@ -0,0 +1,33 @@
+\version "2.13.62"
+
+\header {
+  texidoc = "Non-staff lines between two systems are separated by
+  @code{system-system-spacing} @code{padding}."
+}
+
+\paper {
+  ragged-right = ##t
+  system-system-spacing #'padding = 2
+  annotate-spacing = ##t
+}
+
+<<
+  \new Lyrics
+  \with {
+    \override VerticalAxisGroup #'staff-affinity = #DOWN
+    \override VerticalAxisGroup
+      #'nonstaff-relatedstaff-spacing #'basic-distance = 6
+  }
+  \lyricmode {
+    My2 first Li4 -- ly song,2
+    My2 first Li4 -- ly song,2
+  }
+  \context Voice = "voice" \relative c' {
+    d2 d c4 bes a2 \break
+    d'2 d c4 bes a2
+  }
+  \new Lyrics \lyricmode {
+    Not2 much can4 go wrong!2
+    Not2 much can4 go wrong!2
+  }
+>>
Index: lily/include/page-layout-problem.hh
diff --git a/lily/include/page-layout-problem.hh b/lily/include/page-layout-problem.hh index fb1c7c373d4a1ad72252f8ebd2c4b8294aeeb7d0..ff6fcece22c154be7ae5e9d66c747dc2bf5a06c1 100644
--- a/lily/include/page-layout-problem.hh
+++ b/lily/include/page-layout-problem.hh
@@ -57,17 +57,22 @@ protected:
     Prob *prob;
     vector<Grob*> staves;
     vector<Real> min_offsets;
+    // Store the appropriate '*-*-spacing 'padding,
+    //  for spacing any adjacent loose line
+    Real padding;

-    Element (vector<Grob*> const& a, vector<Real> const& o)
+    Element (vector<Grob*> const& a, vector<Real> const& o, Real p)
     {
       staves = a;
       min_offsets = o;
+      padding = p;
       prob = 0;
     }

-    Element (Prob *p)
+    Element (Prob *p, Real pad)
     {
       prob = p;
+      padding = pad;
     }
   } Element;

Index: lily/page-layout-problem.cc
diff --git a/lily/page-layout-problem.cc b/lily/page-layout-problem.cc
index fa4bd9c7b416f98aefc6f838b2b082888764ecd0..e47c7d27faf8b04ebf1c35726b128249a2e23031 100644
--- a/lily/page-layout-problem.cc
+++ b/lily/page-layout-problem.cc
@@ -312,7 +312,7 @@ Page_layout_problem::append_system (System *sys, Spring const& spring, Real inde
   springs_.push_back (spring_copy);

   bottom_skyline_ = down_skyline;
-  elements_.push_back (Element (elts, minimum_offsets));
+  elements_.push_back (Element (elts, minimum_offsets, padding));

   // Add the springs for the VerticalAxisGroups in this system.

@@ -398,7 +398,7 @@ Page_layout_problem::append_prob (Prob *prob, Spring const& spring, Real padding
     spring_copy.ensure_min_distance (minimum_distance + padding);

   springs_.push_back (spring_copy);
-  elements_.push_back (Element (prob));
+  elements_.push_back (Element (prob, padding));
 }

 void
@@ -462,7 +462,8 @@ Page_layout_problem::find_system_offsets ()
          if (loose_lines.size ())
            {
Interval loose_extent = loose_lines.back ()->extent (loose_lines.back (), Y_AXIS); - Real min_distance = -loose_extent[DOWN] + prob_extent[UP]; // TODO: include padding/minimum-distance
+             Real min_distance = (-loose_extent[DOWN] + prob_extent[UP]
+                                  + elements_[i].padding);

              loose_line_min_distances.push_back (min_distance);
              loose_lines.push_back (0);
@@ -513,7 +514,10 @@ Page_layout_problem::find_system_offsets ()
                  // the last one.
                  if (loose_lines.size ())
                    {
- loose_line_min_distances.push_back (min_offsets[staff_idx-1] - min_offsets[staff_idx]);
+                     if (staff_idx)
+ loose_line_min_distances.push_back (min_offsets[staff_idx-1] - min_offsets[staff_idx]);
+                     else
+ loose_line_min_distances.push_back (elements_[i].padding - min_offsets[staff_idx]);
                      loose_lines.push_back (staff);

                      distribute_loose_lines (loose_lines, 
loose_line_min_distances,
@@ -536,18 +540,20 @@ Page_layout_problem::find_system_offsets ()
                  if (staff_idx)
loose_line_min_distances.push_back (min_offsets[staff_idx-1] - min_offsets[staff_idx]);
                  else
-                   {
+                   { // this is the first line in a system
                      Real min_dist = 0;
                      if (loose_lines.back ())
-                       min_dist = Axis_group_interface::minimum_distance 
(loose_lines.back (),
-                                                                          
staff,
-                                                                          
Y_AXIS);
+                       // distance to the final line in the preceding system,
+                       // including 'system-system-spacing 'padding
+                       min_dist = (Axis_group_interface::minimum_distance 
(loose_lines.back (),
+                                                                           
staff,
+                                                                           
Y_AXIS)
+                                   + elements_[i].padding);
                      else if (!last_title_extent.is_empty ())
-                       { // distance to the preceding title
-                         // TODO: add options for controlling the space 
between a loose line
-                         // and a title/markup preceding it.
- min_dist = staff->extent (staff, Y_AXIS)[UP] - last_title_extent[DOWN];
-                       }
+                       // distance to the preceding title,
+                       //  including 'markup-system-spacing 'padding
+                       min_dist = (staff->extent (staff, Y_AXIS)[UP] - 
last_title_extent[DOWN]
+                                   + elements_[i].padding);
                      else // distance to the top margin
min_dist = header_padding_ + header_height_ + staff->extent (staff, Y_AXIS)[UP];






reply via email to

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