Reviewers: ,
Message:
this patch makes staff_radius work in cases when line-positions is
overridden. so long staff_radius assumed overriding at most line-count.
http://codereview.appspot.com/6202048/diff/1/lily/tuplet-bracket.cc
File lily/tuplet-bracket.cc (left):
http://codereview.appspot.com/6202048/diff/1/lily/tuplet-bracket.cc#oldcode687
lily/tuplet-bracket.cc:687:
removed because regtest showed it not true
Description:
staff_radius fixes
1. implementation does not assume staff centred at zero
2. where used for determining whether within staff or not,
use new function Staff_symbol_referencer::staff_span instead
Please review this at http://codereview.appspot.com/6202048/
Affected files:
M lily/include/staff-symbol-referencer.hh
M lily/side-position-interface.cc
M lily/slur-configuration.cc
M lily/staff-symbol-referencer.cc
M lily/tie-formatting-problem.cc
M lily/tuplet-bracket.cc
Index: lily/include/staff-symbol-referencer.hh
diff --git a/lily/include/staff-symbol-referencer.hh
b/lily/include/staff-symbol-referencer.hh
index
179bae828f6905339b16ffa2757e67b9fb87fa12..79d07cfe7c91f9c6e1df1de0c5c75074f1784dbf
100644
--- a/lily/include/staff-symbol-referencer.hh
+++ b/lily/include/staff-symbol-referencer.hh
@@ -48,7 +48,17 @@ public:
static int line_count (Grob *);
static Real get_position (Grob *);
static Real pure_get_position (Grob *);
+
+ /**
+ Interval of staff lines.
+ */
+ static Interval staff_span (Grob *);
+
+ /**
+ Half of the height, in staff space, i.e. 2.0 for a normal staff.
+ */
static Real staff_radius (Grob *);
+
static int get_rounded_position (Grob *);
static int pure_get_rounded_position (Grob *);
static Interval extent_in_staff (Grob *);
Index: lily/side-position-interface.cc
diff --git a/lily/side-position-interface.cc
b/lily/side-position-interface.cc
index
7cf332e85c5bfd78e60ab63ff96abca40f6f808d..6fad89ea54cccf0e5846d69d35e90d6e0ff391c3
100644
--- a/lily/side-position-interface.cc
+++ b/lily/side-position-interface.cc
@@ -349,7 +349,9 @@ Side_position_interface::aligned_side (Grob *me, Axis
a, bool pure, int start, i
Real rounded = directed_round (position, dir);
Grob *head = me->get_parent (X_AXIS);
- if (fabs (position) <= 2 * Staff_symbol_referencer::staff_radius
(me) + 1
+ Interval staff_span = Staff_symbol::line_span (staff);
+ staff_span.widen (1);
+ if (staff_span.contains (position)
/* In case of a ledger lines, quantize even if we're outside
the staff. */
|| (Note_head::has_interface (head)
Index: lily/slur-configuration.cc
diff --git a/lily/slur-configuration.cc b/lily/slur-configuration.cc
index
d6d231de305e2b90c6aabdb80ea581c6dfb35064..79a4bba8c74b279db4ed935a0ddefdd3a848bbbd
100644
--- a/lily/slur-configuration.cc
+++ b/lily/slur-configuration.cc
@@ -49,19 +49,15 @@ avoid_staff_line (Slur_score_state const &state,
Real p = 2 * (y - staff->relative_coordinate (state.common_[Y_AXIS],
Y_AXIS))
/ state.staff_space_;
- Real distance = fabs (my_round (p) - p); // in halfspaces
- if (distance < 4 * state.thickness_
- && (int) fabs (my_round (p))
- <= 2 * Staff_symbol_referencer::staff_radius (staff) + 0.1
- && (int (fabs (my_round (p))) % 2
- != Staff_symbol_referencer::line_count (staff) % 2))
+ Real const round = my_round (p);
+ Real const frac = p - round;
+ if (fabs (frac) < 4 * state.thickness_
+ && Staff_symbol_referencer::on_staff_line (staff, int (round)))
{
- Direction resolution_dir
- = (distance ? state.dir_ : Direction (sign (p - my_round
(p))));
+ Direction resolution_dir = frac ? state.dir_ : CENTER;
// TODO: parameter
- Real newp = my_round (p) + resolution_dir
- * 5 * state.thickness_;
+ Real newp = round + resolution_dir * 5 * state.thickness_;
Real dy = (newp - p) * state.staff_space_ / 2.0;
@@ -292,12 +288,12 @@ Slur_configuration::score_encompass (Slur_score_state
const &state)
For slurs over 3 or 4 heads, the average distance is not a
good normalizer.
*/
- Real n = convex_head_distances.size ();
+ size_t n = convex_head_distances.size ();
if (n <= 2)
{
Real fact = 1.0;
avg_distance += height_ * fact;
- n += fact;
+ ++n;
}
/*
Index: lily/staff-symbol-referencer.cc
diff --git a/lily/staff-symbol-referencer.cc
b/lily/staff-symbol-referencer.cc
index
b18bb04fa3b8f7f2dd6b8d60206e09ac2fb08863..3b8aa6ba187698bb8ea6a92f1580c3069c9f787e
100644
--- a/lily/staff-symbol-referencer.cc
+++ b/lily/staff-symbol-referencer.cc
@@ -189,11 +189,23 @@ Staff_symbol_referencer::internal_set_position (Grob
*me, Real p, bool pure)
me->translate_axis ((p - oldpos) * ss * 0.5, Y_AXIS);
}
-/* Half of the height, in staff space, i.e. 2.0 for a normal staff. */
+Interval
+Staff_symbol_referencer::staff_span (Grob *me)
+{
+ Interval result;
+ if (me)
+ if (Grob *symb = get_staff_symbol (me))
+ result = Staff_symbol::line_span (symb);
+ return result;
+}
+
Real
Staff_symbol_referencer::staff_radius (Grob *me)
{
- return (line_count (me) - 1) / 2.0;
+ /*
+ line_span is measured in pitch steps, not in staff spaces
+ */
+ return staff_span (me).length () / 4.0;
}
int
Index: lily/tie-formatting-problem.cc
diff --git a/lily/tie-formatting-problem.cc b/lily/tie-formatting-problem.cc
index
d93df73abf2ef3db0d49169833cba4b7a2b7dd76..e2c3736f70d380147386b06847db5ee2849df594
100644
--- a/lily/tie-formatting-problem.cc
+++ b/lily/tie-formatting-problem.cc
@@ -497,22 +497,25 @@ Tie_formatting_problem::generate_configuration (int
pos, Direction dir,
size.
*/
+ Interval staff_span =
+ Staff_symbol_referencer::staff_span
(details_.staff_symbol_referencer_);
+ staff_span.widen (-1);
+ bool const within_staff = staff_span.contains(pos);
if (head_positions_slice (columns[LEFT]).contains (pos)
|| head_positions_slice (columns[RIGHT]).contains (pos)
- || abs (pos) < 2 * Staff_symbol_referencer::staff_radius
(details_.staff_symbol_referencer_))
+ || within_staff)
{
if (h < details_.intra_space_threshold_ * 0.5 *
details_.staff_space_)
{
- if (!Staff_symbol_referencer::on_line
(details_.staff_symbol_referencer_, pos)
- && abs (pos) < 2 * Staff_symbol_referencer::staff_radius
(details_.staff_symbol_referencer_))
- {
- conf->center_tie_vertically (details_);
- }
- else if (Staff_symbol_referencer::on_line
(details_.staff_symbol_referencer_, pos))
+ if (Staff_symbol_referencer::on_line
(details_.staff_symbol_referencer_, pos))
{
conf->delta_y_ += dir *
details_.tip_staff_line_clearance_ *
0.5 * details_.staff_space_;
}
+ else if (within_staff)
+ {
+ conf->center_tie_vertically (details_);
+ }
}
else
{
@@ -718,9 +721,11 @@ Tie_formatting_problem::score_configuration
(Tie_configuration *conf) const
Real top_y = tip_y + conf->dir_ * height;
Real top_pos = 2 * top_y / details_.staff_space_;
Real round_top_pos = rint (top_pos);
+ Interval staff_span =
+ Staff_symbol_referencer::staff_span
(details_.staff_symbol_referencer_);
if (Staff_symbol_referencer::on_line (details_.staff_symbol_referencer_,
int (round_top_pos))
- && Staff_symbol_referencer::staff_radius
(details_.staff_symbol_referencer_) > top_y)
+ && staff_span[UP] * 0.5 > top_y)
{
conf->add_score (details_.staff_line_collision_penalty_
* peak_around (0.1 *
details_.center_staff_line_clearance_,
@@ -730,10 +735,11 @@ Tie_formatting_problem::score_configuration
(Tie_configuration *conf) const
}
int rounded_tip_pos = int (rint (tip_pos));
+ staff_span.widen (-1);
if (Staff_symbol_referencer::on_line (details_.staff_symbol_referencer_,
rounded_tip_pos)
&& (head_positions_slice (conf->column_ranks_[LEFT]).contains
(rounded_tip_pos)
|| head_positions_slice (conf->column_ranks_[RIGHT]).contains
(rounded_tip_pos)
- || abs (rounded_tip_pos) < 2 *
Staff_symbol_referencer::staff_radius (details_.staff_symbol_referencer_))
+ || staff_span.contains (rounded_tip_pos))
)
{
conf->add_score (details_.staff_line_collision_penalty_
Index: lily/tuplet-bracket.cc
diff --git a/lily/tuplet-bracket.cc b/lily/tuplet-bracket.cc
index
37099683bf859b33cf91cbcf5fea282f60c74087..643d07ae67cc48dcebc51cacf07025a5e594cc00
100644
--- a/lily/tuplet-bracket.cc
+++ b/lily/tuplet-bracket.cc
@@ -681,21 +681,20 @@ Tuplet_bracket::calc_position_and_height (Grob
*me_grob, Real *offset, Real *dy)
/*
horizontal brackets should not collide with staff lines.
- Kind of pointless since we put them outside the staff anyway, but
- let's leave code for the future when possibly allow them to move
- into the staff once again.
-
This doesn't seem to support cross-staff tuplets atm.
*/
- if (*dy == 0
- && fabs (*offset) < ss * Staff_symbol_referencer::staff_radius (me))
+ if (*dy == 0)
{
// quantize, then do collision check.
- *offset *= 2 / ss;
+ *offset /= 0.5 * ss;
- *offset = rint (*offset);
- if (Staff_symbol_referencer::on_line (me, (int) rint (*offset)))
- *offset += dir;
+ Interval staff_span = Staff_symbol_referencer::staff_span (me);
+ if (staff_span.contains (*offset))
+ {
+ *offset = rint (*offset);
+ if (Staff_symbol_referencer::on_line (me, int (*offset)))
+ *offset += dir;
+ }
*offset *= 0.5 * ss;
}
_______________________________________________
lilypond-devel mailing list
lilypond-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-devel