]> git.donarmstrong.com Git - lilypond.git/commitdiff
small changes of the line_count fixing series
authorBenkő Pál <benko.pal@gmail.com>
Sat, 21 Jul 2012 07:21:06 +0000 (09:21 +0200)
committerBenkő Pál <benko.pal@gmail.com>
Thu, 9 Aug 2012 19:42:11 +0000 (21:42 +0200)
- enhance support of non-standard staves by checking staff bounds or
being on staff line by juggling not line_count but staff_span or on_line
- eliminate an unnecessary call and a warning

lily/beam.cc
lily/breathing-sign.cc
lily/custos.cc
lily/rest-collision.cc
lily/rest.cc
lily/vaticana-ligature.cc

index 49253434c05d94faab4e471b44cc42898841f1e9..d73169a917181d046e8dfc50f9bd9cbc40b9d112 100644 (file)
@@ -675,7 +675,7 @@ Beam::print (SCM grob)
 
       // we need two translations: the normal one and
       // the one of the lowest segment
-      int idx[] = {i, extreme};
+      size_t 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 ((rest_extent[d] + staff_space * shift) * d
-      < rad
-      || (rest_extent[-d] + staff_space * shift) * -d
-      < rad)
+  if (staff_span.contains (rest_extent[d] + staff_space * shift)
+      || staff_span.contains (rest_extent[-d] + staff_space * shift))
     shift = ceil (fabs (shift)) * sign (shift);
 
   return scm_from_double (offset + staff_space * shift);
index a3d9637bef6d2d2e3685c8b23334b97b49804e13..02b29858af1465d042c0c16d6f57c967e82f0f27 100644 (file)
@@ -81,13 +81,19 @@ 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.
    */
-  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 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);
 
   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 ();
@@ -102,20 +108,15 @@ 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 (-0.5 * staff_size, +0.5 * staff_size);
+  Interval ydim = Staff_symbol_referencer::staff_span (me);
+  ydim *= staff_space / 2;
   Box b (xdim, ydim);
   Stencil out = Lookup::round_filled_box (b, blotdiameter);
   return out.smobbed_copy ();
@@ -130,20 +131,15 @@ 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 (-0.5 * staff_size, +0.5 * staff_size);
+  Interval ydim = Staff_symbol_referencer::staff_span (me);
+  ydim *= staff_space / 2;
   Box b (xdim, ydim);
   Stencil line1 = Lookup::round_filled_box (b, blotdiameter);
   Stencil line2 (line1);
index 00da1d53d1bfee2288287e082d2c5523a641121b..1366202f725013905fb37844b874628bec5e3bf0 100644 (file)
@@ -62,7 +62,6 @@ 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)
@@ -77,7 +76,7 @@ Custos::print (SCM smob)
     font_char += "d";
 
   if (adjust)
-    font_char += (((pos ^ sz) & 0x1) == 0) ? "1" : "0";
+    font_char += Staff_symbol_referencer::on_line (me, pos) ? "1" : "0";
   else
     font_char += "2";
 
index 8ba647e2019d8201d3698dbaa39cdd74f6671e90..0e7a01c5a7a204ec05f51f38cf0cd4af9a294884 100644 (file)
@@ -250,19 +250,14 @@ 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 (fabs (Staff_symbol_referencer::get_position (rest)
-                    + discrete_y) < stafflines + 1)
+          if (staff_span.contains
+              (Staff_symbol_referencer::get_position (rest) + discrete_y))
             {
               discrete_y = dir * int (ceil (dir * discrete_y / 2.0) * 2.0);
             }
index 9057e45af1bd90deaf29c0419ac2a2b2233ee8a9..8e45405de278dbd4ea5040dfc3259c6a2164a112 100644 (file)
@@ -37,7 +37,6 @@ 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"));
@@ -69,7 +68,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 && line_count > 1)
+      if (duration_log == 0 && Staff_symbol_referencer::line_count (me) > 1)
         pos += 2;
 
       /*
index 7420db3ec1bbaffc8e0d8af5825ac9e6fe4250fd..deb0218bd08ebe92a4e710efe9f00979ed0c7862 100644 (file)
@@ -37,8 +37,7 @@ vaticana_brew_cauda (Grob *me,
                      Real blotdiameter)
 {
   bool on_staffline = Staff_symbol_referencer::on_line (me, pos);
-  int interspaces = Staff_symbol_referencer::line_count (me) - 1;
-  bool above_staff = pos > interspaces;
+  bool above_staff = pos > Staff_symbol_referencer::staff_span (me)[UP];
 
   if (delta_pitch > -1)
     {