]> git.donarmstrong.com Git - lilypond.git/commitdiff
Revert "line_count fixes"
authorKeith OHara <k-ohara5a5a@oco.net>
Sat, 14 Jul 2012 17:19:41 +0000 (10:19 -0700)
committerKeith OHara <k-ohara5a5a@oco.net>
Sat, 14 Jul 2012 17:19:41 +0000 (10:19 -0700)
This reverts commit 2a872121379fffe7b1cd5d23048b7ea04b4d1f68.

14 files changed:
input/regression/ledger-lines-varying-staves.ly
input/regression/non-centered-bar-lines.ly
input/regression/staff-ledger-positions.ly
input/regression/staff-line-positions.ly
input/regression/zero-staff-space.ly
lily/bar-line.cc
lily/beam.cc
lily/breathing-sign.cc
lily/custos.cc
lily/rest-collision.cc
lily/rest.cc
lily/slur-scoring.cc
lily/time-signature.cc
lily/vaticana-ligature.cc

index 2f8db819a1ee4b3a94f433ed2c7e1e6dcbf666c7..e037de7f79d76f4773f754c2e6cc34826183567d 100644 (file)
@@ -7,9 +7,9 @@ for a variety of staves using both @code{line-count} and
 
 notes = \relative c' {
   \time 3/4
-  c2. | d | e | f \bar ":|"
-  g2. | a | b | c \bar "|:"
-  d2. | e | f | g \bar ":|:"
+  c2. | d | e | f
+  g2. | a | b | c
+  d2. | e | f | g
   a2.
 }
 
index f12fb9850361f374cc7076c5c889351c09021427..429fc419151cea0697f95e009f0d746b351516f3 100644 (file)
@@ -8,6 +8,5 @@ staves which are not centered around position@tie{}0.
   \override Staff.StaffSymbol #'line-positions = #'(1 3 5 7 9)
   c''1 \bar "||"
   c''1 \bar ":"
-  c''1 \bar ":|"
   c''1 \bar "|."
 }
index 7cf8fb000d80666c0cff9649e176c02a7bb56173..67233d1060682ac63e7f557eb87178109f8ea711 100644 (file)
@@ -13,5 +13,5 @@ later by setting the @code{ledger-extra} property."
   \override Staff.StaffSymbol #'line-positions = #'(-5 -2 -1 2 5 6)
   \override Staff.StaffSymbol #'ledger-positions = #'(-5 (-2 -1) 2)
   \override Staff.StaffSymbol #'ledger-extra = #1
-  g,4 c e b' \bar ":|" c'' e g
+  g,4 c e b' c'' e g
 }
index 1e3ee81be18e8183a5009cc4240eed5add4e435c..0b801a87441113b5eb75d7a117938226dfb8041f 100644 (file)
@@ -11,5 +11,7 @@
 
 \new Staff \relative c'  {
   \override Staff.StaffSymbol #'line-positions = #'(-7 -2 0 3 9)
-  g c f b \bar ":|" e a
+  g c f b e a
 }
+  
+  
index fc1c162c065aa3eafaffa0cdb16b6fff8b93de00..62e2e16bc9397d30801a09d3c26e9b4ef078fbb7 100644 (file)
@@ -10,6 +10,6 @@ Setting staff-space to 0 does not cause a segmentation fault.
   \override StaffSymbol #'staff-space = #0
   } {
   \relative c' {
-    c1 \bar ":|"
+    c1
   }
 }
index 7da72ba3216c27a47d682b0ee39ebb6c85b4e7c2..0cd0339235b41c307459670210ea35c27f69d66d 100644 (file)
 #include "lookup.hh"
 #include "output-def.hh"
 #include "paper-column.hh"
-#include "staff-symbol.hh"
 #include "staff-symbol-referencer.hh"
 
-#include <set>
-
-
 MAKE_SCHEME_CALLBACK (Bar_line, calc_bar_extent, 1)
 SCM
 Bar_line::calc_bar_extent (SCM smob)
@@ -116,62 +112,15 @@ Bar_line::compound_barline (Grob *me, string str, Interval const &extent,
   Stencil thick = simple_barline (me, fatline, extent, rounded);
   Stencil dot = Font_interface::get_default_font (me)->find_by_name ("dots.dot");
 
-  /*
-    the two dots of the repeat sign should be centred at the middle of
-    the staff and both should avoid staff lines
-  */
-  Real centre = 0.0, dist = 1.0;
-  if (staff_space)
-    {
-      if (Grob *staff = Staff_symbol_referencer::get_staff_symbol (me))
-        {
-          std::vector<Real> linepos = Staff_symbol::line_positions (staff);
-          if (!linepos.empty ())
-            {
-              centre = Staff_symbol::line_span (staff).center ();
-
-              /*
-                fold the staff into two at centre and find the first gap
-                big enough to hold a dot and some space below and above
-              */
-              std::set<Real> half_staff;
-              half_staff.insert (0.0);
-              for (std::vector<Real>::const_iterator
-                     i = linepos.begin (), e = linepos.end ();
-                   i != e;
-                   ++i)
-                half_staff.insert (fabs (*i - centre));
-
-              /*
-                gap is measured like line-positions;
-                1.0 for dot diameter, twice the staffline width for the
-                gap above and below and one more staffline width for the
-                two half stafflines
-              */
-              Real const gap_to_find = (1.0 + 3 * staffline) / staff_space;
-              dist = *half_staff.rbegin () * 2 + gap_to_find;
-              for (std::set<Real>::const_iterator
-                     i0 = half_staff.begin (), i1 = i0, e = half_staff.end ();
-                   ++i1 != e;
-                   i0 = i1)
-                if (*i1 - *i0 > gap_to_find)
-                  {
-                    dist = *i0 + *i1;
-                    break;
-                  }
-            }
-        }
-    }
-  else
-    dist += 3 * staffline;
-
-  if (staff_space == 0.0)
-    staff_space = 1.0;
-
+  int lines = Staff_symbol_referencer::line_count (me);
+  Real dist
+    = ((lines & 1 || lines == 0)
+       ? 1
+       : (staff_space < 2 ? 2 : .5)) * staff_space;
   Stencil colon (dot);
-  colon.translate_axis (dist * staff_space / 2, Y_AXIS);
+  colon.translate_axis (dist, Y_AXIS);
   colon.add_stencil (dot);
-  colon.translate_axis ((centre - dist / 2) * staff_space / 2, Y_AXIS);
+  colon.translate_axis (-dist / 2, Y_AXIS);
 
   Real const h = extent.length ();
   Stencil m;
index d73169a917181d046e8dfc50f9bd9cbc40b9d112..49253434c05d94faab4e471b44cc42898841f1e9 100644 (file)
@@ -675,7 +675,7 @@ Beam::print (SCM grob)
 
       // we need two translations: the normal one and
       // the one of the lowest segment
-      size_t idx[] = {i, extreme};
+      int idx[] = {i, extreme};
       Real translations[2];
 
       for (int j = 0; j < 2; j++)
@@ -1274,16 +1274,16 @@ Beam::rest_collision_callback (SCM smob, SCM prev_offset)
   Real shift = d * min (d * (beam_y - d * minimum_distance - rest_dim), 0.0);
 
   shift /= staff_space;
+  Real rad = Staff_symbol_referencer::line_count (rest) * staff_space / 2;
 
   /* Always move discretely by half spaces */
   shift = ceil (fabs (shift * 2.0)) / 2.0 * sign (shift);
 
-  Interval staff_span = Staff_symbol_referencer::staff_span (rest);
-  staff_span *= staff_space / 2;
-
   /* Inside staff, move by whole spaces*/
-  if (staff_span.contains (rest_extent[d] + staff_space * shift)
-      || staff_span.contains (rest_extent[-d] + staff_space * shift))
+  if ((rest_extent[d] + staff_space * shift) * d
+      < rad
+      || (rest_extent[-d] + staff_space * shift) * -d
+      < rad)
     shift = ceil (fabs (shift)) * sign (shift);
 
   return scm_from_double (offset + staff_space * shift);
index 02b29858af1465d042c0c16d6f57c967e82f0f27..a3d9637bef6d2d2e3685c8b23334b97b49804e13 100644 (file)
@@ -81,19 +81,13 @@ Breathing_sign::divisio_maior (SCM smob)
    * more than half the size of the staff, such that the endings of
    * the line are in the middle of a staff space.
    */
-  Interval ydim = Staff_symbol_referencer::staff_span (me);
-  ydim.widen (-0.25 * ydim.delta ());
-  for (UP_and_DOWN (i))
-    {
-      int const int_dim = (int) ydim[i];
-      if (int_dim == ydim[i]
-          && Staff_symbol_referencer::on_staff_line (me, int_dim))
-        ydim[i] += i;
-    }
-
-  ydim *= 1.0 / Staff_symbol_referencer::staff_space (me);
+  int lines = Staff_symbol_referencer::line_count (me);
+  int height = lines / 2; // little more than half of staff size
+  if ((lines & 1) != (height & 1))
+    height++; // ensure endings are centered in staff space
 
   Interval xdim (0, thickness);
+  Interval ydim (-0.5 * height, +0.5 * height);
   Box b (xdim, ydim);
   Stencil out = Lookup::round_filled_box (b, blotdiameter);
   return out.smobbed_copy ();
@@ -108,15 +102,20 @@ Breathing_sign::divisio_maxima (SCM smob)
 {
   Grob *me = unsmob_grob (smob);
   Real staff_space = Staff_symbol_referencer::staff_space (me);
+  Real staff_size;
   Real thickness = Staff_symbol_referencer::line_thickness (me);
   thickness *= robust_scm2double (me->get_property ("thickness"), 1.0);
 
+  if (Staff_symbol_referencer::get_staff_symbol (me))
+    staff_size = (Staff_symbol_referencer::line_count (me) - 1) * staff_space;
+  else
+    staff_size = 0.0;
+
   Real blotdiameter = me->layout ()->get_dimension (ly_symbol2scm ("blot-diameter"));
 
   // like a "|" type bar
   Interval xdim (0, thickness);
-  Interval ydim = Staff_symbol_referencer::staff_span (me);
-  ydim *= staff_space / 2;
+  Interval ydim (-0.5 * staff_size, +0.5 * staff_size);
   Box b (xdim, ydim);
   Stencil out = Lookup::round_filled_box (b, blotdiameter);
   return out.smobbed_copy ();
@@ -131,15 +130,20 @@ Breathing_sign::finalis (SCM smob)
 {
   Grob *me = unsmob_grob (smob);
   Real staff_space = Staff_symbol_referencer::staff_space (me);
+  Real staff_size;
   Real thickness = Staff_symbol_referencer::line_thickness (me);
   thickness *= robust_scm2double (me->get_property ("thickness"), 1.0);
 
+  if (Staff_symbol_referencer::get_staff_symbol (me))
+    staff_size = (Staff_symbol_referencer::line_count (me) - 1) * staff_space;
+  else
+    staff_size = 0.0;
+
   Real blotdiameter = me->layout ()->get_dimension (ly_symbol2scm ("blot-diameter"));
 
   // like a "||" type bar
   Interval xdim (0, thickness);
-  Interval ydim = Staff_symbol_referencer::staff_span (me);
-  ydim *= staff_space / 2;
+  Interval ydim (-0.5 * staff_size, +0.5 * staff_size);
   Box b (xdim, ydim);
   Stencil line1 = Lookup::round_filled_box (b, blotdiameter);
   Stencil line2 (line1);
index 1366202f725013905fb37844b874628bec5e3bf0..00da1d53d1bfee2288287e082d2c5523a641121b 100644 (file)
@@ -62,6 +62,7 @@ Custos::print (SCM smob)
     = to_dir (me->get_property ("neutral-direction"));
 
   int pos = Staff_symbol_referencer::get_rounded_position (me);
+  int sz = Staff_symbol_referencer::line_count (me) - 1;
 
   string font_char = "custodes." + style + ".";
   if (pos < neutral_pos)
@@ -76,7 +77,7 @@ Custos::print (SCM smob)
     font_char += "d";
 
   if (adjust)
-    font_char += Staff_symbol_referencer::on_line (me, pos) ? "1" : "0";
+    font_char += (((pos ^ sz) & 0x1) == 0) ? "1" : "0";
   else
     font_char += "2";
 
index 0e7a01c5a7a204ec05f51f38cf0cd4af9a294884..8ba647e2019d8201d3698dbaa39cdd74f6671e90 100644 (file)
@@ -250,14 +250,19 @@ Rest_collision::calc_positioning_done (SCM smob)
           Real y = dir * max (0.0,
                               -dir * restdim[-dir] + dir * notedim[dir] + minimum_dist);
 
+          int stafflines = Staff_symbol_referencer::line_count (me);
+          if (!stafflines)
+            {
+              programming_error ("no staff line count");
+              stafflines = 5;
+            }
+
           // move discretely by half spaces.
           int discrete_y = dir * int (ceil (y / (0.5 * dir * staff_space)));
 
-          Interval staff_span = Staff_symbol_referencer::staff_span (rest);
-          staff_span.widen (1);
           // move by whole spaces inside the staff.
-          if (staff_span.contains
-              (Staff_symbol_referencer::get_position (rest) + discrete_y))
+          if (fabs (Staff_symbol_referencer::get_position (rest)
+                    + discrete_y) < stafflines + 1)
             {
               discrete_y = dir * int (ceil (dir * discrete_y / 2.0) * 2.0);
             }
index 8e45405de278dbd4ea5040dfc3259c6a2164a112..9057e45af1bd90deaf29c0419ac2a2b2233ee8a9 100644 (file)
@@ -37,6 +37,7 @@ Rest::y_offset_callback (SCM smob)
 {
   Grob *me = unsmob_grob (smob);
   int duration_log = scm_to_int (me->get_property ("duration-log"));
+  int line_count = Staff_symbol_referencer::line_count (me);
   Real ss = Staff_symbol_referencer::staff_space (me);
 
   bool position_override = scm_is_number (me->get_property ("staff-position"));
@@ -68,7 +69,7 @@ Rest::y_offset_callback (SCM smob)
         make a semibreve rest hang from the next line,
         except for a single line staff
       */
-      if (duration_log == 0 && Staff_symbol_referencer::line_count (me) > 1)
+      if (duration_log == 0 && line_count > 1)
         pos += 2;
 
       /*
index e1025fa545c56c1c20ee0a476355b778229cf336..d8b713265c7e79e60300bf25c8870ff5616b8a9f 100644 (file)
@@ -595,7 +595,8 @@ Slur_score_state::move_away_from_staffline (Real y,
       * 2.0 / staff_space_;
 
   if (fabs (pos - my_round (pos)) < 0.2
-      && Staff_symbol_referencer::on_staff_line (on_staff, (int) rint (pos)))
+      && Staff_symbol_referencer::on_line (on_staff, (int) rint (pos))
+      && Staff_symbol_referencer::line_count (on_staff) - 1 >= rint (pos))
     y += 1.5 * staff_space_ * dir_ / 10;
 
   return y;
index 082b62a93c0f45bd0d7f786fd4808e22dde1496b..ad553e4229268800e94763b3d81de959213272c2 100644 (file)
@@ -23,7 +23,6 @@
 #include "font-interface.hh"
 #include "international.hh"
 #include "output-def.hh"
-#include "staff-symbol.hh"
 #include "staff-symbol-referencer.hh"
 #include "text-interface.hh"
 #include "warn.hh"
@@ -58,35 +57,8 @@ Time_signature::print (SCM smob)
   else
     m = numbered_time_signature (me, n, d);
 
-  /*
-    position the signature centred on the staff line
-    nearest to the middle of the staff
-  */
-  if (Grob *staff = Staff_symbol_referencer::get_staff_symbol (me))
-    {
-      std::vector<Real> const linepos = Staff_symbol::line_positions (staff);
-      if (!linepos.empty ())
-        {
-          Interval const span = Staff_symbol::line_span (staff);
-          Real const mid = span.center ();
-          Real pos = linepos.front ();
-          Real dist = fabs (pos - mid);
-          for (std::vector<Real>::const_iterator
-                 i = linepos.begin (), e = linepos.end ();
-               ++i != e;)
-            {
-              double const d = fabs (*i - mid);
-              if (d < dist)
-                {
-                  pos = *i;
-                  dist = d;
-                }
-            }
-
-          m.translate_axis
-            (pos * Staff_symbol_referencer::staff_space (me) / 2, Y_AXIS);
-        }
-    }
+  if (Staff_symbol_referencer::line_count (me) % 2 == 0)
+    m.translate_axis (Staff_symbol_referencer::staff_space (me) / 2, Y_AXIS);
 
   return m.smobbed_copy ();
 }
index deb0218bd08ebe92a4e710efe9f00979ed0c7862..7420db3ec1bbaffc8e0d8af5825ac9e6fe4250fd 100644 (file)
@@ -37,7 +37,8 @@ vaticana_brew_cauda (Grob *me,
                      Real blotdiameter)
 {
   bool on_staffline = Staff_symbol_referencer::on_line (me, pos);
-  bool above_staff = pos > Staff_symbol_referencer::staff_span (me)[UP];
+  int interspaces = Staff_symbol_referencer::line_count (me) - 1;
+  bool above_staff = pos > interspaces;
 
   if (delta_pitch > -1)
     {