[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
line_count fixes (issue 6211047)
From: |
benko . pal |
Subject: |
line_count fixes (issue 6211047) |
Date: |
Sun, 13 May 2012 19:26:07 +0000 |
Reviewers: ,
http://codereview.appspot.com/6211047/diff/1/lily/slur-scoring.cc
File lily/slur-scoring.cc (right):
http://codereview.appspot.com/6211047/diff/1/lily/slur-scoring.cc#newcode593
lily/slur-scoring.cc:593: && Staff_symbol_referencer::on_staff_line
(on_staff, (int) rint (pos)))
this condition is stricter than the original, which wasn't bounded from
below. as a result some regression tests changed:
spacing-horizontal-skyline-grace improved (probably only by chance);
the change in quote-overrides is easy to see, I hope it's an improvement
for all;
slur-symmetry perhaps seems more symmetric to me now, but I'd like
someone to take a look into it;
I can't really see the actual difference in other lower slur changes.
http://codereview.appspot.com/6211047/diff/1/lily/time-signature.cc
File lily/time-signature.cc (right):
http://codereview.appspot.com/6211047/diff/1/lily/time-signature.cc#newcode61
lily/time-signature.cc:61: Real offset = staff_span.is_empty () ? 0.0 :
staff_span.center ();
this line creates a difference for staves not symmetric to 0.
for wildly asymmetric staves (non-centered-bar-lines,
breathing-sign-custom-staff) this is an improvement to me; the changes
in staff-line-positions and rest-on-nonstandard-staff are not that
clean.
Description:
line_count fixes
1. implementation does not assume staff centred at zero
2. where used for determining whether something falls on a line,
use Staff_symbol_referencer::on_line or on_staff_line
3. where used for determining whether something is within staff or not,
use Staff_symbol_referencer::staff_span
Please review this at http://codereview.appspot.com/6211047/
Affected files:
M input/regression/non-centered-bar-lines.ly
M lily/bar-line.cc
M lily/beam.cc
M lily/breathing-sign.cc
M lily/custos.cc
M lily/rest-collision.cc
M lily/rest.cc
M lily/slur-scoring.cc
M lily/time-signature.cc
M lily/vaticana-ligature.cc
Index: input/regression/non-centered-bar-lines.ly
diff --git a/input/regression/non-centered-bar-lines.ly
b/input/regression/non-centered-bar-lines.ly
index
429fc419151cea0697f95e009f0d746b351516f3..f12fb9850361f374cc7076c5c889351c09021427
100644
--- a/input/regression/non-centered-bar-lines.ly
+++ b/input/regression/non-centered-bar-lines.ly
@@ -8,5 +8,6 @@ staves which are not centered around address@hidden
\override Staff.StaffSymbol #'line-positions = #'(1 3 5 7 9)
c''1 \bar "||"
c''1 \bar ":"
+ c''1 \bar ":|"
c''1 \bar "|."
}
Index: lily/bar-line.cc
diff --git a/lily/bar-line.cc b/lily/bar-line.cc
index
0cd0339235b41c307459670210ea35c27f69d66d..21ffa7cf1acb556d1071beb2e635573616d243ce
100644
--- a/lily/bar-line.cc
+++ b/lily/bar-line.cc
@@ -112,15 +112,17 @@ 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");
- int lines = Staff_symbol_referencer::line_count (me);
+ Interval const staff_span = Staff_symbol_referencer::staff_span (me);
+ bool const empty_staff = staff_span.is_empty ();
+ Real const centre = empty_staff ? 0.0 : staff_span.center ();
Real dist
- = ((lines & 1 || lines == 0)
- ? 1
- : (staff_space < 2 ? 2 : .5)) * staff_space;
+ = empty_staff || Staff_symbol_referencer::on_line (me, centre)
+ ? 1
+ : staff_space < 2 ? 2 : .5;
Stencil colon (dot);
colon.translate_axis (dist, Y_AXIS);
colon.add_stencil (dot);
- colon.translate_axis (-dist / 2, Y_AXIS);
+ colon.translate_axis ((centre - dist) * staff_space / 2, Y_AXIS);
Real const h = extent.length ();
Stencil m;
Index: lily/beam.cc
diff --git a/lily/beam.cc b/lily/beam.cc
index
49253434c05d94faab4e471b44cc42898841f1e9..65065a56a4ca39299f65f690f96da3a3d55e0c5f
100644
--- a/lily/beam.cc
+++ b/lily/beam.cc
@@ -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 *= 0.5 / staff_space;
+
/* 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: lily/breathing-sign.cc
diff --git a/lily/breathing-sign.cc b/lily/breathing-sign.cc
index
a3d9637bef6d2d2e3685c8b23334b97b49804e13..62dc795faf555683f2c3a5209d265ca763ec7b9f
100644
--- a/lily/breathing-sign.cc
+++ b/lily/breathing-sign.cc
@@ -81,13 +81,21 @@ 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 (Direction i = DOWN;
+ i != DIRECTION_LIMIT;
+ i = i == DOWN ? UP : DIRECTION_LIMIT)
+ {
+ 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 +110,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 *= 0.5 / staff_space;
Box b (xdim, ydim);
Stencil out = Lookup::round_filled_box (b, blotdiameter);
return out.smobbed_copy ();
@@ -130,20 +133,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 *= 0.5 /staff_space;
Box b (xdim, ydim);
Stencil line1 = Lookup::round_filled_box (b, blotdiameter);
Stencil line2 (line1);
Index: lily/custos.cc
diff --git a/lily/custos.cc b/lily/custos.cc
index
00da1d53d1bfee2288287e082d2c5523a641121b..1366202f725013905fb37844b874628bec5e3bf0
100644
--- a/lily/custos.cc
+++ b/lily/custos.cc
@@ -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: lily/rest-collision.cc
diff --git a/lily/rest-collision.cc b/lily/rest-collision.cc
index
8ba647e2019d8201d3698dbaa39cdd74f6671e90..0e7a01c5a7a204ec05f51f38cf0cd4af9a294884
100644
--- a/lily/rest-collision.cc
+++ b/lily/rest-collision.cc
@@ -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: lily/rest.cc
diff --git a/lily/rest.cc b/lily/rest.cc
index
9057e45af1bd90deaf29c0419ac2a2b2233ee8a9..8e45405de278dbd4ea5040dfc3259c6a2164a112
100644
--- a/lily/rest.cc
+++ b/lily/rest.cc
@@ -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: lily/slur-scoring.cc
diff --git a/lily/slur-scoring.cc b/lily/slur-scoring.cc
index
eaadde5c587031a50ae5ad35be5e55ed59d22f84..9e50984243a9e5861dc36768e08c688797e1b3c2
100644
--- a/lily/slur-scoring.cc
+++ b/lily/slur-scoring.cc
@@ -590,8 +590,7 @@ 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_line (on_staff, (int) rint (pos))
- && Staff_symbol_referencer::line_count (on_staff) - 1 >= rint (pos))
+ && Staff_symbol_referencer::on_staff_line (on_staff, (int) rint
(pos)))
y += 1.5 * staff_space_ * dir_ / 10;
return y;
Index: lily/time-signature.cc
diff --git a/lily/time-signature.cc b/lily/time-signature.cc
index
ad553e4229268800e94763b3d81de959213272c2..61bb7af1824c5236cad9abc10bad774a314dc977
100644
--- a/lily/time-signature.cc
+++ b/lily/time-signature.cc
@@ -57,8 +57,12 @@ Time_signature::print (SCM smob)
else
m = numbered_time_signature (me, n, d);
- if (Staff_symbol_referencer::line_count (me) % 2 == 0)
- m.translate_axis (Staff_symbol_referencer::staff_space (me) / 2,
Y_AXIS);
+ Interval const staff_span = Staff_symbol_referencer::staff_span (me);
+ Real offset = staff_span.is_empty () ? 0.0 : staff_span.center ();
+ if (!Staff_symbol_referencer::on_line (me, offset))
+ offset += 1.0;
+ m.translate_axis
+ (offset * Staff_symbol_referencer::staff_space (me) / 2, Y_AXIS);
return m.smobbed_copy ();
}
Index: lily/vaticana-ligature.cc
diff --git a/lily/vaticana-ligature.cc b/lily/vaticana-ligature.cc
index
7420db3ec1bbaffc8e0d8af5825ac9e6fe4250fd..deb0218bd08ebe92a4e710efe9f00979ed0c7862
100644
--- a/lily/vaticana-ligature.cc
+++ b/lily/vaticana-ligature.cc
@@ -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)
{
- line_count fixes (issue 6211047),
benko . pal <=